Re: [Zope] Getting REQUEST in product method by default
class ZMyClass(MyClass, Folder): """ Zope Folder subclass """ def getData(self): REQUEST = self.REQUEST RESPONSE = REQUEST.RESPONSE ... validate REQUEST variables ... return MyClass.getData(self, REQUEST['user'], REQUEST['field'])
This way you can use <dtml-var getData> without passing any arguments.
This works great! Thanks! But I see that there is something else wrong with my plan. When I try to call MyClass.getData(self, ...), I get an error essentially saying that my ZMyClass instance is not an instance of MyClass, so I can't call that method. Python's isinstance tells me that this is the case even though issubclass verifies that ZMyClass is a subclass of MyClass. Is it not possible to wrap regular Python classes with Zope wrappers simply by inheriting from the regular class and a Zope class like Folder/SimpleItem? Kevin Smith Kevin.Smith@theMorgue.org
This works great! Thanks! But I see that there is something else wrong with my plan. When I try to call MyClass.getData(self, ...), I get an error essentially saying that my ZMyClass instance is not an instance of MyClass, so I can't call that method. Python's isinstance tells me that this is the case even though issubclass verifies that ZMyClass is a subclass of MyClass. Is it not possible to wrap regular Python classes with Zope wrappers simply by inheriting from the regular class and a Zope class like Folder/SimpleItem?
Ahh... this is probably due to the fact that one is an ExtensionClass and one is a normal class. Try doing: ZMyClass.inheritedAttribute('getData')() Brian Lloyd brian@zope.com Software Engineer 540.361.1716 Zope Corporation http://www.zope.com
participants (2)
-
Brian Lloyd -
Kevin Smith