[Zope3-Users] How to register a local adapter?

Christophe Combelles ccomb at free.fr
Sat Jan 5 19:42:31 EST 2008


nixon a écrit :
> Hi, dear all,
> 
> The scenario:
> I have a  folder "MyFolder" created under the root folder of zope3 and 
> make it a site manager.
> I want to have a different "index.html" page under MyFolder so that 
> folders under MyFolder look different from the root folder. (It's a 
> common folder and I dont want to make a specail type)

it seems easier to me to create an IMyFolder interface, implemented by MyFolder 
as a subclass of Folder (nothing more), then to register an index.html for 
IMyFolder.

> I guess a local adapter may help.
> While a local utility could be easily made by clicking "Registration" 
> tab, I cannot find anything available for local adapter registration 
> through the web.

I'm wondering how registering an adapter through the web would look like. I mean 
in a generic way.
Adapters are classes and not persistent objects, so to be able to register an 
adapter TTW, it would require to choose a not-yet-zcml-registered class in a 
list, among those which can adapt the current object.
But this kind of registration would not be specific to the current object, so it 
wouldn't make sense to do it in the registration tab of the current object.

But why not ?

> 
> I know the local adapter registration API:
> e.g. "sm.registerAdapter(FileSize, [IFile])"
> It seems to be invoked in runtime. But I don't know where to place it?
> I think it should be invoked once during startup and should not be 
> invoked everytime I use the adapter.

I've recently added a FAQ entry on how to do things once at startup:
http://wiki.zope.org/zope3/FAQ#how-do-i-automatically-create-some-needed-object-at-application-startup

Christophe

> 
> Thank you!
> Regards
> Nixon
> 
> ------------------------------------------------------------------------
> 雅虎邮箱传递新年祝福,个性贺卡送亲朋! 
> <http://cn.mail.yahoo.com/gc/index.html?entry=5&souce=mail_mailletter_tagline> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users



More information about the Zope3-users mailing list