[Zope] Catalog aware

Tino Wildenhain tino at wildenhain.de
Wed Jul 19 11:07:14 EDT 2006


Garito wrote:
> Tino Wildenhain escribió:
>> Garito wrote:
>>> Andreas Jung escribió:
>>>>
>>>>
>>>> --On 19. Juli 2006 09:34:58 +0200 Garito <garito at sistes.net> wrote:
>>>>
>>>>> Andreas Jung escribió:
>>>>>>
>>>>>>
>>>>>> --On 18. Juli 2006 15:14:54 +0200 Garito <garito at sistes.net> wrote:
>>>>>>
>>>>>>> Hi all!
>>>>>>>
>>>>>>> Is possible to create an object (for example a Page Template) and
>>>>>>> make it
>>>>>>> catalog aware?
>>>>>>
>>>>>> Look at the CatalogAware mixin class.
>>>>> But with this class I could create a new class of PT Catalog aware,
>>>>> isn't
>>>>> it?
>>>>> I would like to convert a normal PT is this possible?
>>>>
>>>> It makes little sense to index the contents of PTs. PTs are used to
>>>> present a view on a particular instance of your class but not for
>>>> providing content
>>>> itself.
>>>>
>>>>>>>
>>>>>>> I wonder why the objects aren't catalogable by default (I need
>>>>>>> all my
>>>>>>> object catalogables)
>>>>>>>
>>>>>>
>>>>>> Because Zope is not CMF and Zope is not Plone. Because you need this
>>>>>> feature it does not mean that everyone needs this feature by default.
>>>>>>
>>>>>> -aj
>>>>> Sure but Is the cost so big?
>>>>
>>>> This is not the question. If you need catalog awareness, either
>>>> implement it as stated above or use one of the frameworks....little
>>>> need to discuss the pros and cons...by default Zope default
>>>> content-types  don't depend on the catalog. CMF and Plone depend on
>>>> the catalog for various reasons. If you have the requirement to use
>>>> a catalog you have the mentioned options.
>>>>
>>>> -aj
>>>>
>>> Yes but what about something like
>>>
>>> if self.default_catalog != '': self.reindex_object()
>>>
>>> ?
>>>
>>> I think it's a question of preferences
>>>
>>> Then can I "inject" Catalog awarness to an object?
>>
>> Yes you can. Its possible with so called monkeypatching.
>> However if you can do that, you better just write
>> a product w/ subclasses of the standard zope objects and
>> your CatalogAwareness. Its easy and clean and you dont
>> interfere with further development of zope.
>>
>> Regards
>> Tino
> Sure, but I can't create a new product for every product I'll use only
> to do it catalog aware, isn't it?

Yes you can. Why not? I mean you are using them - so you can use
your products instead as well.


> Can you say more about monkeypatching?

If you cant figure out (google, imagination)
you better dont do it :-)

The code to monkey-patch is roughly the same
as subclassing. So you better just subclass
and use your products.

Hint: you can use loops in python too .-)

Kind regards
Tino


More information about the Zope mailing list