Martin Aspeli wrote:
Hi!
I may have a use case where I need an instance to provide marker
interfaces dynamically. That is, under certain conditions I want the
type to say it provides a particular marker interface, and otherwise it
doesn't. It still needs to support the usual by-class and
directly-provided idioms for providing interfaces, including
directlyProvides()/alsoProvides().
Is such a thing possible? Perhaps one could make __providedBy__ a
dynamic property or something? Or is this a very bad idea? :)
Instead of adding the magic to the class, maybe the framework could make
the necessary *Provides calls when it adds context (aq wrapping) to the
object? On traversal perhaps.
FWIW I do something similar with collective.tin to make `bare`
SQLAlchemy mapped objects usable to me (this includes adding __name__,
__parent__, aq wrapping and setting workflow permissions). I don't think
it is possible to achieve this in a __new__ method as there is no
context available).
Laurence
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users