Hi, i have now checked the source temporary in a subversion. You can look here:
http://stormcontainer.googlecode.com/svn/trunk/src/megrok/storm/ Additionally i have a doctest which is heavily based on yours from strom.zope. > Hey Christian, > >> i played the last days a bit with storm.zope. >> Unfortunatly there is no Container for zope.storm, >> >> I´ve looked at the nice z3c.zalchemy [2], >> espacially the container implementation. >> >> I have taken the container.py from z3c.zalchemy as >> a base for the stormcontainer.py attached to this post. > > Very nice! Thanks for publishing it. > >> As i´m using grok[1]. I subclass the container from >> grok.Container. But i think this should work in a pure Z3 >> Environment too. Maybe subclass from zope.container? >> >> I´m waiting for your comments. > > A few things to perhaps look after: > > - store.delete() is actually store.remove() Yes you are right. I have *replaced* the remove statement. > > - The way that commit() is being done in delitem and > setitem seems dangerous. It means that as a side-effect > of removing an item from the container, all the changes > in the current transaction are persisted. I use now transaction.commit(). But i don´t exactly know if i need this? > > - You shouldn't have to do flush(). Storm does it > automatically when needed. I don´t use flush() anymore. > > - for id in obj.__storm_object_info__.get('primary_vars'): > ident += str(id._value) Now i use this statement. But i convert the result to an string type. You can see an example in the doctests. def _getInstanceKey(self, obj): """ Get an unique id form obj """ obj_info = get_obj_info(obj) id = tuple(obj_info.variables[column].get() for column in obj_info.cls_info.primary_key) return id > > You're using private data here, which is not part of the > exposed API, meaning that it may change without warnings. Also, > this internal value may not be available by the time you access > it directly, unlike the actual property. > > Besides these points, this isn't a very good way to extract the > key, since (1, 23) will yield the same key as (12, 3), for > instance. > > I try to experiment with store.get for this issue. But i have no solution at this moment. > - for obj in store.find(self._class): > if self._getInstanceKey(obj) == str(id): > return obj > > That is a *very* expensive way to get an object out of the > database. It will walk through all the objects, potentially. > It should somehow look for the specific key instead. > Christian -- storm mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm
