incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1420572 - in /incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac: bloodhound.py bloodhound/ bloodhound/__init__.py bloodhound/db.py bloodhound/env.py bloodhoundsql.py web/standalone.py
Date Wed, 12 Dec 2012 08:37:23 GMT
Author: jure
Date: Wed Dec 12 08:37:22 2012
New Revision: 1420572

URL: http://svn.apache.org/viewvc?rev=1420572&view=rev
Log:
* reorganized code, moved bloodhound code to separate directory


Added:
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/__init__.py
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/db.py
      - copied, changed from r1420086, incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhoundsql.py
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/env.py
      - copied, changed from r1420086, incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound.py
Removed:
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound.py
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhoundsql.py
Modified:
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/web/standalone.py

Added: incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/__init__.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/__init__.py?rev=1420572&view=auto
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/__init__.py (added)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/__init__.py Wed
Dec 12 08:37:22 2012
@@ -0,0 +1,20 @@
+
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+from trac.bloodhound.env import *
+from trac.bloodhound.db import *

Copied: incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/db.py (from
r1420086, incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhoundsql.py)
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/db.py?p2=incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/db.py&p1=incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhoundsql.py&r1=1420086&r2=1420572&rev=1420572&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhoundsql.py (original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/db.py Wed Dec
12 08:37:22 2012
@@ -16,11 +16,52 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
+from trac.db.util import IterableCursor
+from trac.util import concurrency
+
 import sqlparse
 import sqlparse.tokens as Tokens
 import sqlparse.sql as Types
 
-__all__ = ['BloodhoundProductSQLTranslate']
+__all__ = ['BloodhoundIterableCursor']
+
+TRANSLATE_TABLES = ['ticket', 'enum', 'component', 'milestone', 'version', 'wiki']
+PRODUCT_COLUMN = 'product'
+
+class BloodhoundIterableCursor(IterableCursor):
+    __slots__ = IterableCursor.__slots__ + ['_translator']
+    _tls = concurrency.ThreadLocal(env=None)
+
+    def __init__(self, cursor, log=None):
+        super(BloodhoundIterableCursor, self).__init__(cursor, log=log)
+        self._translator = None
+
+    @property
+    def translator(self):
+        if not self._translator:
+            from env import DEFAULT_PRODUCT
+            product = self.env.product_scope if self.env else DEFAULT_PRODUCT
+            self._translator = BloodhoundProductSQLTranslate(TRANSLATE_TABLES,
+                                                             PRODUCT_COLUMN,
+                                                             product)
+        return self._translator
+
+    def _translate_sql(self, sql):
+        return self.translator.translate(sql) if (self.env and not self.env.product_aware)
else sql
+
+    def execute(self, sql, args=None):
+        return super(BloodhoundIterableCursor, self).execute(self._translate_sql(sql), args=args)
+
+    def executemany(self, sql, args=None):
+        return super(BloodhoundIterableCursor, self).executemany(self._translate_sql(sql),
args=args)
+
+    @property
+    def env(self):
+        return self._tls.env
+
+    @classmethod
+    def set_env(cls, env):
+        cls._tls.env = env
 
 class BloodhoundProductSQLTranslate(object):
     _join_statements = ['LEFT JOIN', 'LEFT OUTER JOIN',

Copied: incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/env.py (from
r1420086, incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound.py)
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/env.py?p2=incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/env.py&p1=incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound.py&r1=1420086&r2=1420572&rev=1420572&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound.py (original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/bloodhound/env.py Wed Dec
12 08:37:22 2012
@@ -16,49 +16,14 @@
 #  specific language governing permissions and limitations
 #  under the License.
 
-import trac.env
-from trac.db.util import IterableCursor
-from trac.util import concurrency
 from trac.env import Environment
-from bloodhoundsql import BloodhoundProductSQLTranslate
+import trac.db.util
 
-DEFAULT_PRODUCT = 'default'
-TRANSLATE_TABLES = ['ticket', 'enum', 'component', 'milestone', 'version', 'wiki']
-PRODUCT_COLUMN = 'product'
-
-class BloodhoundIterableCursor(IterableCursor):
-    __slots__ = IterableCursor.__slots__ + ['_translator']
-    _tls = concurrency.ThreadLocal(env=None)
-
-    def __init__(self, cursor, log=None):
-        super(BloodhoundIterableCursor, self).__init__(cursor, log=log)
-        self._translator = None
-
-    @property
-    def translator(self):
-        if not self._translator:
-            product = self.env.product_scope if self.env else DEFAULT_PRODUCT
-            self._translator = BloodhoundProductSQLTranslate(TRANSLATE_TABLES,
-                                                             PRODUCT_COLUMN,
-                                                             product)
-        return self._translator
-
-    def _translate_sql(self, sql):
-        return self.translator.translate(sql) if (self.env and not self.env.product_aware)
else sql
+from db import BloodhoundIterableCursor
 
-    def execute(self, sql, args=None):
-        return super(BloodhoundIterableCursor, self).execute(self._translate_sql(sql), args=args)
+__all__ = ["bloodhound_hooks", "BloodhoundEnvironment", "DEFAULT_PRODUCT"]
 
-    def executemany(self, sql, args=None):
-        return super(BloodhoundIterableCursor, self).executemany(self._translate_sql(sql),
args=args)
-
-    @property
-    def env(self):
-        return self._tls.env
-
-    @classmethod
-    def set_env(cls, env):
-        cls._tls.env = env
+DEFAULT_PRODUCT = 'default'
 
 class BloodhoundEnvironment(Environment):
     def __init__(self, path, create=False, options=[]):

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/web/standalone.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/web/standalone.py?rev=1420572&r1=1420571&r2=1420572&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/web/standalone.py (original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/web/standalone.py Wed Dec
12 08:37:22 2012
@@ -120,7 +120,7 @@ class TracHTTPRequestHandler(WSGIRequest
 class TracHTTP11RequestHandler(TracHTTPRequestHandler):
     protocol_version = 'HTTP/1.1'
 
-from trac.bloodhound import bloodhound_hooks
+from trac.bloodhound.env import bloodhound_hooks
 bloodhound_hooks()
 
 def main():



Mime
View raw message