pypersyst-cvs Mailing List for Pypersyst - Python Persistence System (Page 2)
Brought to you by:
pobrien
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
(12) |
Apr
(11) |
May
(45) |
Jun
(97) |
Jul
(5) |
Aug
(73) |
Sep
(266) |
Oct
(222) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(81) |
Jun
(57) |
Jul
(279) |
Aug
(88) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Matthew R. S. <gld...@us...> - 2004-08-10 16:34:48
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11123/pypersyst/ui/qt Modified Files: collection.py supplier.py Log Message: Cosmetic improvements: widget stacks return the minimum size hint of their visible widget, not of the least-common-denominator minimum size hint amongst all their widgets. Index: supplier.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/supplier.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** supplier.py 5 Aug 2004 03:18:17 -0000 1.8 --- supplier.py 10 Aug 2004 16:34:38 -0000 1.9 *************** *** 175,178 **** --- 175,184 ---- self._collectionWidget = {} + def minimumSizeHint(self): + h = qt.QWidgetStack.minimumSizeHint(self) + visible = self.visibleWidget() + h2 = visible.minimumSizeHint() + return h2 + def onCollectionWidgetCreated(self, payload): domain = self._domain *************** *** 195,198 **** --- 201,205 ---- collection = payload.collection widget = self._collectionWidget[collection] + visible = self.visibleWidget() self.raiseWidget(widget) Index: collection.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/collection.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** collection.py 10 Aug 2004 16:02:10 -0000 1.30 --- collection.py 10 Aug 2004 16:34:38 -0000 1.31 *************** *** 81,84 **** --- 81,90 ---- widget.setDefaultAction(a) + def minimumSizeHint(self): + h = qt.QWidgetStack.minimumSizeHint(self) + visible = self.visibleWidget() + h2 = visible.minimumSizeHint() + return h2 + # -- Signal handlers -- |
From: Matthew R. S. <gld...@us...> - 2004-08-10 16:02:20
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4545/pypersyst/ui/qt Modified Files: collection.py Log Message: Partial support for icons. Index: collection.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/collection.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** collection.py 9 Aug 2004 22:38:50 -0000 1.29 --- collection.py 10 Aug 2004 16:02:10 -0000 1.30 *************** *** 136,139 **** --- 136,145 ---- collection = payload.collection plural = domain.IPluralLabel(collection) + iconSet = qt.QIconSet() + icon = domain.IIcon(collection, None) + if icon is not None: + image = qt.QImage() + image.loadFromData(icon) + iconSet.setPixmap(qt.QPixmap(image), iconSet.Automatic) # Create a submenu if requested. submenu = None *************** *** 165,171 **** if submenu.count() > 1: submenu.insertSeparator(1) ! self.insertItem('&' + plural, submenu) else: ! self.insertItem(viewLabel, onViewActivated, qt.QKeySequence(), -1, -1) --- 171,177 ---- if submenu.count() > 1: submenu.insertSeparator(1) ! self.insertItem(iconSet, '&' + plural, submenu) else: ! self.insertItem(iconSet, viewLabel, onViewActivated, qt.QKeySequence(), -1, -1) *************** *** 525,532 **** domain = self._domain collection = payload.collection # Create a widget to contain the action buttons. widget = qt.QWidget(self) widget._collection = collection ! self.addItem(widget, domain.IPluralLabel(collection)) self._collectionWidget[collection] = widget # Add the action buttons to the widget. --- 531,544 ---- domain = self._domain collection = payload.collection + iconSet = qt.QIconSet() + icon = domain.IIcon(collection, None) + if icon is not None: + image = qt.QImage() + image.loadFromData(icon) + iconSet.setPixmap(qt.QPixmap(image), iconSet.Automatic) # Create a widget to contain the action buttons. widget = qt.QWidget(self) widget._collection = collection ! self.addItem(widget, iconSet, domain.IPluralLabel(collection)) self._collectionWidget[collection] = widget # Add the action buttons to the widget. |
From: Matthew R. S. <gld...@us...> - 2004-08-10 16:02:19
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/domain In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4545/pypersyst/domain Modified Files: domain.py interface.py Log Message: Partial support for icons. Index: interface.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/domain/interface.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** interface.py 9 Aug 2004 22:38:30 -0000 1.23 --- interface.py 10 Aug 2004 16:02:10 -0000 1.24 *************** *** 28,31 **** --- 28,72 ---- + class IIcon(protocol.Interface): + """An icon for something.""" + + + def declareIcon(ob, icon=None, forWhat=None): + """Convenience function for declaring icon(s) for something. + + ob: The object to declare an icon for. + + icon: For static icons, a string containing binary image data. For + dynamic icons, a function that accepts one paramter (the object to + generate an icon for) and returns a string containing binary image + data. + + forWhat: Optional indicator of what type of thing it is for which + a icon is being declared. Valid values are 'forObjects', + 'forProtocols', and 'forTypes' and cause declareIcon to act + according to the use of those same-named arguments to the + PyProtocols declareAdapter function. If None, a default will be + inferred based on what ob is. + """ + if icon is not None: + if type(icon) == types.StringType: + def factory(ob, icon=icon): + return icon + else: + factory = value + kwargs = {'factory': factory, + 'provides': [IIcon], + } + if forWhat is not None: + kwargs[forWhat] = [ob] + elif (type(ob) == types.ClassType or + type(ob) == types.TypeType): + # Object is a class. + kwargs['forTypes'] = [ob] + else: + kwargs['forObjects'] = [ob] + protocol.declareAdapter(**kwargs) + + class ILabel(protocol.Interface): """A label for something. Singular, if the label is a noun.""" *************** *** 66,71 **** if forWhat is not None: kwargs[forWhat] = [ob] ! elif type(ob) == types.ClassType or \ ! type(ob) == types.TypeType: # Object is a class. kwargs['forTypes'] = [ob] --- 107,112 ---- if forWhat is not None: kwargs[forWhat] = [ob] ! elif (type(ob) == types.ClassType or ! type(ob) == types.TypeType): # Object is a class. kwargs['forTypes'] = [ob] Index: domain.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/domain/domain.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** domain.py 4 Aug 2004 04:55:58 -0000 1.36 --- domain.py 10 Aug 2004 16:02:10 -0000 1.37 *************** *** 180,185 **** v = protocol.Variation(proto) setattr(self, name, v) ! # Make sure we can get a label from it if it has a label ! # assigned to it. try: label = domain.interface.ILabel(proto) --- 180,185 ---- v = protocol.Variation(proto) setattr(self, name, v) ! # Make sure we can get a label and/or icon from it if it has a ! # label and/or icon assigned to it. try: label = domain.interface.ILabel(proto) *************** *** 194,197 **** --- 194,209 ---- forObjects=[v], ) + try: + icon = domain.interface.IIcon(proto) + except protocol.AdaptationFailure: + pass + else: + def iconFromVariation(v, icon=icon): + return icon + protocol.declareAdapter( + factory=iconFromVariation, + provides=[self.IIcon], + forObjects=[v], + ) def _postsetup(self): *************** *** 282,289 **** """Create local Interface variations.""" names = dir(domain.interface) ! # Make sure ILabel and IPluralLabel are created first, since ! # _localVariation uses them. names.remove('ILabel') names.remove('IPluralLabel') names.insert(0, 'ILabel') names.insert(0, 'IPluralLabel') --- 294,303 ---- """Create local Interface variations.""" names = dir(domain.interface) ! # Make sure IIcon, ILabel, and IPluralLabel are created first, ! # since _localVariation uses them. ! names.remove('IIcon') names.remove('ILabel') names.remove('IPluralLabel') + names.insert(0, 'IIcon') names.insert(0, 'ILabel') names.insert(0, 'IPluralLabel') |
From: Matthew R. S. <gld...@us...> - 2004-08-10 16:02:19
|
Update of /cvsroot/pypersyst/pypersyst/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4545/doc Modified Files: domains.txt Log Message: Partial support for icons. Index: domains.txt =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/doc/domains.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** domains.txt 21 Jul 2004 01:22:36 -0000 1.2 --- domains.txt 10 Aug 2004 16:02:10 -0000 1.3 *************** *** 143,144 **** --- 143,200 ---- what type of transaction occurs when the supplier is executed (if the supplier is executable). + + Icons + ----- + + Developers of user interface code that interacts with PyPerSyst + Domains often desire that code to also show icons for objects it gets + from the application's domain. + + The ``pypersyst.domain.interface`` module provides an interface that + is used to determine the icon of an object, ``IIcon``. Anything you + want to display an icon for in the user interface should have an icon + defined for it. + + The ``pypersyst.domain.interface`` module also provides a convenience + function, ``declareIcon``, used to declare an icon for an object or + group of objects. The icon can be either a static string containing + the binary image of the icon, or a callable that produces the string + dynamically. + + Typically, you will only have to use ``declareIcon`` to label things. + In other words, under most circumstances you will not need to declare + the underlying adapters for the icon interface. + + Objects that should have icons + .............................. + + You will typically want to have your user interface code declare icons + for some or all of the following types of objects: + + - **Action** classes should have icons that represent the action. + + - **Collection** instances should have icons that represent the data + they contain. + + - **Domain** instances should have icons that could be used in an + About box, or as an application icon. + + - **Field** classes should have icons that represent the data they + contain. + + - **Fieldspace** instances should have icons that represent the data + they contain. Often, Fieldspace instances will have the same icons + as their associated collection. + + - **Supplier** instances should have icons that represent what the + supplier is helping you do. For suppliers that are created by + applying actions onto other objects, they will typically have the + same icon as that action. + + Objects that have default icons + ............................... + + Because of the confusion that might occur if several different types + of objects have the same default icon, no default icons are declared. + All icons must be declared by the application using PyPerSyst. + |
From: Matthew R. S. <gld...@us...> - 2004-08-09 23:41:02
|
Update of /cvsroot/pypersyst/sandbox/gldnspud/orderd/schema In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20453/schema Modified Files: domain.py field.py root.py Log Message: Sync with PyPerSyst changes. Index: root.py =================================================================== RCS file: /cvsroot/pypersyst/sandbox/gldnspud/orderd/schema/root.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** root.py 21 Jul 2004 01:21:39 -0000 1.8 --- root.py 9 Aug 2004 23:40:52 -0000 1.9 *************** *** 12,19 **** class Customer(Entity): ! _attrSpec = [ ! 'id', ! 'name', ! 'city', ] --- 12,19 ---- class Customer(Entity): ! _spec = [ ! ('id', field.Id), ! ('name', field.Name), ! ('city', field.City), ] *************** *** 23,32 **** ] - _fieldSpec = { - 'id': field.Id, - 'name': field.Name, - 'city': field.City, - } - interface.declareLabel(Customer, lambda ob: ob.name) --- 23,26 ---- *************** *** 34,40 **** class CustomerCredit(Entity): ! _attrSpec = [ ! 'customer', ! 'limit', ] --- 28,34 ---- class CustomerCredit(Entity): ! _spec = [ ! ('customer', field.Customer), ! ('limit', field.Limit), ] *************** *** 43,57 **** ] - _fieldSpec = { - 'customer': field.Customer, - 'limit': field.Limit, - } - class CustomerExtra(Entity): ! _attrSpec = [ ! 'customer', ! 'whuffie', ] --- 37,46 ---- ] class CustomerExtra(Entity): ! _spec = [ ! ('customer', field.Customer), ! ('whuffie', field.Whuffie), ] *************** *** 60,75 **** ] - _fieldSpec = { - 'customer': field.Customer, - 'whuffie': field.Whuffie, - } - class Order(Entity): ! _attrSpec = [ ! 'customer', ! 'date', ! 'id', ] --- 49,59 ---- ] class Order(Entity): ! _spec = [ ! ('customer', field.Customer), ! ('date', field.Date), ! ('id', field.Id), ] *************** *** 78,87 **** ] - _fieldSpec = { - 'customer': field.Customer, - 'date': field.Date, - 'id': field.Id, - } - interface.declareLabel(Order, lambda ob: str(ob.id)) --- 62,65 ---- *************** *** 89,96 **** class OrderDetail(Entity): ! _attrSpec = [ ! 'order', ! 'product', ! 'quantity', ] --- 67,74 ---- class OrderDetail(Entity): ! _spec = [ ! ('order', field.Order), ! ('product', field.Product), ! ('quantity', field.Quantity), ] *************** *** 99,116 **** ] - _fieldSpec = { - 'order': field.Order, - 'product': field.Product, - 'quantity': field.Quantity, - } - class Product(Entity): ! _attrSpec = [ ! 'id', ! 'name', ! 'group', ! 'price', ] --- 77,88 ---- ] class Product(Entity): ! _spec = [ ! ('id', field.Id), ! ('name', field.Name), ! ('group', field.Group), ! ('price', field.Price), ] *************** *** 120,130 **** ] - _fieldSpec = { - 'id': field.Id, - 'name': field.Name, - 'group': field.Group, - 'price': field.Price, - } - interface.declareLabel(Product, lambda ob: str(ob.id)) --- 92,95 ---- Index: domain.py =================================================================== RCS file: /cvsroot/pypersyst/sandbox/gldnspud/orderd/schema/domain.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** domain.py 27 Jul 2004 03:36:34 -0000 1.25 --- domain.py 9 Aug 2004 23:40:52 -0000 1.26 *************** *** 24,39 **** protocol.advise(instancesProvide=[interface.IFieldspace]) ! _attrSpec = root.Customer._attrSpec[:] ! _attrSpec.extend([ ! 'credit.limit', ! 'extra.whuffie', ]) - _fieldSpec = root.Customer._fieldSpec.copy() - _fieldSpec.update({ - 'credit.limit': root.CustomerCredit._fieldSpec['limit'], - 'extra.whuffie': root.CustomerExtra._fieldSpec['whuffie'], - }) - def _fromClass(cls, EntityClass): cfs = Customer() --- 24,33 ---- protocol.advise(instancesProvide=[interface.IFieldspace]) ! _spec = root.Customer._spec[:] ! _spec.extend([ ! ('credit.limit', field.Limit), ! ('extra.whuffie', field.Whuffie), ]) def _fromClass(cls, EntityClass): cfs = Customer() *************** *** 58,63 **** class CustomerCollection(collection.ExtentCollection): ! _attrSpec = Customer._attrSpec ! _fieldSpec = Customer._fieldSpec --- 52,56 ---- class CustomerCollection(collection.ExtentCollection): ! _spec = Customer._spec *************** *** 100,111 **** protocol.advise(instancesProvide=[interface.IFieldspace]) ! _attrSpec = [ ! 'adjustment', ] - _fieldSpec = { - 'adjustment': field.Adjustment, - } - interface.declareLabel(Adjustment, 'Adjustment', 'Adjustments') --- 93,100 ---- protocol.advise(instancesProvide=[interface.IFieldspace]) ! _spec = [ ! ('adjustment', field.Adjustment), ] interface.declareLabel(Adjustment, 'Adjustment', 'Adjustments') Index: field.py =================================================================== RCS file: /cvsroot/pypersyst/sandbox/gldnspud/orderd/schema/field.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** field.py 22 Jul 2004 00:55:53 -0000 1.6 --- field.py 9 Aug 2004 23:40:52 -0000 1.7 *************** *** 6,27 **** class Adjustment(field.Money): ! label = 'Adjustment' class City(field.String): ! label = 'City' class Customer(field.EntityInstance): - label = 'Customer' validClassNames = ['Customer'] class Date(field.Date): ! label = 'Date' class Group(field.String): ! label = 'Group' --- 6,26 ---- class Adjustment(field.Money): ! pass class City(field.String): ! pass class Customer(field.EntityInstance): validClassNames = ['Customer'] class Date(field.Date): ! pass class Group(field.String): ! pass *************** *** 32,62 **** class Limit(field.Money): default = 100.00 - label = 'Limit' class Name(field.String): ! label = 'Name' class Order(field.EntityInstance): - label = 'Order' validClassNames = ['Order'] class Price(field.Money): ! label = 'Price' class Product(field.EntityInstance): - label = 'Product' validClassNames = ['Product'] class Quantity(field.Integer): ! label = 'Quantity' class Whuffie(field.Integer): ! label = 'Whuffie' --- 31,58 ---- class Limit(field.Money): default = 100.00 class Name(field.String): ! pass class Order(field.EntityInstance): validClassNames = ['Order'] class Price(field.Money): ! pass class Product(field.EntityInstance): validClassNames = ['Product'] class Quantity(field.Integer): ! pass class Whuffie(field.Integer): ! pass |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:39:27
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/test Modified Files: test_domain.py test_entity.py test_entity_root.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: test_entity_root.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/test_entity_root.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_entity_root.py 3 Sep 2003 19:10:09 -0000 1.1 --- test_entity_root.py 9 Aug 2004 22:38:47 -0000 1.2 *************** *** 37,41 **** def test_registerEntityClass(self): class EntitySubclass(entity.Entity): ! pass root = self.root root._registerEntityClass(EntitySubclass) --- 37,41 ---- def test_registerEntityClass(self): class EntitySubclass(entity.Entity): ! _spec = [] root = self.root root._registerEntityClass(EntitySubclass) *************** *** 60,64 **** def test_registerEntityClass_TrueDup(self): class Thing(entity.Entity): ! pass self.root._registerEntityClass(Thing) originalExtent = self.root['Thing'] --- 60,64 ---- def test_registerEntityClass_TrueDup(self): class Thing(entity.Entity): ! _spec = [] self.root._registerEntityClass(Thing) originalExtent = self.root['Thing'] Index: test_domain.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/test_domain.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** test_domain.py 9 Aug 2004 16:38:31 -0000 1.30 --- test_domain.py 9 Aug 2004 22:38:30 -0000 1.31 *************** *** 103,111 **** collection = self.domain['Realm'] extent = self.domain.db['Realm'] ! self.assertEqual(collection._attrSpec, extent._attrSpec) ! for name, fieldClass in extent._fieldSpec.items(): ! self.assertEqual(collection._fieldSpec[name], fieldClass) ! for name, fieldClass in collection._fieldSpec.items(): ! self.assertEqual(extent._fieldSpec[name], fieldClass) def test_getByOid(self): --- 103,107 ---- collection = self.domain['Realm'] extent = self.domain.db['Realm'] ! self.assertEqual(collection._spec, extent._spec) def test_getByOid(self): Index: test_entity.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/test_entity.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** test_entity.py 26 Jun 2004 15:19:15 -0000 1.22 --- test_entity.py 9 Aug 2004 22:38:30 -0000 1.23 *************** *** 123,128 **** class SimpleEntity(Entity): ! _attrSpec = [ ! 'name', ] --- 123,128 ---- class SimpleEntity(Entity): ! _spec = [ ! ('name', None), ] *************** *** 220,223 **** --- 220,225 ---- class SomeEntity(Entity): + _spec = [] + v2 = 0 v3 = 0 *************** *** 278,283 **** class BadAttrEntity(Entity): ! _attrSpec = [ ! 'name', ] --- 280,285 ---- class BadAttrEntity(Entity): ! _spec = [ ! ('name', None), ] *************** *** 300,305 **** class BadAltKeyEntity(Entity): ! _attrSpec = [ ! 'name', ] --- 302,307 ---- class BadAltKeyEntity(Entity): ! _spec = [ ! ('name', None), ] *************** *** 321,327 **** class DupAltKeyEntity(Entity): ! _attrSpec = [ ! 'name', ! 'other', ] --- 323,329 ---- class DupAltKeyEntity(Entity): ! _spec = [ ! ('name', None), ! ('other', None), ] *************** *** 344,352 **** class FieldedEntity(Entity): ! _fieldSpec = { ! 'testfield': field.Field, ! } ! ! _attrSpec = _fieldSpec.keys() --- 346,352 ---- class FieldedEntity(Entity): ! _spec = [ ! ('testfield', field.Field), ! ] *************** *** 421,431 **** class InheritanceEntity(FieldedEntity): ! _fieldSpec = { ! 'anotherfield': field.Field, ! } ! ! _fieldSpec.update(FieldedEntity._fieldSpec) ! _attrSpec = _fieldSpec.keys() --- 421,429 ---- class InheritanceEntity(FieldedEntity): ! _spec = [ ! ('anotherfield', field.Field), ! ] ! _spec += FieldedEntity._spec *************** *** 468,476 **** class OidEntity(Entity): ! _fieldSpec = { ! '_oid': field.Field, ! } ! ! _attrSpec = _fieldSpec.keys() --- 466,472 ---- class OidEntity(Entity): ! _spec = [ ! ('_oid', field.Field), ! ] |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:39:27
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test/schema In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/test/schema Modified Files: root.py twistedroot.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: root.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/schema/root.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** root.py 7 Jul 2004 20:26:39 -0000 1.1 --- root.py 9 Aug 2004 22:38:47 -0000 1.2 *************** *** 14,21 **** """Avatar class.""" ! _attrSpec = [ ! 'realm', ! 'user', ! 'name', ] --- 14,21 ---- """Avatar class.""" ! _spec = [ ! ('realm', None), ! ('user', None), ! ('name', None), ] *************** *** 28,33 **** """Realm class.""" ! _attrSpec = [ ! 'name', ] --- 28,33 ---- """Realm class.""" ! _spec = [ ! ('name', None), ] *************** *** 40,46 **** """Thing class.""" ! _attrSpec = [ ! 'name', ! 'quantity', ] --- 40,46 ---- """Thing class.""" ! _spec = [ ! ('name', None), ! ('quantity', None), ] *************** *** 53,59 **** """User class.""" ! _attrSpec = [ ! 'name', ! 'hashedPassword', ] --- 53,59 ---- """User class.""" ! _spec = [ ! ('name', None), ! ('hashedPassword', None), ] Index: twistedroot.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/schema/twistedroot.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** twistedroot.py 7 Jul 2004 20:26:39 -0000 1.1 --- twistedroot.py 9 Aug 2004 22:38:47 -0000 1.2 *************** *** 14,21 **** """Avatar class.""" ! _attrSpec = [ ! 'realm', ! 'user', ! 'name', ] --- 14,21 ---- """Avatar class.""" ! _spec = [ ! ('realm', None), ! ('user', None), ! ('name', None), ] *************** *** 28,33 **** """Realm class.""" ! _attrSpec = [ ! 'name', ] --- 28,33 ---- """Realm class.""" ! _spec = [ ! ('name', None), ] *************** *** 40,46 **** """User class.""" ! _attrSpec = [ ! 'name', ! 'hashedPassword', ] --- 40,46 ---- """User class.""" ! _spec = [ ! ('name', None), ! ('hashedPassword', None), ] |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:39:27
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/migration/2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/test/schevo/migration/2 Modified Files: system.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: system.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/migration/2/system.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** system.py 7 Oct 2003 16:36:58 -0000 1.1 --- system.py 9 Aug 2004 22:38:48 -0000 1.2 *************** *** 14,21 **** """Avatar class.""" ! _attrSpec = [ ! 'realm', ! 'user', ! 'name', ] --- 14,21 ---- """Avatar class.""" ! _spec = [ ! ('realm', None), ! ('user', None), ! ('name', None), ] *************** *** 28,33 **** """Realm class.""" ! _attrSpec = [ ! 'name', ] --- 28,33 ---- """Realm class.""" ! _spec = [ ! ('name', None), ] *************** *** 40,46 **** """User class.""" ! _attrSpec = [ ! 'name', ! 'hashedPassword', ] --- 40,46 ---- """User class.""" ! _spec = [ ! ('name', None), ! ('hashedPassword', None), ] |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:39:26
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test/schemaF In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/test/schemaF Modified Files: root.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: root.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/schemaF/root.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** root.py 9 Aug 2004 19:49:15 -0000 1.3 --- root.py 9 Aug 2004 22:38:48 -0000 1.4 *************** *** 14,29 **** - # Avatar class shows old-style of _attrSpec and _fieldSpec, all other - # classes show new-style _spec which determines _attrSpec and - # _fieldSpec. - - class Avatar(Entity): """Avatar class.""" ! _attrSpec = [ ! 'realm', ! 'user', ! 'name', ] --- 14,24 ---- class Avatar(Entity): """Avatar class.""" ! _spec = [ ! ('realm', pfield.EntityInstance), ! ('user', pfield.EntityInstance), ! ('name', pfield.String), ] *************** *** 32,41 **** ] - _fieldSpec = { - 'realm': pfield.EntityInstance, - 'user': pfield.EntityInstance, - 'name': pfield.String, - } - class Realm(Entity): --- 27,30 ---- |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:39:10
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/entity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/entity Modified Files: entity.py extent.py root.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: root.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/entity/root.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** root.py 9 Aug 2004 19:49:15 -0000 1.15 --- root.py 9 Aug 2004 22:38:30 -0000 1.16 *************** *** 69,82 **** if not issubclass(EntityClass, entity.Entity): raise TypeError, 'EntityClass must be a subclass of entity.Entity' - # If extent class has a _spec attribute, determine the class's - # _attrSpec and _fieldSpec from it. - if hasattr(EntityClass, '_spec'): - spec = EntityClass._spec - EntityClass._attrSpec = [attrName for attrName, fieldClass in spec] - EntityClass._fieldSpec = dict( - [(attrName, fieldClass) - for attrName, fieldClass in spec - if fieldClass is not None] - ) # Restore the extent after unpickling, or create a new extent. extent = self._branch(classname, Extent, EntityClass) --- 69,72 ---- Index: entity.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/entity/entity.py,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** entity.py 9 Aug 2004 20:11:55 -0000 1.58 --- entity.py 9 Aug 2004 22:38:30 -0000 1.59 *************** *** 20,34 **** instancesProvide=[interface.IEntity]) ! # A list of (name, FieldClass) tuples used to populate _attrSpec ! # and _fieldSpec. This attribute should be specified in all ! # Entity subclasses as part of the root schema. If an attribute ! # is not based on a field, then the tuple should be (name, None). ! # _spec = [] ! ! # A list of names of attributes this Entity is expected to have. ! _attrSpec = [] ! ! # A dictionary of 'FieldName': FieldClass pairs. ! _fieldSpec = {} # A list of tuples of attribute names representing a specification --- 20,29 ---- instancesProvide=[interface.IEntity]) ! # A list of (name, FieldClass) tuples used to specify attribute ! # and field specifications. This attribute should be specified in ! # all Entity subclasses as part of the root schema. If an ! # attribute is not based on a field, then the tuple should be ! # (name, None). ! _spec = [] # A list of tuples of attribute names representing a specification *************** *** 69,77 **** # Clean up after ourselves. del self.__dict__['_initattrs'] - ## # We expect to receive a value for every field in the _fieldSpec. - ## if len(attrs) < len(self._fieldSpec): - ## raise AttributeError, 'wrong number of attrs %r' % (attrs, ) fields = {} ! for name, FieldClass in self._fieldSpec.iteritems(): field = FieldClass(instance=self, attribute=name) value = attrs.pop(name, field.default) --- 64,71 ---- # Clean up after ourselves. del self.__dict__['_initattrs'] fields = {} ! for name, FieldClass in self._spec: ! if FieldClass is None: ! continue field = FieldClass(instance=self, attribute=name) value = attrs.pop(name, field.default) *************** *** 145,149 **** """Return dictionary of current attribute name: value pairs.""" d = {} ! for name in self._attrSpec: d[name] = getattr(self, name) return d --- 139,143 ---- """Return dictionary of current attribute name: value pairs.""" d = {} ! for name, fieldClass in self._spec: d[name] = getattr(self, name) return d *************** *** 200,207 **** def _validate(self, attrs): """Validate the attrs individually, and as a whole.""" ! attrSpec = self._attrSpec for name in attrs: # Make sure the name is in the list of declared attrs. ! if name not in attrSpec: raise error.InvalidAttribute, '%r is not an attribute' % name # Since only a few attrs may be changing, get the existing --- 194,201 ---- def _validate(self, attrs): """Validate the attrs individually, and as a whole.""" ! attrNames = [name for name, fieldClass in self._spec] for name in attrs: # Make sure the name is in the list of declared attrs. ! if name not in attrNames: raise error.InvalidAttribute, '%r is not an attribute' % name # Since only a few attrs may be changing, get the existing *************** *** 229,237 **** def _validateFields(self, attrs): """Validate the field attrs individually.""" ! fieldSpec = self._fieldSpec fields = self._fields for name, value in attrs.iteritems(): # If the attr is a field, validate it individually. ! if name in fieldSpec: # Make sure they don't try to assign to an attribute # we are already using, such as self._oid. --- 223,232 ---- def _validateFields(self, attrs): """Validate the field attrs individually.""" ! fieldNames = [name for name, fieldClass in self._spec ! if fieldClass is not None] fields = self._fields for name, value in attrs.iteritems(): # If the attr is a field, validate it individually. ! if name in fieldNames: # Make sure they don't try to assign to an attribute # we are already using, such as self._oid. Index: extent.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/entity/extent.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** extent.py 14 Jul 2004 15:45:52 -0000 1.36 --- extent.py 9 Aug 2004 22:38:30 -0000 1.37 *************** *** 293,296 **** --- 293,297 ---- """Setup alternate keys.""" self._altkeys = {} + specNames = [name for name, fieldClass in self._spec] for names in self._altkeySpec: spec = self._makekeyspec(names) *************** *** 298,306 **** raise error.DuplicateAltKeySpec, 'duplicate spec %r' % (spec,) for name in spec: ! if name not in self._attrSpec: msg = ('alternate key spec %r includes %r' + ! ' which is not in attrSpec %r') raise error.InvalidAltKeySpec, msg % (spec, name, ! self._attrSpec) self._altkeys[spec] = {} --- 299,307 ---- raise error.DuplicateAltKeySpec, 'duplicate spec %r' % (spec,) for name in spec: ! if name not in specNames: msg = ('alternate key spec %r includes %r' + ! ' which is not in spec %r') raise error.InvalidAltKeySpec, msg % (spec, name, ! self._spec) self._altkeys[spec] = {} *************** *** 308,313 **** """Synchronize with the current EntityClass definition.""" self._altkeySpec = EntityClass._altkeySpec[:] ! self._attrSpec = EntityClass._attrSpec[:] ! self._fieldSpec = EntityClass._fieldSpec.copy() self._forClassName = EntityClass.__name__ self._refreshkeys() --- 309,313 ---- """Synchronize with the current EntityClass definition.""" self._altkeySpec = EntityClass._altkeySpec[:] ! self._spec = EntityClass._spec[:] self._forClassName = EntityClass.__name__ self._refreshkeys() |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:39:10
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/domain In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/domain Modified Files: collection.py fieldspace.py interface.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: interface.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/domain/interface.py,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** interface.py 4 Aug 2004 04:55:58 -0000 1.22 --- interface.py 9 Aug 2004 22:38:30 -0000 1.23 *************** *** 80,86 **** # Labels for fields via their 'label' attribute. ! def labelFromField(f): ! return f.label ! declareLabel(field.Field, labelFromField) # By default, Entity classes have labels and plural labels that --- 80,100 ---- # Labels for fields via their 'label' attribute. ! def labelFromFieldClass(f): ! if f.label is not None: ! return f.label ! else: ! name = f.__name__ ! label = name[0].upper() ! for c in name[1:]: ! if c.isupper(): ! label += ' ' ! label += c ! return label ! ! def labelFromFieldInstance(f): ! return labelFromFieldClass(f.__class__) ! ! declareLabel(field.Field, labelFromFieldClass, forWhat='forObjects') ! declareLabel(field.Field, labelFromFieldInstance, forWhat='forTypes') # By default, Entity classes have labels and plural labels that *************** *** 210,216 **** """A sequence of objects implementing ISupplier.""" ! _attrSpec = property(doc='Attribute specificiation.') ! ! _fieldSpec = property(doc='Field specification.') def __contains__(item): --- 224,228 ---- """A sequence of objects implementing ISupplier.""" ! _spec = property(doc='Attribute/field specification.') def __contains__(item): *************** *** 258,262 **** changed = property(doc='Dictionary of changed attributes.') ! fieldlist = property(doc='List of (name, field) in _attrSpec order.') fields = property(doc='Dictionary of fields.') --- 270,274 ---- changed = property(doc='Dictionary of changed attributes.') ! fieldlist = property(doc='List of (name, field) in _spec order.') fields = property(doc='Dictionary of fields.') *************** *** 270,276 **** class for details.""" ! _attrSpec = property(doc='Attribute specification list.') ! ! _fieldSpec = property(doc='Field specification dictionary.') sys = property(doc='An implementation of IFieldspaceSysNamespace.') --- 282,286 ---- class for details.""" ! _spec = property(doc='Attribute/field specification list.') sys = property(doc='An implementation of IFieldspaceSysNamespace.') Index: fieldspace.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/domain/fieldspace.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** fieldspace.py 27 Jul 2004 03:40:51 -0000 1.14 --- fieldspace.py 9 Aug 2004 22:38:29 -0000 1.15 *************** *** 18,23 **** if classname not in _entityFieldspaceClasses: class Fieldspace(BaseClass): ! _attrSpec = EntityClass._attrSpec[:] ! _fieldSpec = EntityClass._fieldSpec.copy() Fieldspace.__name__ = classname _entityFieldspaceClasses[classname] = Fieldspace --- 18,22 ---- if classname not in _entityFieldspaceClasses: class Fieldspace(BaseClass): ! _spec = EntityClass._spec[:] Fieldspace.__name__ = classname _entityFieldspaceClasses[classname] = Fieldspace *************** *** 42,54 **** protocol.advise(instancesProvide=[interface.IFieldspace]) ! _attrSpec = [] ! ! _fieldSpec = {} def __init__(self, attrs={}): """Create a Fieldspace instance.""" self.__dict__['_fields'] = {} # 'field name': field instance fields = {} ! for name, FieldClass in self._fieldSpec.iteritems(): field = FieldClass(instance=self, attribute=name) if name in attrs: --- 41,54 ---- protocol.advise(instancesProvide=[interface.IFieldspace]) ! _spec = [] def __init__(self, attrs={}): """Create a Fieldspace instance.""" + # Set up fields. self.__dict__['_fields'] = {} # 'field name': field instance fields = {} ! for name, FieldClass in self._spec: ! if FieldClass is None: ! continue field = FieldClass(instance=self, attribute=name) if name in attrs: *************** *** 90,94 **** """Return dictionary of current attribute name: value pairs.""" d = {} ! for name in self._attrSpec: try: d[name] = getattr(self, name) --- 90,95 ---- """Return dictionary of current attribute name: value pairs.""" d = {} ! for item in self._spec: ! name = item[0] try: d[name] = getattr(self, name) *************** *** 108,115 **** def _fieldlist(self): ! """Return list of (name, field) in _attrSpec order.""" ! attrSpec = self._attrSpec fields = self._fields ! return [(name, fields[name]) for name in attrSpec if name in fields] _fieldlist = property(fget=_fieldlist, doc=_fieldlist.__doc__) --- 109,118 ---- def _fieldlist(self): ! """Return list of (name, field) in _spec order.""" fields = self._fields ! return [(attrName, fields[attrName]) ! for attrName, fieldClass ! in self._spec ! if fieldClass is not None] _fieldlist = property(fget=_fieldlist, doc=_fieldlist.__doc__) Index: collection.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/domain/collection.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** collection.py 4 Aug 2004 04:55:58 -0000 1.18 --- collection.py 9 Aug 2004 22:38:29 -0000 1.19 *************** *** 37,43 **** name = self._name = extent._forClassName self._entityClass = domain.db.root._classes[name] ! if not hasattr(self, '_attrSpec'): ! self._attrSpec = extent._attrSpec ! self._fieldSpec = extent._fieldSpec def __contains__(self, item): --- 37,42 ---- name = self._name = extent._forClassName self._entityClass = domain.db.root._classes[name] ! if not hasattr(self, '_spec'): ! self._spec = extent._spec def __contains__(self, item): |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:39:10
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/field In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/field Modified Files: field.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: field.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/field/field.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** field.py 7 Aug 2004 07:10:58 -0000 1.19 --- field.py 9 Aug 2004 22:38:30 -0000 1.20 *************** *** 64,68 **** default = UNASSIGNED hidden = False ! label = '' maxSize = None minSize = None --- 64,68 ---- default = UNASSIGNED hidden = False ! label = None maxSize = None minSize = None |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:38:59
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/ui/qt Modified Files: collection.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: collection.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/ui/qt/collection.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** collection.py 7 Aug 2004 07:10:59 -0000 1.28 --- collection.py 9 Aug 2004 22:38:50 -0000 1.29 *************** *** 198,201 **** --- 198,225 ---- # -- Properties -- + def currentSupplier(self): + try: + return self.currentItem().supplier() + except: + return None + + def setCurrentSupplier(self, supplier): + try: + self.setCurrentItem(self._supplierItems[supplierId(supplier)]) + except: + pass + + def currentSupplierId(self): + try: + return supplierId(self.currentItem().supplier()) + except: + return None + + def setCurrentSupplierId(self, supplierId): + try: + self.setcurrentItem(self._supplierItems[supplierId]) + except: + pass + def draggable(self): return self._draggable *************** *** 214,217 **** --- 238,270 ---- self.viewport().setAcceptDrops(b) + def isSupplierSelected(self, supplier): + """Return True if the item representing the supplier is selected.""" + try: + return self.isSelected(self._supplierItems[supplierId(supplier)]) + except: + return False + + def setSupplierSelected(self, supplier, selected=True): + """Set the selected state of the item representing the supplier.""" + try: + self.setSelected(self._supplierItems[supplierId(supplier)], + selected) + except: + pass + + def isSupplierIdSelected(self, supplierId): + """Return True if the item representing the supplier is selected.""" + try: + return self.isSelected(self._supplierItems[supplierId]) + except: + return False + + def setSupplierIdSelected(self, supplierId, selected=True): + """Set the selected state of the item representing the supplier.""" + try: + self.setSelected(self._supplierItems[supplierId], selected) + except: + pass + def showContextMenu(self): return self._showContextMenu *************** *** 239,250 **** def _setupColumns(self): colnames = self._colnames = [] collection = self._childCollection ! attrSpec = collection._attrSpec ! fieldSpec = collection._fieldSpec ! for name in attrSpec: ! label = name ! if name in fieldSpec: ! label = getattr(fieldSpec[name], 'label', label) colnames.append((name, label)) for name, label in colnames: --- 292,301 ---- def _setupColumns(self): + domain = self._domain colnames = self._colnames = [] collection = self._childCollection ! spec = collection._spec ! for name, fieldClass in spec: ! label = domain.ILabel(fieldClass) colnames.append((name, label)) for name, label in colnames: *************** *** 259,275 **** # If there are selected items, hold on to their ids so we can # re-select them. ! prevItems = [] iterator = qt.QListViewItemIterator(self) current = iterator.current() while current is not None: ! if self.isSelected(current): ! try: ! prevItems.append(supplierId(current.supplier())) ! except KeyError: ! # Selected item no longer exists ! pass iterator += 1 current = iterator.current() # Destory current list items. self.clear() # Create new list items for each supplier returned by the --- 310,332 ---- # If there are selected items, hold on to their ids so we can # re-select them. ! prevSelected = [] ! prevOpen = {} iterator = qt.QListViewItemIterator(self) current = iterator.current() while current is not None: ! try: ! sid = supplierId(current.supplier()) ! except KeyError: ! # Selected item no longer exists ! pass ! else: ! if self.isSelected(current): ! prevSelected.append(sid) ! prevOpen[sid] = current.isOpen() iterator += 1 current = iterator.current() + prevCurrent = self.currentSupplierId() # Destory current list items. + supplierItems = self._supplierItems = {} self.clear() # Create new list items for each supplier returned by the *************** *** 283,289 **** parentSupplier, self) sid = supplierId(parentSupplier) ! if sid in prevItems: self.setSelected(parentItem, True) ! parentItem.setOpen(True) # Create child list items. findArgs = {parentAttribute: domain.IEntity(parentSupplier.data)} --- 340,349 ---- parentSupplier, self) sid = supplierId(parentSupplier) ! supplierItems[sid] = parentItem ! if sid in prevSelected: self.setSelected(parentItem, True) ! # If the item already existed, use its previous open ! # setting; otherwise start with it open. ! parentItem.setOpen(prevOpen.get(sid, True)) # Create child list items. findArgs = {parentAttribute: domain.IEntity(parentSupplier.data)} *************** *** 293,299 **** childSupplier, parentItem) sid = supplierId(childSupplier) ! if sid in prevItems: self.setSelected(childItem, True) self._setDragEnabledIfDraggable() def _setDragEnabledIfDraggable(self): --- 353,361 ---- childSupplier, parentItem) sid = supplierId(childSupplier) ! supplierItems[sid] = childItem ! if sid in prevSelected: self.setSelected(childItem, True) self._setDragEnabledIfDraggable() + self.setCurrentSupplierId(prevCurrent) def _setDragEnabledIfDraggable(self): *************** *** 579,582 **** --- 641,668 ---- self.reset() + def currentSupplier(self): + try: + return self.currentItem().supplier() + except: + return None + + def setCurrentSupplier(self, supplier): + try: + self.setCurrentItem(self._supplierItems[supplierId(supplier)]) + except: + pass + + def currentSupplierId(self): + try: + return supplierId(self.currentItem().supplier()) + except: + return None + + def setCurrentSupplierId(self, supplierId): + try: + self.setcurrentItem(self._supplierItems[supplierId]) + except: + pass + def draggable(self): return self._draggable *************** *** 595,598 **** --- 681,713 ---- self.viewport().setAcceptDrops(b) + def isSupplierSelected(self, supplier): + """Return True if the item representing the supplier is selected.""" + try: + return self.isSelected(self._supplierItems[supplierId(supplier)]) + except: + return False + + def setSupplierSelected(self, supplier, selected=True): + """Set the selected state of the item representing the supplier.""" + try: + self.setSelected(self._supplierItems[supplierId(supplier)], + selected) + except: + pass + + def isSupplierIdSelected(self, supplierId): + """Return True if the item representing the supplier is selected.""" + try: + return self.isSelected(self._supplierItems[supplierId]) + except: + return False + + def setSupplierIdSelected(self, supplierId, selected=True): + """Set the selected state of the item representing the supplier.""" + try: + self.setSelected(self._supplierItems[supplierId], selected) + except: + pass + # -- Setup -- *************** *** 610,621 **** def _setupColumns(self): colnames = self._colnames = [('sys.oid', 'OID')] collection = self._collection ! attrSpec = collection._attrSpec ! fieldSpec = collection._fieldSpec ! for name in attrSpec: ! label = name ! if name in fieldSpec: ! label = getattr(fieldSpec[name], 'label', label) colnames.append((name, label)) for name, label in colnames: --- 725,734 ---- def _setupColumns(self): + domain = self._domain colnames = self._colnames = [('sys.oid', 'OID')] collection = self._collection ! spec = collection._spec ! for name, fieldClass in spec: ! label = domain.ILabel(fieldClass) colnames.append((name, label)) for name, label in colnames: *************** *** 629,633 **** # If there are selected items, hold on to their ids so we can # re-select them. ! prevItems = [] iterator = qt.QListViewItemIterator(self) current = iterator.current() --- 742,746 ---- # If there are selected items, hold on to their ids so we can # re-select them. ! prevSelected = [] iterator = qt.QListViewItemIterator(self) current = iterator.current() *************** *** 635,639 **** if self.isSelected(current): try: ! prevItems.append(supplierId(current.supplier())) except KeyError: # Selected item no longer exists --- 748,752 ---- if self.isSelected(current): try: ! prevSelected.append(supplierId(current.supplier())) except KeyError: # Selected item no longer exists *************** *** 641,654 **** iterator += 1 current = iterator.current() # Destory current list items. self.clear() # Create new list items for each supplier returned by the # filter. for supplier in self._filter(): item = ListViewItem(self._domain, self._collection, supplier, self) sid = supplierId(supplier) ! if sid in prevItems: self.setSelected(item, True) self._setDragEnabledIfDraggable() def _setDragEnabledIfDraggable(self): --- 754,771 ---- iterator += 1 current = iterator.current() + prevCurrent = self.currentSupplierId() # Destory current list items. self.clear() # Create new list items for each supplier returned by the # filter. + supplierItems = self._supplierItems = {} for supplier in self._filter(): item = ListViewItem(self._domain, self._collection, supplier, self) sid = supplierId(supplier) ! supplierItems[sid] = item ! if sid in prevSelected: self.setSelected(item, True) self._setDragEnabledIfDraggable() + self.setCurrentSupplierId(prevCurrent) def _setDragEnabledIfDraggable(self): *************** *** 818,821 **** --- 935,948 ---- # -- Convenience access to listView properties -- + currentSupplierd= property(fget=lambda self: + self.listView.currentSupplier) + setCurrentSupplier = property(fget=lambda self: + self.listView.setCurrentSupplier) + + currentSupplierId = property(fget=lambda self: + self.listView.currentSupplierId) + setCurrentSupplierId = property(fget=lambda self: + self.listView.setCurrentSupplierId) + draggable = property(fget=lambda self: self.listView.draggable) setDraggable = property(fget=lambda self: self.listView.setDraggable) *************** *** 824,827 **** --- 951,964 ---- setDroppable = property(fget=lambda self: self.listView.setDroppable) + isSupplierSelected = property(fget=lambda self: + self.listView.isSupplierSelected) + setSupplierSelected = property(fget=lambda self: + self.listView.setSupplierSelected) + + isSupplierIdSelected = property(fget=lambda self: + self.listView.isSupplierIdSelected) + setSupplierIdSelected = property(fget=lambda self: + self.listView.setSupplierIdSelected) + # -- Setup -- |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:38:59
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/production/5 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/test/schevo/production/5 Modified Files: system.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: system.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/production/5/system.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** system.py 7 Oct 2003 16:36:57 -0000 1.1 --- system.py 9 Aug 2004 22:38:50 -0000 1.2 *************** *** 14,21 **** """Avatar class.""" ! _attrSpec = [ ! 'realm', ! 'user', ! 'name', ] --- 14,21 ---- """Avatar class.""" ! _spec = [ ! ('realm', None), ! ('user', None), ! ('name', None), ] *************** *** 28,33 **** """Realm class.""" ! _attrSpec = [ ! 'name', ] --- 28,33 ---- """Realm class.""" ! _spec = [ ! ('name', None), ] *************** *** 40,46 **** """User class.""" ! _attrSpec = [ ! 'name', ! 'hashedPassword', ] --- 40,46 ---- """User class.""" ! _spec = [ ! ('name', None), ! ('hashedPassword', None), ] |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:38:59
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/production/4 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/test/schevo/production/4 Modified Files: system.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: system.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/production/4/system.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** system.py 7 Oct 2003 16:36:58 -0000 1.1 --- system.py 9 Aug 2004 22:38:50 -0000 1.2 *************** *** 14,21 **** """Avatar class.""" ! _attrSpec = [ ! 'realm', ! 'user', ! 'name', ] --- 14,21 ---- """Avatar class.""" ! _spec = [ ! ('realm', None), ! ('user', None), ! ('name', None), ] *************** *** 28,33 **** """Realm class.""" ! _attrSpec = [ ! 'name', ] --- 28,33 ---- """Realm class.""" ! _spec = [ ! ('name', None), ] *************** *** 40,46 **** """User class.""" ! _attrSpec = [ ! 'name', ! 'hashedPassword', ] --- 40,46 ---- """User class.""" ! _spec = [ ! ('name', None), ! ('hashedPassword', None), ] |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:38:59
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/production/3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/test/schevo/production/3 Modified Files: system.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: system.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/production/3/system.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** system.py 7 Oct 2003 16:36:58 -0000 1.1 --- system.py 9 Aug 2004 22:38:49 -0000 1.2 *************** *** 14,21 **** """Avatar class.""" ! _attrSpec = [ ! 'realm', ! 'user', ! 'name', ] --- 14,21 ---- """Avatar class.""" ! _spec = [ ! ('realm', None), ! ('user', None), ! ('name', None), ] *************** *** 28,33 **** """Realm class.""" ! _attrSpec = [ ! 'name', ] --- 28,33 ---- """Realm class.""" ! _spec = [ ! ('name', None), ] *************** *** 40,46 **** """User class.""" ! _attrSpec = [ ! 'name', ! 'hashedPassword', ] --- 40,46 ---- """User class.""" ! _spec = [ ! ('name', None), ! ('hashedPassword', None), ] |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:38:58
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/production/2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/test/schevo/production/2 Modified Files: system.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: system.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/production/2/system.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** system.py 7 Oct 2003 16:36:58 -0000 1.1 --- system.py 9 Aug 2004 22:38:49 -0000 1.2 *************** *** 14,21 **** """Avatar class.""" ! _attrSpec = [ ! 'realm', ! 'user', ! 'name', ] --- 14,21 ---- """Avatar class.""" ! _spec = [ ! ('realm', None), ! ('user', None), ! ('name', None), ] *************** *** 28,33 **** """Realm class.""" ! _attrSpec = [ ! 'name', ] --- 28,33 ---- """Realm class.""" ! _spec = [ ! ('name', None), ] *************** *** 40,46 **** """User class.""" ! _attrSpec = [ ! 'name', ! 'hashedPassword', ] --- 40,46 ---- """User class.""" ! _spec = [ ! ('name', None), ! ('hashedPassword', None), ] |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:38:58
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/migration/5 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/test/schevo/migration/5 Modified Files: system.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: system.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/migration/5/system.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** system.py 7 Oct 2003 16:36:58 -0000 1.1 --- system.py 9 Aug 2004 22:38:48 -0000 1.2 *************** *** 14,21 **** """Avatar class.""" ! _attrSpec = [ ! 'realm', ! 'user', ! 'name', ] --- 14,21 ---- """Avatar class.""" ! _spec = [ ! ('realm', None), ! ('user', None), ! ('name', None), ] *************** *** 28,33 **** """Realm class.""" ! _attrSpec = [ ! 'name', ] --- 28,33 ---- """Realm class.""" ! _spec = [ ! ('name', None), ] *************** *** 40,46 **** """User class.""" ! _attrSpec = [ ! 'name', ! 'hashedPassword', ] --- 40,46 ---- """User class.""" ! _spec = [ ! ('name', None), ! ('hashedPassword', None), ] |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:38:58
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/production/1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/test/schevo/production/1 Modified Files: system.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: system.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/production/1/system.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** system.py 7 Oct 2003 16:36:58 -0000 1.1 --- system.py 9 Aug 2004 22:38:49 -0000 1.2 *************** *** 14,21 **** """Avatar class.""" ! _attrSpec = [ ! 'realm', ! 'user', ! 'name', ] --- 14,21 ---- """Avatar class.""" ! _spec = [ ! ('realm', None), ! ('user', None), ! ('name', None), ] *************** *** 28,33 **** """Realm class.""" ! _attrSpec = [ ! 'name', ] --- 28,33 ---- """Realm class.""" ! _spec = [ ! ('name', None), ] *************** *** 40,46 **** """User class.""" ! _attrSpec = [ ! 'name', ! 'hashedPassword', ] --- 40,46 ---- """User class.""" ! _spec = [ ! ('name', None), ! ('hashedPassword', None), ] |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:38:58
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/migration/3 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/test/schevo/migration/3 Modified Files: system.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: system.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/migration/3/system.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** system.py 7 Oct 2003 16:36:58 -0000 1.1 --- system.py 9 Aug 2004 22:38:48 -0000 1.2 *************** *** 14,21 **** """Avatar class.""" ! _attrSpec = [ ! 'realm', ! 'user', ! 'name', ] --- 14,21 ---- """Avatar class.""" ! _spec = [ ! ('realm', None), ! ('user', None), ! ('name', None), ] *************** *** 28,33 **** """Realm class.""" ! _attrSpec = [ ! 'name', ] --- 28,33 ---- """Realm class.""" ! _spec = [ ! ('name', None), ] *************** *** 40,46 **** """User class.""" ! _attrSpec = [ ! 'name', ! 'hashedPassword', ] --- 40,46 ---- """User class.""" ! _spec = [ ! ('name', None), ! ('hashedPassword', None), ] |
From: Matthew R. S. <gld...@us...> - 2004-08-09 22:38:57
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/migration/4 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9521/pypersyst/test/schevo/migration/4 Modified Files: system.py Log Message: * _attrSpec and _fieldSpec are now fully retired in favor of _spec. PyPerSyst no longer uses _attrSpec or _fieldSpec internally. * Field classes and instances have default labels now that are based on the class name, if the field class's label attribute not overridden from None. Index: system.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/schevo/migration/4/system.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** system.py 7 Oct 2003 16:36:58 -0000 1.1 --- system.py 9 Aug 2004 22:38:48 -0000 1.2 *************** *** 14,21 **** """Avatar class.""" ! _attrSpec = [ ! 'realm', ! 'user', ! 'name', ] --- 14,21 ---- """Avatar class.""" ! _spec = [ ! ('realm', None), ! ('user', None), ! ('name', None), ] *************** *** 28,33 **** """Realm class.""" ! _attrSpec = [ ! 'name', ] --- 28,33 ---- """Realm class.""" ! _spec = [ ! ('name', None), ] *************** *** 40,46 **** """User class.""" ! _attrSpec = [ ! 'name', ! 'hashedPassword', ] --- 40,46 ---- """User class.""" ! _spec = [ ! ('name', None), ! ('hashedPassword', None), ] |
From: Patrick K. O'B. <po...@us...> - 2004-08-09 20:12:04
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/entity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14351/pypersyst/entity Modified Files: entity.py Log Message: Added a placeholder attribute and comments for the _spec attribute. Index: entity.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/entity/entity.py,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** entity.py 9 Aug 2004 16:36:03 -0000 1.57 --- entity.py 9 Aug 2004 20:11:55 -0000 1.58 *************** *** 20,23 **** --- 20,29 ---- instancesProvide=[interface.IEntity]) + # A list of (name, FieldClass) tuples used to populate _attrSpec + # and _fieldSpec. This attribute should be specified in all + # Entity subclasses as part of the root schema. If an attribute + # is not based on a field, then the tuple should be (name, None). + # _spec = [] + # A list of names of attributes this Entity is expected to have. _attrSpec = [] |
From: Matthew R. S. <gld...@us...> - 2004-08-09 19:49:27
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/entity In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9904/entity Modified Files: root.py Log Message: Allow _spec instead of _attrSpec and _fieldSpec Index: root.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/entity/root.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** root.py 14 Jul 2004 15:45:52 -0000 1.14 --- root.py 9 Aug 2004 19:49:15 -0000 1.15 *************** *** 69,72 **** --- 69,82 ---- if not issubclass(EntityClass, entity.Entity): raise TypeError, 'EntityClass must be a subclass of entity.Entity' + # If extent class has a _spec attribute, determine the class's + # _attrSpec and _fieldSpec from it. + if hasattr(EntityClass, '_spec'): + spec = EntityClass._spec + EntityClass._attrSpec = [attrName for attrName, fieldClass in spec] + EntityClass._fieldSpec = dict( + [(attrName, fieldClass) + for attrName, fieldClass in spec + if fieldClass is not None] + ) # Restore the extent after unpickling, or create a new extent. extent = self._branch(classname, Extent, EntityClass) |
From: Matthew R. S. <gld...@us...> - 2004-08-09 19:49:27
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test/schemaF In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9904/test/schemaF Modified Files: root.py Log Message: Allow _spec instead of _attrSpec and _fieldSpec Index: root.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/schemaF/root.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** root.py 9 Aug 2004 16:00:20 -0000 1.2 --- root.py 9 Aug 2004 19:49:15 -0000 1.3 *************** *** 14,17 **** --- 14,22 ---- + # Avatar class shows old-style of _attrSpec and _fieldSpec, all other + # classes show new-style _spec which determines _attrSpec and + # _fieldSpec. + + class Avatar(Entity): """Avatar class.""" *************** *** 37,42 **** """Realm class.""" ! _attrSpec = [ ! 'name', ] --- 42,47 ---- """Realm class.""" ! _spec = [ ! ('name', pfield.String), ] *************** *** 45,59 **** ] - _fieldSpec = { - 'name': pfield.String, - } - class Sprocket(Entity): """Sprocket class.""" ! _attrSpec = [ ! 'diameter', ! 'disposition', ] --- 50,60 ---- ] class Sprocket(Entity): """Sprocket class.""" ! _spec = [ ! ('diameter', pfield.Integer), ! ('disposition', tfield.Disposition), ] *************** *** 61,76 **** ] - _fieldSpec = { - 'diameter': pfield.Integer, - 'disposition': tfield.Disposition, - } - class Thing(Entity): """Thing class.""" ! _attrSpec = [ ! 'name', ! 'quantity', ] --- 62,72 ---- ] class Thing(Entity): """Thing class.""" ! _spec = [ ! ('name', pfield.String), ! ('quantity', pfield.Integer), ] *************** *** 79,93 **** ] - _fieldSpec = { - 'name': pfield.String, - 'quantity': pfield.Integer, - } - class ThingyThing(Entity): """Thingy Thing class.""" ! _attrSpec = [ ! 'name', ] --- 75,84 ---- ] class ThingyThing(Entity): """Thingy Thing class.""" ! _spec = [ ! ('name', pfield.String), ] *************** *** 96,110 **** ] - _fieldSpec = { - 'name': pfield.String, - } - class User(Entity): """User class.""" ! _attrSpec = [ ! 'name', ! 'hashedPassword', ] --- 87,97 ---- ] class User(Entity): """User class.""" ! _spec = [ ! ('name', pfield.String), ! ('hashedPassword', pfield.String), ] *************** *** 113,121 **** ] - _fieldSpec = { - 'name': pfield.String, - 'hashedPassword': pfield.String, - } - class Root(root.Root): --- 100,103 ---- |
From: Matthew R. S. <gld...@us...> - 2004-08-09 16:38:46
|
Update of /cvsroot/pypersyst/pypersyst/pypersyst/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2999/test Modified Files: test_domain.py Log Message: Extend test case a little. Index: test_domain.py =================================================================== RCS file: /cvsroot/pypersyst/pypersyst/pypersyst/test/test_domain.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** test_domain.py 9 Aug 2004 16:00:20 -0000 1.29 --- test_domain.py 9 Aug 2004 16:38:31 -0000 1.30 *************** *** 140,147 **** --- 140,151 ---- domain = self.domain collection = domain['Sprocket'] + # Leave the disposition off. create = domain.ICreate(collection) create.data.diameter = 5 display = create.execute() self.assertEqual(display.data.disposition, 'neutral') + # Leave both the diameter and disposition off. + create = domain.ICreate(collection) + self.assertRaises(AttributeError, create.execute) def test_createWithReferences(self): |