[Zope3-dev] Re: Can an adapter find out what name it was registered for?

Tres Seaver tseaver at palladion.com
Thu Nov 16 21:14:59 EST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Philipp von Weitershausen wrote:
> Chris Withers wrote:
>> Can a named adapter find out the name it was registered with during the 
>> adaptation process?
> 
> Nope.

But you can create the adapter factories in such a way that they know
that name, via a little "curry powder":

  >>> map = {}
  >>> for name in 'foo', 'bar', 'baz':
  ...     def whoami(name=name):
  ...         return name
  ...     map[name] = whoami
  ...
  >>> map['foo']()
  'foo'
  >>> map['bar']()
  'bar'



Tres.
- --
===================================================================
Tres Seaver          +1 202-558-7113          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFXRsj+gerLs4ltQ4RAtHSAKC85EasxcDQpCTDaY7AGT2lHpP7egCeJ12k
qaUxJBox8tQ1Pz5LWw99IHk=
=zgNn
-----END PGP SIGNATURE-----



More information about the Zope3-dev mailing list