Hi, Maciek Pasternacki wrote:
On Pungenday, Bureaucracy 24, 3170 YOLD, Johan Carlsson wrote:
Or you could create an object on-the-fly that: [snip]
Here is a real-life example of class created dynamically from SQL (cut just to relevant fragments).
from Acquisition import Implicit from AccessControl import ClassSecurityInfo from Globals import InitializeClass
class theBasket(Implicit): """The basket"""
id=meta_type = "Basket" title = "The basket"
security = ClassSecurityInfo() security.declareObjectPublic() security.setDefaultAccess("allow")
def __init__(self, id): ...
...
InitializeClass(theBasket)
class BasketGenerator(Something): """Basket Generator product kept in ZODB""" def __getitem__(self, id): """Return theBasket instance""" rv = theBasket(self, id) return rv.__of__(self)
I'm unable to understand what BasketGenerator is doing. Can you please explain what __getitem__ is upto? - Raja