[SQL-CVS] r708 - trunk/SQLObject/sqlobject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2005-04-04 05:56:32
|
Author: ianb
Date: 2005-04-04 05:56:29 +0000 (Mon, 04 Apr 2005)
New Revision: 708
Modified:
trunk/SQLObject/sqlobject/col.py
Log:
Reverting commits I didn't mean to make
Modified: trunk/SQLObject/sqlobject/col.py
===================================================================
--- trunk/SQLObject/sqlobject/col.py 2005-04-04 05:54:10 UTC (rev 707)
+++ trunk/SQLObject/sqlobject/col.py 2005-04-04 05:56:29 UTC (rev 708)
@@ -980,218 +980,3 @@
all.append(key)
__all__.extend(all)
del all
-
-
-
-# import boundattributes
-# import declarative
-
-# class BoundCol(object):
-
-# __metaclass__ = declarative.DeclarativeMeta
-
-# sqlTypeRegistry = {}
-
-# def __classinit__(cls, new_attrs):
-# cls.sqlTypeRegistry = cls.sqlTypeRegistry.copy()
-
-# def registerSQLType(cls, dbname, type_func):
-# if not isinstance(dbname, (list, tuple)):
-# dbname = [dbname]
-# for name in dbname:
-# cls.sqlTypeRegistry[name] = type_func
-# registerSQLType = classmethod(registerSQLType)
-
-# def __init__(self, added_class, attr_name,
-# dbName=None,
-# default=NoDefault,
-# alternateID=False,
-# alternateMethodName=None,
-# constraints=None,
-# notNull=NoDefault,
-# notNon=NoDefault,
-# sqlType=None,
-# validator=None,
-# immutable=False,
-# cascade=None,
-# lazy=False,
-# noCache=False,
-# forceDBName=False):
-# if not forceDBName:
-# assert sqlbuilder.sqlIdentifier(name), (
-# "Name must be SQL-safe (letters, numbers, underscores): "
-# "%s (or use forceDBName=True)" % repr(name))
-# assert attr_name != 'id', (
-# "The column name 'id' is reserved for SQLObject use (and is "
-# "implicitly created).")
-# assert name, "You must provide a name for all columns"
-# self.immutable = immutable
-# assert cascade in (None, True, False), (
-# "The cascade attribute must be one of None, True, or False "
-# "(you gave: %r" % cascade)
-# self.cascade = cascade
-
-# if not isinstance(constraints, (list, tuple)):
-# constraints = [constraints]
-# self.constraints = self.autoConstraints() + constraints
-
-# self.notNone = False
-# if notNull is not NoDefault:
-# self.notNone = notNull
-# assert (notNone is NoDefault or
-# (not notNone) == (not notNull)), (
-# "The notNull and notNone arguments are aliases, and must "
-# "not conflict. You gave notNull=%r, notNone=%r"
-# % (notNull, notNone))
-# elif notNone is not NoDefault:
-# self.notNone = notNone
-# if self.notNone:
-# self.constraints = [consts.notNull] + self.constraints
-
-# self.name = attr_name
-# self.soClass = added_class
-# self._default = default
-# self.customSQLType = sqlType
-
-# # if they don't give us a specific database name for
-# # the column, we separate the mixedCase into mixed_case
-# # and assume that.
-# if dbName is None:
-# self.dbName = added_class.sqlmeta.style.pythonAttrToDBColumn(self.name)
-# else:
-# self.dbName = dbName
-
-# # alternateID means that this is a unique column that
-# # can be used to identify rows
-# self.alternateID = alternateID
-# if self.alternateID and alternateMethodName is None:
-# self.alternateMethodName = 'by' + self.name[0].capitalize() + self.name[1:]
-# else:
-# self.alternateMethodName = alternateMethodName
-
-# if unique is NoDefault:
-# self.unique = alternateID
-# else:
-# self.unique = unique
-# self.validator = validator
-# self.noCache = noCache
-# self.lazy = lazy
-
-# self.soClass.addColumn(self.name, self)
-
-# def _set_validator(self, value):
-# self._validator = value
-# if self._validator:
-# self.toPython = self._validator.toPython
-# self.fromPython = self._validator.fromPython
-# else:
-# self.toPython = None
-# self.fromPython = None
-
-# def _get_validator(self):
-# return self._validator
-
-# validator = property(_get_validator, _set_validator)
-
-# def autoConstraints(self):
-# return []
-
-# def _get_default(self):
-# # A default can be a callback or a plain value,
-# # here we resolve the callback
-# if self._default is NoDefault:
-# return NoDefault
-# elif hasattr(self._default, '__sqlrepr__'):
-# return self._default
-# elif callable(self._default):
-# return self._default()
-# else:
-# return self._default
-# default = property(_get_default, None, None)
-
-# def __repr__(self):
-# r = '<%s %s' % (self.__class__.__name__, self.name)
-# if self.default is not NoDefault:
-# r += ' default=%s' % repr(self.default)
-# if self.foreignKey:
-# r += ' connected to %s' % self.foreignKey
-# if self.alternateID:
-# r += ' alternate ID'
-# if self.notNone:
-# r += ' not null'
-# return r + '>'
-
-# def createSQL(self, dbname):
-# if self.customSQLType is not None:
-# return self.customSQLType
-# try:
-# func = self.sqlTypeRegistry[dbname]
-# except KeyError:
-# assert 0, (
-# "The database %s does not support the column type %s "
-# "(no SQL type generator found; only %s found)"
-# % (dbname, self.__class__.__name__,
-# ', '.join(self.sqlTypeRegistry.keys())))
-# else:
-# return func(self, dbname)
-
-# def __get__(self, obj, type=None):
-# if obj is None:
-# # class attribute, return the descriptor itself
-# return self
-# if obj.sqlmeta.obsolete:
-# raise SQLObjectNotFound, (
-# "This object has been deleted from the database: %r"
-# % obj)
-# if obj.sqlmeta.cacheColumns:
-# columns = obj.sqlmeta._columnCache
-# if columns is None:
-# obj.sqlmeta.loadValues()
-# try:
-# return columns[name]
-# except KeyError:
-# return obj.sqlmeta.loadColumn(self)
-# else:
-# return obj.sqlmeta.loadColumn(self)
-
-# def __set__(self, obj, value):
-# if self.immutable:
-# raise AttributeError("The column %s.%s is immutable" %
-# (obj.__class__.__name__,
-# self.name))
-# obj.sqlmeta.setColumn(self, value)
-
-# def __delete__(self, obj):
-# raise AttributeError("I can't be deleted from %r" % obj)
-
-# class Col(boundattributes.BoundFactory):
-# factory_class = BoundCol
-
-# def addToClass(self, cls, addToThisClass, name):
-# me = self or cls
-# me.__addtoclass__(addToThisClass, name)
-# addToClass = declarative.classinstancemethod(addToClass)
-
-# class BoundStringCol(BoundCol):
-
-# def __init__(self, *args, **kw):
-# self.length = popKey(kw, 'length')
-# self.varchar = popKey(kw, 'varchar', 'auto')
-# if not self.length:
-# assert self.varchar == 'auto' or not self.varchar, (
-# "Without a length strings are treated as TEXT, not "
-# "VARCHAR")
-# self.varchar = False
-# elif self.varchar == 'auto':
-# self.varchar = True
-# BoundCol.__init__(self, *args, **kw)
-
-# def autoConstraints(self):
-# constraints = [consts.isString]
-# if self.length is not None:
-# constraints += [consts.MaxLength(self.length)]
-# return constraints
-
-
-# class StringCol(Col):
-# factory_class = BoundStringCol
|