Update of /cvsroot/webware/Webware/MiddleKit/Run
In directory usw-pr-cvs1:/tmp/cvs-serv18045/MiddleKit/Run
Modified Files:
MSSQLObjectStore.py MiddleObject.py ObjectKey.py
ObjectStore.py SQLObjectStore.py
Log Message:
Changed doc strings to use ''' instead of """
Index: MSSQLObjectStore.py
===================================================================
RCS file: /cvsroot/webware/Webware/MiddleKit/Run/MSSQLObjectStore.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** MSSQLObjectStore.py 17 Jun 2001 19:49:45 -0000 1.4
--- MSSQLObjectStore.py 20 Jun 2002 17:47:46 -0000 1.5
***************
*** 5,9 ****
class MSSQLObjectStore(SQLObjectStore):
! '''
MSSQLObjectStore does the obvious: it implements an object store backed by a MSSQL database.
--- 5,9 ----
class MSSQLObjectStore(SQLObjectStore):
! """
MSSQLObjectStore does the obvious: it implements an object store backed by a MSSQL database.
***************
*** 17,24 ****
You wouldn't use the 'db' argument, since that is determined by the model.
! '''
def dbapiConnect(self):
! '''
Returns a DB API 2.0 connection. This is a utility method invoked by connect(). Subclasses should implement this, making use of self._dbArgs (a dictionary specifying host, username, etc.).
Subclass responsibility.
--- 17,24 ----
You wouldn't use the 'db' argument, since that is determined by the model.
! """
def dbapiConnect(self):
! """
Returns a DB API 2.0 connection. This is a utility method invoked by connect(). Subclasses should implement this, making use of self._dbArgs (a dictionary specifying host, username, etc.).
Subclass responsibility.
***************
*** 26,30 ****
if you want it off, do not send any arg for clear_auto_commit or set it to 1
# self._db = ODBC.Windows.Connect(dsn='myDSN',clear_auto_commit=0)
! '''
return apply(ODBC.Windows.Connect, (), self._dbArgs)
--- 26,30 ----
if you want it off, do not send any arg for clear_auto_commit or set it to 1
# self._db = ODBC.Windows.Connect(dsn='myDSN',clear_auto_commit=0)
! """
return apply(ODBC.Windows.Connect, (), self._dbArgs)
***************
*** 37,44 ****
def sqlTableName(self):
! '''
Returns "[name]" so that table names do not conflict with SQL
reserved words.
! '''
return '[%s]' % self.sqlTableName()
--- 37,44 ----
def sqlTableName(self):
! """
Returns "[name]" so that table names do not conflict with SQL
reserved words.
! """
return '[%s]' % self.sqlTableName()
Index: MiddleObject.py
===================================================================
RCS file: /cvsroot/webware/Webware/MiddleKit/Run/MiddleObject.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** MiddleObject.py 9 May 2002 03:47:32 -0000 1.23
--- MiddleObject.py 20 Jun 2002 17:47:47 -0000 1.24
***************
*** 100,106 ****
def setSerialNum(self, value):
! ''' Sets the serial number of the object and invalidates the object's key.
There are some restrictions: Once the serial number is a positive value, indicating a legitimate value from the object store, it cannot be set to anything else. Also, if the serial number is negative, indicating a temporary serial number for new objects that haven't been committed to the database, it can only be set to a positive value.
! '''
assert type(value) in (type(0), type(0L)), "Type is: %r, value is: %r" % (type(value), value)
if self._mk_serialNum<0:
--- 100,106 ----
def setSerialNum(self, value):
! """ Sets the serial number of the object and invalidates the object's key.
There are some restrictions: Once the serial number is a positive value, indicating a legitimate value from the object store, it cannot be set to anything else. Also, if the serial number is negative, indicating a temporary serial number for new objects that haven't been committed to the database, it can only be set to a positive value.
! """
assert type(value) in (type(0), type(0L)), "Type is: %r, value is: %r" % (type(value), value)
if self._mk_serialNum<0:
***************
*** 253,257 ****
def valueForKey(self, attrName, default=NoDefault):
! '''
Returns the value of the named attribute by invoking its "get"
accessor method. You can use this when you want a value whose
--- 253,257 ----
def valueForKey(self, attrName, default=NoDefault):
! """
Returns the value of the named attribute by invoking its "get"
accessor method. You can use this when you want a value whose
***************
*** 265,269 ****
If the attribute is not found, the default argument is returned
if specified, otherwise LookupError is raised with the attrName.
! '''
attr = self.klass().lookupAttr(attrName, None)
if attr:
--- 265,269 ----
If the attribute is not found, the default argument is returned
if specified, otherwise LookupError is raised with the attrName.
! """
attr = self.klass().lookupAttr(attrName, None)
if attr:
***************
*** 276,280 ****
def setValueForKey(self, attrName, value):
! '''
Sets the value of the named attribute by invoking its "set"
accessor method. You can use this when you want a value whose
--- 276,280 ----
def setValueForKey(self, attrName, value):
! """
Sets the value of the named attribute by invoking its "set"
accessor method. You can use this when you want a value whose
***************
*** 288,292 ****
If the required set method is not found, a LookupError is raised
with the attrName.
! '''
try:
attr = self.klass().lookupAttr(attrName)
--- 288,292 ----
If the required set method is not found, a LookupError is raised
with the attrName.
! """
try:
attr = self.klass().lookupAttr(attrName)
Index: ObjectKey.py
===================================================================
RCS file: /cvsroot/webware/Webware/MiddleKit/Run/ObjectKey.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ObjectKey.py 13 Feb 2001 04:42:52 -0000 1.1
--- ObjectKey.py 20 Jun 2002 17:47:47 -0000 1.2
***************
*** 1,9 ****
class ObjectKey:
! '''
An ObjectKey is used by ObjectStore for keeping track of objects in memory.
Currently a key is equal to the class name of the object combined with the object's serial number, although as a user of object keys, you don't normally need to know what's inside them.
! '''
--- 1,9 ----
class ObjectKey:
! """
An ObjectKey is used by ObjectStore for keeping track of objects in memory.
Currently a key is equal to the class name of the object combined with the object's serial number, although as a user of object keys, you don't normally need to know what's inside them.
! """
***************
*** 12,16 ****
def initFromObject(self, object):
! ''' Initializes the key and potentially invokes object.setSerialNum() if the object does not have one. The key does not maintain a reference to either the object or the store. '''
self._className = object.__class__.__name__
self._serialNum = object.serialNum()
--- 12,16 ----
def initFromObject(self, object):
! """ Initializes the key and potentially invokes object.setSerialNum() if the object does not have one. The key does not maintain a reference to either the object or the store. """
self._className = object.__class__.__name__
self._serialNum = object.serialNum()
Index: ObjectStore.py
===================================================================
RCS file: /cvsroot/webware/Webware/MiddleKit/Run/ObjectStore.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** ObjectStore.py 3 May 2002 14:26:28 -0000 1.23
--- ObjectStore.py 20 Jun 2002 17:47:47 -0000 1.24
***************
*** 13,25 ****
class UnknownObjectError(LookupError):
! ''' This is the exception returned by store.fetchObject() if the specified object cannot be found (unless you also passed in a default value in which case that value is returned). '''
pass
class DeleteError(Exception):
! ''' Base class for all delete exceptions '''
pass
class DeleteReferencedError(DeleteError):
! '''
This is raised when you attempt to delete an object that is referenced by other objects with
onDeleteOther not set to detach or cascade. You can call referencingObjectsAndAttrs() to get a
--- 13,25 ----
class UnknownObjectError(LookupError):
! """ This is the exception returned by store.fetchObject() if the specified object cannot be found (unless you also passed in a default value in which case that value is returned). """
pass
class DeleteError(Exception):
! """ Base class for all delete exceptions """
pass
class DeleteReferencedError(DeleteError):
! """
This is raised when you attempt to delete an object that is referenced by other objects with
onDeleteOther not set to detach or cascade. You can call referencingObjectsAndAttrs() to get a
***************
*** 28,32 ****
This might not be the same as the object originally being deleted if a cascading
delete was happening.
! '''
def __init__(self, text, object, referencingObjectsAndAttrs):
Exception.__init__(self, text)
--- 28,32 ----
This might not be the same as the object originally being deleted if a cascading
delete was happening.
! """
def __init__(self, text, object, referencingObjectsAndAttrs):
Exception.__init__(self, text)
***************
*** 39,43 ****
class DeleteObjectWithReferencesError(DeleteError):
! '''
This is raised when you attempt to delete an object that references other objects,
with onDeleteSelf=deny. You can call attrs() to get a list of attributes
--- 39,43 ----
class DeleteObjectWithReferencesError(DeleteError):
! """
This is raised when you attempt to delete an object that references other objects,
with onDeleteSelf=deny. You can call attrs() to get a list of attributes
***************
*** 46,50 ****
This might not be the same as the object originally being deleted if a cascading
delete was happening.
! '''
def __init__(self, text, object, attrs):
Exception.__init__(self, text)
--- 46,50 ----
This might not be the same as the object originally being deleted if a cascading
delete was happening.
! """
def __init__(self, text, object, attrs):
Exception.__init__(self, text)
***************
*** 57,61 ****
class ObjectStore(ModelUser):
! '''
NOT IMPLEMENTED:
* revertChanges()
--- 57,61 ----
class ObjectStore(ModelUser):
! """
NOT IMPLEMENTED:
* revertChanges()
***************
*** 63,67 ****
FUTURE
* expanded fetch
! '''
--- 63,67 ----
FUTURE
* expanded fetch
! """
***************
*** 82,89 ****
def setting(self, name, default=NoDefault):
! '''
Returns the given setting for the store, which is actually
just taken from the model.
! '''
return self._model.setting(name, default)
--- 82,89 ----
def setting(self, name, default=NoDefault):
! """
Returns the given setting for the store, which is actually
just taken from the model.
! """
return self._model.setting(name, default)
***************
*** 100,104 ****
def object(self, key, default=NoDefault):
! ''' Returns an object from the store by it's given key. If no default is given and the object is not in the store, then an exception is raised. Note: This method doesn't currently fetch objects from the persistent store. '''
if default is NoDefault:
return self._objects[key]
--- 100,104 ----
def object(self, key, default=NoDefault):
! """ Returns an object from the store by it's given key. If no default is given and the object is not in the store, then an exception is raised. Note: This method doesn't currently fetch objects from the persistent store. """
if default is NoDefault:
return self._objects[key]
***************
*** 271,275 ****
def saveChanges(self):
! ''' Commits object changes to the object store by invoking commitInserts(), commitUpdates() and commitDeletions() all of which must by implemented by a concrete subclass. '''
self.commitDeletions()
self.commitInserts()
--- 271,275 ----
def saveChanges(self):
! """ Commits object changes to the object store by invoking commitInserts(), commitUpdates() and commitDeletions() all of which must by implemented by a concrete subclass. """
self.commitDeletions()
self.commitInserts()
***************
*** 278,294 ****
def commitInserts(self):
! ''' Invoked by saveChanges() to insert any news objects add since the last save. Subclass responsibility. '''
raise SubclassResponsibilityError
def commitUpdates(self):
! ''' Invoked by saveChanges() to update the persistent store with any changes since the last save. '''
raise SubclassResponsibilityError
def commitDeletions(self):
! ''' Invoked by saveChanges() to delete from the persistent store any objects deleted since the last save. Subclass responsibility. '''
raise SubclassResponsibilityError
def revertChanges(self):
! ''' Discards all insertions and deletions, and restores changed objects to their original values. '''
raise NotImplementedError
--- 278,294 ----
def commitInserts(self):
! """ Invoked by saveChanges() to insert any news objects add since the last save. Subclass responsibility. """
raise SubclassResponsibilityError
def commitUpdates(self):
! """ Invoked by saveChanges() to update the persistent store with any changes since the last save. """
raise SubclassResponsibilityError
def commitDeletions(self):
! """ Invoked by saveChanges() to delete from the persistent store any objects deleted since the last save. Subclass responsibility. """
raise SubclassResponsibilityError
def revertChanges(self):
! """ Discards all insertions and deletions, and restores changed objects to their original values. """
raise NotImplementedError
***************
*** 297,305 ****
def fetchObject(self, className, serialNum, default=NoDefault):
! ''' Subclasses should raise UnknownObjectError if an object with the given className and serialNum does not exist, unless a default value was passed in, in which case that value should be returned. '''
raise SubclassResponsibilityError
def fetchObjectsOfClass(self, className, isDeep=1):
! ''' Fetches all objects of a given class. If isDeep is 1, then all subclasses are also returned. '''
raise SubclassResponsibilityError
--- 297,305 ----
def fetchObject(self, className, serialNum, default=NoDefault):
! """ Subclasses should raise UnknownObjectError if an object with the given className and serialNum does not exist, unless a default value was passed in, in which case that value should be returned. """
raise SubclassResponsibilityError
def fetchObjectsOfClass(self, className, isDeep=1):
! """ Fetches all objects of a given class. If isDeep is 1, then all subclasses are also returned. """
raise SubclassResponsibilityError
***************
*** 342,350 ****
def objectChanged(self, object):
! '''
MiddleObjects must send this message when one of their interesting attributes change, where an attribute is interesting if it's listed in the class model.
This method records the object in a set for later processing when the store's changes are saved.
If you subclass MiddleObject, then you're taken care of.
! '''
self._hasChanges = 1
self._changedObjects[object] = object ## @@ 2000-10-06 ce: Should this be keyed by the object.key()? Does it matter?
--- 342,350 ----
def objectChanged(self, object):
! """
MiddleObjects must send this message when one of their interesting attributes change, where an attribute is interesting if it's listed in the class model.
This method records the object in a set for later processing when the store's changes are saved.
If you subclass MiddleObject, then you're taken care of.
! """
self._hasChanges = 1
self._changedObjects[object] = object ## @@ 2000-10-06 ce: Should this be keyed by the object.key()? Does it matter?
***************
*** 354,358 ****
def newSerialNum(self):
! ''' Returns a new serial number for a newly created object. This is a utility methods for objects that have been created, but not yet committed to the persistent store. These serial numbers are actually temporary and replaced upon committal. Also, they are always negative to indicate that they are temporary, whereas serial numbers taken from the persistent store are positive. '''
self._newSerialNum -= 1
return self._newSerialNum
--- 354,358 ----
def newSerialNum(self):
! """ Returns a new serial number for a newly created object. This is a utility methods for objects that have been created, but not yet committed to the persistent store. These serial numbers are actually temporary and replaced upon committal. Also, they are always negative to indicate that they are temporary, whereas serial numbers taken from the persistent store are positive. """
self._newSerialNum -= 1
return self._newSerialNum
***************
*** 362,371 ****
def _klassForClass(self, aClass):
! ''' Returns a Klass object for the given class, which may be:
- the Klass object already
- a Python class
- a class name (e.g., string)
Users of this method include the various fetchObjectEtc() methods which take a "class" parameter.
! '''
assert aClass is not None
if not isinstance(aClass, BaseKlass):
--- 362,371 ----
def _klassForClass(self, aClass):
! """ Returns a Klass object for the given class, which may be:
- the Klass object already
- a Python class
- a class name (e.g., string)
Users of this method include the various fetchObjectEtc() methods which take a "class" parameter.
! """
assert aClass is not None
if not isinstance(aClass, BaseKlass):
***************
*** 382,385 ****
def shouldRegisterChanges(self):
! ''' MiddleObject asks attributes if changes should be registered. By default, all attributes respond true, but specific stores may choose to override this (a good example being ListAttr for SQLStore). '''
return 1
--- 382,385 ----
def shouldRegisterChanges(self):
! """ MiddleObject asks attributes if changes should be registered. By default, all attributes respond true, but specific stores may choose to override this (a good example being ListAttr for SQLStore). """
return 1
Index: SQLObjectStore.py
===================================================================
RCS file: /cvsroot/webware/Webware/MiddleKit/Run/SQLObjectStore.py,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** SQLObjectStore.py 4 May 2002 03:54:56 -0000 1.45
--- SQLObjectStore.py 20 Jun 2002 17:47:48 -0000 1.46
***************
*** 17,26 ****
class UnknownSerialNumberError(SQLObjectStoreError):
! '''
For internal use when archiving objects.
Sometimes an obj ref cannot be immediately resolved on INSERT because
the target has not yet been inserted and therefore, given a serial number.
! '''
def __init__(self, info):
self.info = info
--- 17,26 ----
class UnknownSerialNumberError(SQLObjectStoreError):
! """
For internal use when archiving objects.
Sometimes an obj ref cannot be immediately resolved on INSERT because
the target has not yet been inserted and therefore, given a serial number.
! """
def __init__(self, info):
self.info = info
***************
*** 50,54 ****
class SQLObjectStore(ObjectStore):
! '''
TO DO:
--- 50,54 ----
class SQLObjectStore(ObjectStore):
! """
TO DO:
***************
*** 57,61 ****
For details on DB API 2.0, including the thread safety levels see:
http://www.python.org/topics/database/DatabaseAPI-2.0.html
! '''
## Init ##
--- 57,61 ----
For details on DB API 2.0, including the thread safety levels see:
http://www.python.org/topics/database/DatabaseAPI-2.0.html
! """
## Init ##
***************
*** 72,81 ****
def modelWasSet(self):
! '''
Performs additional set up of the store after the model is set,
normally via setModel() or readModelFileNamed(). This includes
checking that threading conditions are valid, and connecting to
the database.
! '''
ObjectStore.modelWasSet(self)
--- 72,81 ----
def modelWasSet(self):
! """
Performs additional set up of the store after the model is set,
normally via setModel() or readModelFileNamed(). This includes
checking that threading conditions are valid, and connecting to
the database.
! """
ObjectStore.modelWasSet(self)
***************
*** 133,137 ****
def connect(self):
! '''
Connects to the database only if the store has not already and
provided that the store has a valid model.
--- 133,137 ----
def connect(self):
! """
Connects to the database only if the store has not already and
provided that the store has a valid model.
***************
*** 139,143 ****
The default implementation of connect() is usually sufficient
provided that subclasses have implemented newConnection().
! '''
assert self._model, 'Cannot connect: No model has been attached to this store yet.'
if not self._connected:
--- 139,143 ----
The default implementation of connect() is usually sufficient
provided that subclasses have implemented newConnection().
! """
assert self._model, 'Cannot connect: No model has been attached to this store yet.'
if not self._connected:
***************
*** 152,156 ****
def newConnection(self):
! '''
Returns a DB API 2.0 connection. This is a utility method
invoked by connect(). Subclasses should implement this, making
--- 152,156 ----
def newConnection(self):
! """
Returns a DB API 2.0 connection. This is a utility method
invoked by connect(). Subclasses should implement this, making
***************
*** 159,169 ****
Subclass responsibility.
! '''
raise SubclassResponsibilityError
def readKlassIds(self):
! '''
Reads the klass ids from the SQL database. Invoked by connect().
! '''
conn, cur = self.executeSQL('select id, name from _MKClassIds;')
klassesById = {}
--- 159,169 ----
Subclass responsibility.
! """
raise SubclassResponsibilityError
def readKlassIds(self):
! """
Reads the klass ids from the SQL database. Invoked by connect().
! """
conn, cur = self.executeSQL('select id, name from _MKClassIds;')
klassesById = {}
***************
*** 213,218 ****
def retrieveLastInsertId(self, conn, cur):
! ''' Returns the id (typically a 32-bit int) of the last INSERT operation by this connection. Used by commitInserts() to get the correct serial number for the last inserted object.
! Subclass responsibility. '''
raise SubclassResponsibilityError
--- 213,218 ----
def retrieveLastInsertId(self, conn, cur):
! """ Returns the id (typically a 32-bit int) of the last INSERT operation by this connection. Used by commitInserts() to get the correct serial number for the last inserted object.
! Subclass responsibility. """
raise SubclassResponsibilityError
***************
*** 233,239 ****
def fetchObject(self, aClass, serialNum, default=NoDefault):
! ''' Fetches a single object of a specific class and serial number. TheClass can be a Klass object (from the MiddleKit object model), the name of the class (e.g., a string) or a Python class.
Raises an exception if theClass parameter is invalid, or the object cannot be located.
! '''
klass = self._klassForClass(aClass)
objects = self.fetchObjectsOfClass(klass, serialNum=serialNum, isDeep=0)
--- 233,239 ----
def fetchObject(self, aClass, serialNum, default=NoDefault):
! """ Fetches a single object of a specific class and serial number. TheClass can be a Klass object (from the MiddleKit object model), the name of the class (e.g., a string) or a Python class.
Raises an exception if theClass parameter is invalid, or the object cannot be located.
! """
klass = self._klassForClass(aClass)
objects = self.fetchObjectsOfClass(klass, serialNum=serialNum, isDeep=0)
***************
*** 249,253 ****
def fetchObjectsOfClass(self, aClass, clauses='', isDeep=1, refreshAttrs=1, serialNum=None):
! '''
Fetches a list of objects of a specific class. The list may be empty if no objects are found.
aClass can be a Klass object (from the MiddleKit object model), the name of the class (e.g., a string) or a Python class.
--- 249,253 ----
def fetchObjectsOfClass(self, aClass, clauses='', isDeep=1, refreshAttrs=1, serialNum=None):
! """
Fetches a list of objects of a specific class. The list may be empty if no objects are found.
aClass can be a Klass object (from the MiddleKit object model), the name of the class (e.g., a string) or a Python class.
***************
*** 258,262 ****
The reason for labeling is that this method is likely to undergo improvements in the future which could include additional arguments. No guarantees are made about the order of the arguments except that aClass will always be the first.
Raises an exception if aClass parameter is invalid.
! '''
klass = self._klassForClass(aClass)
--- 258,262 ----
The reason for labeling is that this method is likely to undergo improvements in the future which could include additional arguments. No guarantees are made about the order of the arguments except that aClass will always be the first.
Raises an exception if aClass parameter is invalid.
! """
klass = self._klassForClass(aClass)
***************
*** 306,310 ****
def executeSQL(self, sql, connection=None):
! '''
Executes the given SQL, connecting to the database for the first
time if necessary. This method will also log the SQL to
--- 306,310 ----
def executeSQL(self, sql, connection=None):
! """
Executes the given SQL, connecting to the database for the first
time if necessary. This method will also log the SQL to
***************
*** 313,317 ****
Note that you can pass in a connection to force a particular one
to be used.
! '''
self._sqlCount += 1
if self._sqlEcho:
--- 313,317 ----
Note that you can pass in a connection to force a particular one
to be used.
! """
self._sqlCount += 1
if self._sqlEcho:
***************
*** 333,342 ****
def setSQLEcho(self, file):
! ''' Sets a file to echo sql statements to, as sent through executeSQL(). None can be passed to turn echo off. '''
self._sqlEcho = file
def connectionAndCursor(self, connection=None):
! '''
Returns the connection and cursor needed for executing SQL,
taking into account factors such as setting('Threaded') and the
--- 333,342 ----
def setSQLEcho(self, file):
! """ Sets a file to echo sql statements to, as sent through executeSQL(). None can be passed to turn echo off. """
self._sqlEcho = file
def connectionAndCursor(self, connection=None):
! """
Returns the connection and cursor needed for executing SQL,
taking into account factors such as setting('Threaded') and the
***************
*** 344,348 ****
connection to force a particular one to be used. Uses
newConnection() and connect().
! '''
if connection:
conn = connection
--- 344,348 ----
connection to force a particular one to be used. Uses
newConnection() and connect().
! """
if connection:
conn = connection
***************
*** 365,371 ****
def newConnection(self):
! '''
Subclasses must override to return a newly created database connection.
! '''
raise SubclassResponsibilityError
--- 365,371 ----
def newConnection(self):
! """
Subclasses must override to return a newly created database connection.
! """
raise SubclassResponsibilityError
***************
*** 374,380 ****
def addDeletedToClauses(self, clauses):
! '''
Modify the given set of clauses so that it filters out records with non-NULL deleted field
! '''
clauses = clauses.strip()
if clauses.lower().startswith('where'):
--- 374,380 ----
def addDeletedToClauses(self, clauses):
! """
Modify the given set of clauses so that it filters out records with non-NULL deleted field
! """
clauses = clauses.strip()
if clauses.lower().startswith('where'):
***************
*** 430,439 ****
def objRefZeroSerialNum(self, objRef):
! ''' Invoked by fetchObjRef() if either the class or object serial number is 0. '''
self.warning('Zero serial number. Obj ref = %x.' % objRef)
return None
def objRefDangles(self, objRef):
! ''' Invoked by fetchObjRef() if there is no possible target object for the given objRef, e.g., a dangling reference. This method invokes self.warning() and includes the objRef as decimal, hexadecimal and class:obj numbers. '''
klassId, objSerialNum = objRefSplit(objRef)
self.warning('Obj ref dangles. dec=%i hex=%x class.obj=%s.%i.' % (objRef, objRef, self.klassForId(klassId).name(), objSerialNum))
--- 430,439 ----
def objRefZeroSerialNum(self, objRef):
! """ Invoked by fetchObjRef() if either the class or object serial number is 0. """
self.warning('Zero serial number. Obj ref = %x.' % objRef)
return None
def objRefDangles(self, objRef):
! """ Invoked by fetchObjRef() if there is no possible target object for the given objRef, e.g., a dangling reference. This method invokes self.warning() and includes the objRef as decimal, hexadecimal and class:obj numbers. """
klassId, objSerialNum = objRefSplit(objRef)
self.warning('Obj ref dangles. dec=%i hex=%x class.obj=%s.%i.' % (objRef, objRef, self.klassForId(klassId).name(), objSerialNum))
***************
*** 478,482 ****
def sqlInsertStmt(self, unknowns):
! '''
Returns the SQL insert statements for MySQL (as a tuple) in the form:
insert into table (name, ...) values (value, ...);
--- 478,482 ----
def sqlInsertStmt(self, unknowns):
! """
Returns the SQL insert statements for MySQL (as a tuple) in the form:
insert into table (name, ...) values (value, ...);
***************
*** 484,488 ****
May add an info object to the unknowns list for obj references that
are not yet resolved.
! '''
klass = self.klass()
insertSQLStart, sqlAttrs = klass.insertSQLStart()
--- 484,488 ----
May add an info object to the unknowns list for obj references that
are not yet resolved.
! """
klass = self.klass()
insertSQLStart, sqlAttrs = klass.insertSQLStart()
***************
*** 503,511 ****
def sqlUpdateStmt(self):
! '''
Returns the SQL update statement for MySQL of the form:
update table set name=value, ... where idName=idValue;
Installed as a method of MiddleObject.
! '''
assert self._mk_changedAttrs
klass = self.klass()
--- 503,511 ----
def sqlUpdateStmt(self):
! """
Returns the SQL update statement for MySQL of the form:
update table set name=value, ... where idName=idValue;
Installed as a method of MiddleObject.
! """
assert self._mk_changedAttrs
klass = self.klass()
***************
*** 519,523 ****
def sqlDeleteStmt(self):
! '''
Returns the SQL delete statement for MySQL of the form:
delete from table where idName=idValue;
--- 519,523 ----
def sqlDeleteStmt(self):
! """
Returns the SQL delete statement for MySQL of the form:
delete from table where idName=idValue;
***************
*** 525,529 ****
update table set deleted=Now();
Installed as a method of MiddleObject.
! '''
klass = self.klass()
assert klass is not None
--- 525,529 ----
update table set deleted=Now();
Installed as a method of MiddleObject.
! """
klass = self.klass()
assert klass is not None
***************
*** 548,557 ****
def sqlTableName(self):
! '''
Returns the name of the SQL table for this class.
Returns self.name().
Subclasses may wish to override to provide special quoting that
prevents name collisions between table names and reserved words.
! '''
return self.name()
--- 548,557 ----
def sqlTableName(self):
! """
Returns the name of the SQL table for this class.
Returns self.name().
Subclasses may wish to override to provide special quoting that
prevents name collisions between table names and reserved words.
! """
return self.name()
***************
*** 589,601 ****
def shouldRegisterChanges(self):
! ''' Returns self.hasSQLColumn(). This only makes sense since there would be no point in registering changes on an attribute with no corresponding SQL column. The standard example of such an attribute is "list". '''
return self.hasSQLColumn()
def hasSQLColumn(self):
! ''' Returns true if the attribute has a direct correlating SQL column in it's class' SQL table definition. Most attributes do. Those of type list do not. '''
return not self.get('isDerived', 0)
def sqlColumnName(self):
! ''' Returns the SQL column name corresponding to this attribute, consisting of self.name() + self.sqlTypeSuffix(). '''
if not self._sqlColumnName:
self._sqlColumnName = self.name() + self.sqlTypeSuffix()
--- 589,601 ----
def shouldRegisterChanges(self):
! """ Returns self.hasSQLColumn(). This only makes sense since there would be no point in registering changes on an attribute with no corresponding SQL column. The standard example of such an attribute is "list". """
return self.hasSQLColumn()
def hasSQLColumn(self):
! """ Returns true if the attribute has a direct correlating SQL column in it's class' SQL table definition. Most attributes do. Those of type list do not. """
return not self.get('isDerived', 0)
def sqlColumnName(self):
! """ Returns the SQL column name corresponding to this attribute, consisting of self.name() + self.sqlTypeSuffix(). """
if not self._sqlColumnName:
self._sqlColumnName = self.name() + self.sqlTypeSuffix()
***************
*** 603,611 ****
def sqlTypeSuffix(self):
! ''' Returns a string to be used as a suffix for sqlColumnName(). Returns an empty string. Occasionally, a subclass will override this to help clarify SQL column names of their type. '''
return ''
def sqlValue(self, value):
! ''' For a given Python value, this returns the correct string for use in a SQL INSERT statement. Subclasses should override if this implementation, which returns repr(value), doesn't work for them. This method is responsible for returning 'NULL' if the value is None. '''
if value is None:
return 'NULL'
--- 603,611 ----
def sqlTypeSuffix(self):
! """ Returns a string to be used as a suffix for sqlColumnName(). Returns an empty string. Occasionally, a subclass will override this to help clarify SQL column names of their type. """
return ''
def sqlValue(self, value):
! """ For a given Python value, this returns the correct string for use in a SQL INSERT statement. Subclasses should override if this implementation, which returns repr(value), doesn't work for them. This method is responsible for returning 'NULL' if the value is None. """
if value is None:
return 'NULL'
|