[Zope] Re: Error publishing resource
Maciek Pasternacki
maciekp at japhy.fnord.org
Mon Aug 30 07:43:59 EDT 2004
On Pungenday, Bureaucracy 24, 3170 YOLD, Johan Carlsson wrote:
> Or you could create an object on-the-fly that:
>
> class TempPublishable(some base classes: Aquisition.Implicit maybe??):
> def __init__(self, the_string):
> self.the_string=the_string
>
> def index_html(self, REQUEST=None):
> """return the string"""
> return self.the_string
>
> I'm not sure exactly what base classes and security settings that
> needs to be use on the TempPublishable?
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)
Works just fine, including security declarations and acquisition.
--
__ Maciek Pasternacki <maciekp at japhy.fnord.org> [ http://japhy.fnord.org/ ]
`| _ |_\ / { 2.718281828459045235360287471352662497757247093699959574966967
,|{-}|}| }\/ 62772407663035354759457138217852516642742746639193200305992181741
\/ |____/ 359662904357290033429526059563073813232862794349076... ( e ) -><-
More information about the Zope
mailing list