|
[Webware-checkins] CVS: Webware/MiddleKit/Core Attr.py,1.11,1.12 Klass.py,1.18,1.19 ObjRefAttr.py,1.2,1.3
From: Chuck Esterbrook <echuck@us...> - 2004-02-28 03:30
|
Update of /cvsroot/webware/Webware/MiddleKit/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14756/Core Modified Files: Attr.py Klass.py ObjRefAttr.py Log Message: - make fooClassId SQL columns default to the target class of the obj ref attr - add error checking when loading a model that the target class of an obj ref attr actually exists Index: Attr.py =================================================================== RCS file: /cvsroot/webware/Webware/MiddleKit/Core/Attr.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Attr.py 16 Feb 2004 22:14:52 -0000 1.11 --- Attr.py 28 Feb 2004 03:13:08 -0000 1.12 *************** *** 78,79 **** --- 78,82 ---- def model(self): return self._klass.klasses()._model + + def awakeFromRead(self): + pass Index: Klass.py =================================================================== RCS file: /cvsroot/webware/Webware/MiddleKit/Core/Klass.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Klass.py 8 Dec 2003 06:08:40 -0000 1.18 --- Klass.py 28 Feb 2004 03:13:08 -0000 1.19 *************** *** 70,73 **** --- 70,75 ---- # Invoking pyClass() makes that happen. self.pyClass() + for attr in self.attrs(): + attr.awakeFromRead() def _makeAllAttrs(self): *************** *** 283,287 **** # find all ObjRefAttrs of klass that refer to one of our targetKlasses for attr in klass.attrs(): ! if isinstance(attr, ObjRefAttr) and targetKlasses.has_key(attr.className()): backObjRefAttrs.append(attr) self._backObjRefAttrs = backObjRefAttrs --- 285,289 ---- # find all ObjRefAttrs of klass that refer to one of our targetKlasses for attr in klass.attrs(): ! if isinstance(attr, ObjRefAttr) and targetKlasses.has_key(attr.targetClassName()): backObjRefAttrs.append(attr) self._backObjRefAttrs = backObjRefAttrs Index: ObjRefAttr.py =================================================================== RCS file: /cvsroot/webware/Webware/MiddleKit/Core/ObjRefAttr.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ObjRefAttr.py 20 Jun 2002 17:47:44 -0000 1.2 --- ObjRefAttr.py 28 Feb 2004 03:13:08 -0000 1.3 *************** *** 21,25 **** self._className = dict['Type'] ! def className(self): """ Returns the name of the base class that this obj ref attribute points to. """ return self._className --- 21,43 ---- self._className = dict['Type'] ! def targetClassName(self): """ Returns the name of the base class that this obj ref attribute points to. """ return self._className + + def targetKlass(self): + assert self._targetKlass, 'not yet fully initialized' + return self._targetKlass + + def awakeFromRead(self): + """ + Check that the target class actually exists. + """ + self._targetKlass = self.model().klass(self.targetClassName(), None) + if not self._targetKlass: + from Model import ModelError + raise ModelError, 'class %s: attr %s: cannot locate target class %s for this obj ref.' % ( + self.klass().name(), self.name(), self.targetClassName()) + + def className(self): + print 'DEPRECATED: ObjRefAttr.className() on 2004-02-27. Use targetClassName() instead.' + return self.targetClassName() |
| Thread | Author | Date |
|---|---|---|
| [Webware-checkins] CVS: Webware/MiddleKit/Core Attr.py,1.11,1.12 Klass.py,1.18,1.19 ObjRefAttr.py,1.2,1.3 | Chuck Esterbrook <echuck@us...> |