[Zope3-dev] Re: adapter registration question
Rocky Burt
rocky at serverzen.com
Fri Nov 10 08:35:50 EST 2006
On Fri, 2006-10-11 at 08:00 +0000, Chris Withers wrote:
> This is a toy example, but I need to do something similar and can't seem
> to get the registration right...
>
> How can I register the str builtin as an adapter from python int objects
> to python str objects?
I've personally found when I run into a situation where it seems like I
need to adapt on the builtin str class, I should probably be using named
adapters or named utilities instead.
I use this technique for example to lookup mime type stuff in one of my
apps.
<adapter
for="*"
name="text/html"
factory=".somemodule.SomeClass"
provides=".interfaces.ISomeMimeTypeHandlerThingie"
/>
from zope import component
component.getAdapter(randomobj, ISomeMimeTypeHandlerThingie,
name='text/html')
- Rocky
--
Rocky Burt
ServerZen Software -- http://www.serverzen.com
News About The Server (blog) -- http://www.serverzen.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.zope.org/pipermail/zope3-dev/attachments/20061110/875188e7/attachment.bin
More information about the Zope3-dev
mailing list