Commits

Waldemar Kornewald committed 0534783

added proxy DB backend base classes

Comments (0)

Files changed (4)

dbproxy/__init__.py

Empty file added.
+from django.db import connections
+
+class Proxy(object):
+    def __init__(self, target):
+        self.__target = target
+    
+    def __getattr__(self, name):
+        return getattr(self.__target, name)
+
+class DatabaseWrapper(Proxy):
+    def __init__(self, settings_dict, *args, **kwds):
+        super(DatabaseWrapper, self).__init__(
+            connections[settings_dict['TARGET_BACKEND']])

dbproxy/compiler.py

+from .base import Proxy
+from django.conf import settings
+from django.db.models.sql import aggregates as sqlaggregates
+from django.db.models.sql.constants import LOOKUP_SEP, MULTI, SINGLE
+from django.db.models.sql.where import AND, OR
+from django.db.utils import DatabaseError, IntegrityError
+from django.utils.tree import Node
+
+class SQLCompiler(Proxy):
+    def execute_sql(self, result_type=MULTI):
+        """
+        Handles aggregate/count queries
+        """
+        pass
+
+    def results_iter(self):
+        """
+        Returns an iterator over the results from executing this query.
+        """
+        pass
+
+    def has_results(self):
+        pass
+
+class SQLInsertCompiler(Proxy):
+    def execute_sql(self, return_id=False):
+        pass
+
+class SQLUpdateCompiler(Proxy):
+    def execute_sql(self, result_type=MULTI):
+        pass
+
+class SQLDeleteCompiler(Proxy):
+    def execute_sql(self, result_type=MULTI):
+        pass
 from copy import deepcopy
-from django.views.generic.simple import direct_to_template
 import functools, re
 
 PATTERNS = {
 easyurl = URLPatternGenerator()
 regex = easyurl.regex
 
+class ClassFunction(object):
+    def __new__(cls, *args, **kwargs):
+        obj = super(ClassFunction, cls).__new__(cls)
+        return obj(*args, **kwargs)
+
+    def __call__(self, *args, **kwargs):
+        pass
+
 class Views(object):
     urlpatterns = patterns('', )
 
-    def __init__(self):
-        self._urlpatterns = urlpatterns.copy()
-
-    # Emulate urlpatterns behavior
-    def __iter__(self):
-        return self._urlpatterns.__iter__()
-
-    def __getitem__(self, index):
-        return self._urlpatterns[index]
-
-    def __len__(self):
-        return len(self._urlpatterns)
-
     def __call__(self, request, *args, **kwargs):
         pass