Hi, as some of you noticed i worked during the last week on a container implementation for storm.zope. I need this container because i want a nice ORM solution for grok [1].
I´ve released a first devel package of nva.stormcontainer at pypi [2]. 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. Christian [1] http://grok.zope.org [2] http://pypi.python.org/pypi/nva.stormcontainer/0.2 Here is a part of the doctest which describes the usage of nva.stormcontainer: Lets Create a StormContainer ---------------------------- We create now a container which holds the Person objects. This objects should be automatically go into our DB. >>> from nva.stormcontainer import StormContainer >>> from nva.stormcontainer.interfaces import IStormContainer >>> container = StormContainer() >>> container <nva.stormcontainer.container.StormContainer object at ...> I have to use a seperate *helper* class for Person to make sure that the class could be resolved. >>> container.setClassName('nva.stormcontainer.tests.test_doctests.Person') >>> container.getClassName() 'nva.stormcontainer.tests.test_doctests.Person' Test the name of the store utility >>> container.setStoreUtilityName('test') >>> container.getStoreUtilityName() 'test' Check the contents of the container. As we have nothing saved yet. There should be no objects in our container. >>> len(container) 0 Let´s create some Persons -------------------------- >>> joe = Person() >>> joe.id = 1 >>> joe.name = u"Joe Frazier" >>> joe <Person object at ...> Save joe into the Container It does not matter what id pass as name for the object, because the container saves the object to database. >>> container['id'] = joe >>> transaction.commit() The length of the container should be 1. >>> len(container) 1 We should have a generator for items. >>> container.items() <generator object at ...> We can iterate over the items >>> [item.id for key, item in container.items()] [1] We can iterate over the keys. The second suffix after the - is not nice. Maybe i will find a better solution for this. >>> [key for key in container.keys()] ['Person-aW50OjE7'] We can delete the object. >>> del(container['Person-aW50OjE7']) And the length of the container should be 0 again. >>> len(container) 0 -- storm mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm
