On 28.01.2008, at 13:39, Christian Klinger wrote:
My next tasks is working on a megrok.storm package which makes the usage of storm.zope and nva.stormcontainer more "grokkish". If you have any suggestions please comment.
hi chris thx for the work ... some suggestions ...in container.py you implemented contained, actually zope.app.container.contained.contained does only instantiate the events but does not fire them so i think it is save to just use the orignial implementaion
actually it would be nice to have a special contained class that knows about its parent class, so you dont have to use contained and could just return resultsets. then you could nearly implement the most methods by using values() as a base method.
one drawback is that the container needs to be registered as a utility to make this possible. but this should not be a functional drawback because you dedicated the container to a specific table anyway.
the contained class would implement self.__name__ and self.__parent__ as properties
@property
def __parent__(self):
return component.getUtility(IStormContainer, 'mytablename')
@property
def __name__(self):
return myPKAsString(self.pkattr)
you can then do the following for example:
def values(self):
return store.find(self._class)
with the above you could do someContainer.values()[20:30] (storm does
then offset limit queries)
def __len__(self):
return self.values().count()
def keys(self):
for k in self.values().values('keycol'):
yield makeIdentifier(k)
also it would be nice to use an exists query or some equivalent in
__contains__, below just an example that selects the first pk
def __contains__(self, name):
pk = makePrimaryKey(name)
for pk in self.values().config(limit=1).values('pkcol'):
return True
return False
in __delitem__ you don't have to fetch the object, if you use the form
below, only a delete statement gets executed
def __delitem__(self, name):
pk = makePrimaryKey(name)
self.values().find(pkcol=pk).remove()
additionally you do a lot of utility lookups for the storm utility,
take a look at zope.cachedescriptors.property, there is an
implementation that lets you implement self.store efficiently
regards, bernd -- Lovely Systems, senior developer phone: +43 5572 908060, fax: +43 5572 908060-77 Schmelzhütterstraße 26a, 6850 Dornbirn, Austria skype: bernd.dorn
smime.p7s
Description: S/MIME cryptographic signature
-- storm mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm
