PUT method & get property of parent folder
Hi, how and where can I test in the PUT method, if a property called "TIDY" (boolean) is set in the parent folder the new instance of xyz will created in? Class xyz(DTMLDocument): [...] def PUT(self, REQUEST, RESPONSE): """Handle HTTP PUT requests.""" self.dav__init(REQUEST, RESPONSE) self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1) body=REQUEST.get('BODY', '') self._validateProxy(REQUEST) self.munge(body) self.ZCacheable_invalidate() RESPONSE.setStatus(204) return RESPONSE Thanks Marcus -- Petition for a Software Patent Free Europe http://petition.eurolinux.org
On Tue, 09 Apr 2002 00:34:04 +0200 "Marcus Schopen" <marcus@localguru.de> wrote:
how and where can I test in the PUT method, if a property called "TIDY" (boolean) is set in the parent folder the new instance of xyz will created in?
Class xyz(DTMLDocument): [...] def PUT(self, REQUEST, RESPONSE): """Handle HTTP PUT requests."""
hi marcus, maybe something like this will work (aquiring the property, this should work for you): if hasattr(self,'TIDY'): ThenDoYourCleaningUp or if you want the property of the parent folder (or aquiring up): if hasattr(self.aq_parent,'TIDY'): ThenDoYourCleaningUp cu, maik.
Hei Maik, thanks for answering. Maik Jablonski wrote:
if hasattr(self,'TIDY'): ThenDoYourCleaningUp
That's what I thought too. But result is false and should be true.
or if you want the property of the parent folder (or aquiring up):
if hasattr(self.aq_parent,'TIDY'): ThenDoYourCleaningUp
does not work Bye Marcus -- ,---- [ Marcus Schopen ] | (0> | //\ P.O. Box 10 25 25 | V_/_ D-33525 Bielefeld, Germany | `---- __________________________________________________ Petition for a Software Patent Free Europe http://petition.eurolinux.org
hi again, maybe I didn't understand the problem right away... but maybe this will work (it does for me): if self.hasProperty('TIDY'): ThenDoMuchMoreCleanUp or: if self.aq_parent.hasProperty('TIDY'): ThenDoMuchMoreCleanUp greetings, maik. On Tue, 09 Apr 2002 11:23:25 +0200 "Marcus Schopen" <marcus@localguru.de> wrote:
Hei Maik,
thanks for answering.
Maik Jablonski wrote:
if hasattr(self,'TIDY'): ThenDoYourCleaningUp
That's what I thought too. But result is false and should be true.
or if you want the property of the parent folder (or aquiring up):
if hasattr(self.aq_parent,'TIDY'): ThenDoYourCleaningUp
does not work
Maik Jablonski wrote:
maybe I didn't understand the problem right away... but maybe this will work (it does for me):
if self.hasProperty('TIDY'): ThenDoMuchMoreCleanUp
or:
if self.aq_parent.hasProperty('TIDY'): ThenDoMuchMoreCleanUp
NO, both don't work in in the PUT method!
Marcus Schopen writes:
how and where can I test in the PUT method, if a property called "TIDY" (boolean) is set in the parent folder the new instance of xyz will created in?
Class xyz(DTMLDocument): [...] def PUT(self, REQUEST, RESPONSE): """Handle HTTP PUT requests.""" self.dav__init(REQUEST, RESPONSE) self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1) body=REQUEST.get('BODY', '') self._validateProxy(REQUEST) self.munge(body) self.ZCacheable_invalidate() RESPONSE.setStatus(204) return RESPONSE You use "getProperty" to check for a property of an object (--> Zope online help -> Zope Help -> API reference -> Object manager).
You use method "aq_parent" (or "aq_inner" followed by "aq_parent") to access the parent. To understand, where you are, and how many "aq_parent" you need to use, you can use Shane's "showaq" method (--> list archives). Dieter
Hi Dieter, Dieter Maurer wrote:
how and where can I test in the PUT method, if a property called "TIDY" (boolean) is set in the parent folder the new instance of xyz will created in?
Class xyz(DTMLDocument): [...] def PUT(self, REQUEST, RESPONSE): """Handle HTTP PUT requests.""" self.dav__init(REQUEST, RESPONSE) self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1) body=REQUEST.get('BODY', '') self._validateProxy(REQUEST) self.munge(body) self.ZCacheable_invalidate() RESPONSE.setStatus(204) return RESPONSE You use "getProperty" to check for a property of an object (--> Zope online help -> Zope Help -> API reference -> Object manager).
You use method "aq_parent" (or "aq_inner" followed by "aq_parent") to access the parent.
To understand, where you are, and how many "aq_parent" you need to use, you can use Shane's "showaq" method (--> list archives).
it's more than mysterious calling "showaq(self, ' html ')" from "manage_addHTMLDocument" (creating an instance via Zope's Managment Interface) says: HTMLDocument | <ProductDispatcher instance at 8102880> | HTMLFolder | Zope | <RequestContainer instance at 886b2f8> Uploading a file via FTP and calling "showaq(self, ' html ')" from PUT method says NOTHING !!! Why? Bye Marcus
Marcus Schopen wrote:
how and where can I test in the PUT method, if a property called "TIDY" (boolean) is set in the parent folder the new instance of xyz will created in?
Class xyz(DTMLDocument): [...] def PUT(self, REQUEST, RESPONSE): """Handle HTTP PUT requests.""" self.dav__init(REQUEST, RESPONSE) self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1) body=REQUEST.get('BODY', '') self._validateProxy(REQUEST) self.munge(body) self.ZCacheable_invalidate() RESPONSE.setStatus(204) return RESPONSE
I used "manage_afterAdd" (see OFS.SimpleItem for details): def manage_afterAdd(self, item, container): self.updateHTMLFile() def updateHTMLFile(self): """ do something !!! object is now in zopetree, you have full access to parents properties !!! """ def PUT(self, REQUEST, RESPONSE): ... # only for FTP-updates; frist upload is automaticly # managed by manage_afterAdd # if hasattr(self, 'TIDY'): self.updateHTMLFile() -- ,---- [ Marcus Schopen ] | (0> | //\ P.O. Box 10 25 25 | V_/_ 33525 Bielefeld | Germany `---- __________________________________________________ Petition for a Software Patent Free Europe http://petition.eurolinux.org
participants (4)
-
Dieter Maurer -
Maik Jablonski -
Marcus Schopen -
Marcus Schopen