Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Paro committed Apr 21, 2010
0 parents commit b99f805
Show file tree
Hide file tree
Showing 23 changed files with 1,039 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pyc
*~
.hg*
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Waldemar Kornewald
Alberto Paro (Setuptools)
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include MANIFEST.in
include README.rst
include AUTHORS
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
djangotoolbox
-------------

Utility functions for django-nonrel
11 changes: 11 additions & 0 deletions djangotoolbox/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
__author__ = 'Waldemar Kornewald'

VERSION = (0, 1, 0)

def get_version():
version = '%s.%s' % (VERSION[0], VERSION[1])
if VERSION[2]:
version = '%s.%s' % (version, VERSION[2])
return version

__version__ = get_version()
Empty file added djangotoolbox/db/__init__.py
Empty file.
61 changes: 61 additions & 0 deletions djangotoolbox/db/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import datetime
from django.db.backends import BaseDatabaseFeatures, BaseDatabaseOperations, \
BaseDatabaseWrapper, BaseDatabaseClient, BaseDatabaseValidation, \
BaseDatabaseIntrospection

from .creation import NonrelDatabaseCreation

class NonrelDatabaseFeatures(BaseDatabaseFeatures):
distinguishes_insert_from_update = False
supports_deleting_related_objects = False
supports_multi_table_inheritance = False

class NonrelDatabaseOperations(BaseDatabaseOperations):
def quote_name(self, name):
return name

def value_to_db_date(self, value):
# value is a date here, no need to check it
return value

def value_to_db_datetime(self, value):
# value is a datetime here, no need to check it
return value

def value_to_db_time(self, value):
# value is a time here, no need to check it
return value

def prep_for_like_query(self, value):
return value

def check_aggregate_support(self, aggregate):
# TODO: Only COUNT(*) should be supported, by default.
# Raise NotImplementedError in all other cases.
pass

def year_lookup_bounds(self, value):
return [datetime.datetime(value, 1, 1, 0, 0, 0, 0),
datetime.datetime(value+1, 1, 1, 0, 0, 0, 0)]

class NonrelDatabaseClient(BaseDatabaseClient):
pass

class NonrelDatabaseValidation(BaseDatabaseValidation):
pass

class NonrelDatabaseIntrospection(BaseDatabaseIntrospection):
def table_names(self):
"""Returns a list of names of all tables that exist in the database."""
return self.django_table_names()

class FakeCursor(object):
def __getattribute__(self, name):
raise NotImplementedError('Cursors not supported')

def __setattr__(self, name, value):
raise NotImplementedError('Cursors not supported')

class NonrelDatabaseWrapper(BaseDatabaseWrapper):
def _cursor(self):
return FakeCursor()
Loading

0 comments on commit b99f805

Please sign in to comment.