Hello,

directlyProvides is surely persistent. "Make a site" works like this.

zope.interface.directlyProvides(
            self, interfaces.ISite,
            zope.interface.directlyProvidedBy(self))

Friday, March 9, 2007, 3:30:46 PM, you wrote:

GM> Christophe Combelles wrote:
>> Christophe Combelles a écrit :
>>> Hi,
>>>
>>> I'm playing again with the notion of categories of objects.
>>>
>>> I have two main goals:
>>> ---------------------
>>> 1) I must let the user choose the category of an object added to the 
>>> zodb. For this, I must be able to retrieve the list of categories and 
>>> present them in a form field managed by a vocabulary (or in a 
>>> different manner).
>>> 2) I must have different behaviours for categorized objects:
>>> objects of different categories would have different views, different 
>>> addMenuItems (if they are containers), etc.
>>>
>>> the first requirement would tell me to define categories as objects, 
>>> while the second one would tell me to define them as interfaces.
>>>
>>> The possible solutions I see:
>>> ----------------------------
>>>
>>> 1) The simplest solution is to store the categories as text strings 
>>> into the annotations of the object. So categories actually are just 
>>> tags.
>>>
>>> 2) The second solution is to do the same, but replace text strings 
>>> with category objects, that implement ICategory. And categories can 
>>> be stored separately in a category container, or in a registered 
>>> utility that gives the list of available categories. This is a bit 
>>> better, but this way I don't know how to easily let my categorized 
>>> objects behave differently according to their categories.
>>>
>>> 3) The third solution is to define categories as interfaces extending 
>>> ICategory. I can retrieve the list of categories with 
>>> ICategory.dependents
>>> But to present them in a form, I must have a pretty name for each 
>>> interface. Should I store them in a Tagged Value?
>>>
>>> 4) The fourth solution I see, is to define an interface type, 
>>> ICategoryType, extending IInterface just like IContentType. Then my 
>>> categories would be interfaces whose type is ICategoryType. But with 
>>> IContentType, is there a way to retrieve the list of all available 
>>> content types?
>>
>> I've finally mixed 3) and 4) :
>>
>> I have defined ICompany(Interface), IClient(ICompany), 
>> IProvider(ICompany)
>> And I have an ICompanyType(IInterface) interface type
>> I've set the type of IClient and IProvider as ICompanyType in zcml.
>>
>> ICompany has a "types" attribute, for which I've redefined __getattr__ 
>> and __setattr_:
>> __getattr__ retrieve the ICompanyType interfaces from the object
>> __setattr__ calls noLongerProvides then alsoProvides to change the 
>> interfaces.
GM> I think that it's not work: "alsoProvides" and "directlyProvides" change
GM> interfaces only in memory, it's not persistent changes (after restart 
GM> Zope yours object will be only basic interface) .
GM> (sorry my honor english).





GM> _______________________________________________
GM> Zope3-users mailing list
GM> Zope3-users@zope.org
GM> http://mail.zope.org/mailman/listinfo/zope3-users


-- 
Best regards,
 Groszer Adam
--
Quote of the day:
Never does the human soul appear so strong and noble as when it forgoes revenge 
and dares to forgive an injury. 
- Edwin Hubbell Chapin 


_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to