Chris Withers wrote:
Philipp von Weitershausen wrote:
Chris Withers wrote:
Can a named adapter find out the name it was registered with during
the adaptation process?
Nope.
I can see why it's that way, but it seems a shame and maybe even an
oversight :-/
What do you suggest I do when the adapter needs to know the name it was
registered for?
If you really really want the adapter to be aware of its name, you could
walk thru the adapter registrations of the component registry until you
find one that refers to the adapter, e.g. (pseudoish code):
registry = zope.component.getSiteManager()
for registration in registry.registeredAdapters():
if registration.factory is YourAdapterClass:
return registration.name
HTH
--
http://worldcookery.com -- Professional Zope documentation and training
_______________________________________________
Zope3-dev mailing list
[email protected]
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com