[Zope] Override members values
Jonathan
dev101 at magma.ca
Mon Jul 10 11:51:24 EDT 2006
----- Original Message -----
From: "Garito" <garito at sistes.net>
> I try again:
>
> I have a property on the property manager called member1 with a value of
> "[/some/path]"
>
> User1 ask for this property. We calculate the real value for /some/path
> for these user: 1
> User2 ask for this property. We calculate the real value for /some/path
> for these user: 2
>
> I have a property on the property manager called member2 with a value of
> "[a reference to the calculator]"
>
> A user ask for this property from his firefox. We calculate the real value
> for the reference for this browser: <result1>
> Another user ask for this property from his ie. We calculate the real
> value for the reference for this browser: <result2>
>
> I would like to change the "accessor" for any property in my Zope product
>
> How can I?
If I understand what you are trying to accomplish (of which I am not
completely sure)...then you could create a script that accesses the object
and returns a value based on the user agent string:
eg.
import string
REQUEST = container.REQUEST
targetObject = context.restrictedTraverse('/some/path/objId')
if string.find(REQUEST['HTTP_USER_AGENT'], 'Firefox') != -1:
<do something with targetObject.attribute for Firefox users)
elif string.find(REQUEST['HTTP_USER_AGENT'], 'MSIE') != -1:
<do something with targetObject.attribute for Internet Explorer users)
else:
<do something with targetObject.attribute for xxx users)
Note: 'attribute' is whatever property you have defined for the object.
hth
Jonathan
More information about the Zope
mailing list