"Phillip J. Eby" a écrit :
At 08:39 PM 5/17/00 +0400, Jepthte CLAIN wrote:
I wonder if someone can send me a simple example using the ZPatterns framework. I read all the source, and I still can't figure out what is the relationship between the objects instantiated by the Racks and the Rackmountable objects. Also, why do the rack try to instantiate a ZClass???
When created, Racks create some default Attribute and Sheet providers. These objects are used by Rackmountables to access data which is not stored directly in the rackmountable.
Indeed, attribute and sheets are not stored in the rackmountable. Where are they stored then? in the specialist? in the rack? reading the code does not help to answer that question.
When used, Racks create instances of the ZClass you've specified. If you call newItem(key), you will receive a new instance of that ZClass, which will be stored in the rack under the specified key. Whenever you call getItem(key), the instance will be retrieved. Some Racks, like GenericUserSource, do not store items in themselves, but in external databases. When you call getItem(key) on a GUS, it calls methods to access the external database, then creates an instance of the appropriate LoginUser subclass and returns that.
I don't like ZClasses, because I want to use XEmacs to edit my code. In fact, I have trouble using a python class to store my data. say I have in MyItem.py: class MyItem(RackMountable, Item): "" meta_type = 'My Item' def __init__(self, id): self.id = id self.i = 0 self.s = '' and in __init__.py, MyItem is registered as a z base class i and s are properties my objects are going to store. I would like to use MyItem objects until I am ready to move the data into an SQL database, where i and s will be columns in a table. The AttributeProvider (that my rack have by default) raise an exception in MyItem.__init__ because i and s do not exist (indeed, I want to create them in the instance!) Also, say I want to add the OFS.ProperyManager.PropertyManager mixin class to MyItem to manage my properties through the standard interface. Will it clash with the sheet provider?
Hope that helps; I'm not 100% clear on your question. Anyway, my question was not 100% clear neither :-)
I'm not interested in the ZPatterns framework to allow my customers to customize the data sources or the collaborators. I'm interested in it because I want to develop code that is independant of the data sources. I want to store some data in the ZODB (because they are python list and dict, or because it is easier for me to use Zope objects until I move to a SQL database), and some of them in an SQL database (because they might be used by externals applications), but still want to have a common interface to the data. I'm still figuring out how it works, but once I'm done, I will rule the world :-) Thanks for your good work, and thanks for the advices! regards, jephte clain minf7@educ.univ-reunion.fr