[Zope] acces to file properties on a precondition - WILL SUMMARIZE
Didier Georgieff
Didier.GEORGIEFF@agriculture.gouv.fr
12 Mar 2002 17:55:35 +0100
Hello,
Just trying to test the new (?) policy for writing more how-tos and
summarized text for the community and see the right (tm) to do it ;-
)
- I have a subclassed file (with some more properties like
'approved')
- I want to use the precondition to check if the file is approved
before allowing the donwload
- i have a dtml-method for doing it and all is fine __exept__ that the
context of this script seems to be the container and not the file.
The precondition method aquire the property ('approved') from the
container (folder) and __not__ from the file.
I tried to use lotta <dtml-with>, some aq_explicit, without luck.
I also send a mail from the precondition (with the REQUEST and
some id/title as informations) for debugging, and it shows that
__everything__ comes from the container.
So, I tried to see where is the problem with an external method
(stolen from Dieter)
def baseHasAttr(object,attrname):
obj=3D getattr(object,aq_base,object)
return hasattr(obj,attrname)
and calling <dtml-if "baseHasAttr(this(),'approved')>
from the precondition script.
and this test shouts : __false__ even if there __is__ an 'approved'
property on the file object.
So i'm lost, and can't figure why i can't access the object instead of
the container in the precondition.
Is it because of a wrong syntax ?
Did i missed some aquisition trick ?
Do this fails because it's derived from file ?
Any help welcome, and .... I will summarize
--
Didier Georgieff
D=E9l=E9gation Interservice pour le D=E9veloppement du SIT67
t=E9l : 03.88.76.78.35 - fax : 03.88.76.78.34
email : didier.georgieff@agriculture.gouv.fr