Update of /cvsroot/webware/Webware/MiddleKit/Design
In directory usw-pr-cvs1:/tmp/cvs-serv9305/Design
Modified Files:
MSSQLPythonGenerator.py PythonGenerator.py
Log Message:
more optimizations
Index: MSSQLPythonGenerator.py
===================================================================
RCS file: /cvsroot/webware/Webware/MiddleKit/Design/MSSQLPythonGenerator.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MSSQLPythonGenerator.py 26 Apr 2001 15:50:39 -0000 1.1
--- MSSQLPythonGenerator.py 29 Mar 2002 05:16:28 -0000 1.2
***************
*** 20,23 ****
if value is not None and type(value) is not LongType:
assert type(value) is InstanceType
- self._%(name)s = value
''' % locals())
--- 20,23 ----
if value is not None and type(value) is not LongType:
assert type(value) is InstanceType
''' % locals())
+ self.writePySetAssignment(out.write, name)
Index: PythonGenerator.py
===================================================================
RCS file: /cvsroot/webware/Webware/MiddleKit/Design/PythonGenerator.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** PythonGenerator.py 21 Mar 2002 20:57:22 -0000 1.15
--- PythonGenerator.py 29 Mar 2002 05:16:28 -0000 1.16
***************
*** 190,194 ****
out.write('\n\tdef %(pySetName)s(self, value):\n' % values)
self.writePySetChecks(out)
! out.write('\t\tself._%(name)s = value\n' % values)
def writePySetChecks(self, out):
--- 190,213 ----
out.write('\n\tdef %(pySetName)s(self, value):\n' % values)
self.writePySetChecks(out)
! self.writePySetAssignment(out.write, name)
!
! def writePySetAssignment(self, write, name):
! write('''
! # set the attribute
! origValue = self._%(name)s
! self._%(name)s = value
!
! # MiddleKit machinery
! self._mk_changed = 1 # @@ original semantics, but I think this should be under "if not self._mk_initing..."
! if not self._mk_initing and self._mk_serialNum>0 and value is not origValue:
! attr = self.klass().lookupAttr('%(name)s') # @@ could use allAttrs() dictionary
! if attr.shouldRegisterChanges():
! # Record that it has been changed
! if self._mk_changedAttrs is None:
! self._mk_changedAttrs = {} # maps name to attribute
! self._mk_changedAttrs['%(name)s'] = attr # changedAttrs is a set
! # Tell ObjectStore it happened
! self._mk_store.objectChanged(self)
! ''' % {'name': name})
def writePySetChecks(self, out):
***************
*** 380,385 ****
if not isinstance(value, %(targetClassName)s):
raise TypeError, 'expecting %(targetClassName)s, but got value %%r of type %%r instead' %% (value, type(value))
- self._%(name)s = value
''' % locals())
--- 399,404 ----
if not isinstance(value, %(targetClassName)s):
raise TypeError, 'expecting %(targetClassName)s, but got value %%r of type %%r instead' %% (value, type(value))
''' % locals())
+ self.writePySetAssignment(out.write, name)
|