After receiving a snippet of python script, I finally decided to have a closer look at that language, and I was surprised how simple and comfortable it is. I think I'll like it! But: Where can I find a reference for the objects I can use in those scripts? I received the following snippet: try: my_index = context.dirIndex. except: my_index = 0 But I only want my_index to become 0 when the object and ONLY then object, i. e. without acquisition, has the prop dirIndex. s. th. like in DTML: <dtml-if "_.hasattr(aq_explicit,'dirIndex')"> Can anyone help me please? Where can I get information about python script? I looked at python.org, but didn't find what I was looking for... TIA -- Lars Heber, mailto:Lars.Heber@t-systems.de T-Systems, debis Systemhaus GEI GmbH, Geschaeftsstelle Sachsen
Create an external method called "ihasattr" containing: from Acquisition import aq_base def ihasattr(self, obj, attr): return hasattr(aq_base(obj), attr) and use that function.
But I only want my_index to become 0 when the object and ONLY then object, i. e. without acquisition, has the prop dirIndex. s. th. like in DTML: <dtml-if "_.hasattr(aq_explicit,'dirIndex')">
Can anyone help me please? Where can I get information about python script? I looked at python.org, but didn't find what I was looking for... -- Florent Guillaume, Nuxeo SARL (Paris, France) +33 1 40 33 79 10 http://nuxeo.com mailto:fg@nuxeo.com
On Tuesday 16 October 2001 11:38 am, Lars Heber allegedly wrote:
After receiving a snippet of python script, I finally decided to have a closer look at that language, and I was surprised how simple and comfortable it is. I think I'll like it! But: Where can I find a reference for the objects I can use in those scripts? I received the following snippet:
try: my_index = context.dirIndex. except: my_index = 0
But I only want my_index to become 0 when the object and ONLY then object, i. e. without acquisition, has the prop dirIndex. s. th. like in DTML: <dtml-if "_.hasattr(aq_explicit,'dirIndex')">
Can anyone help me please? Where can I get information about python script? I looked at python.org, but didn't find what I was looking for...
TIA
If this is a property (as opposed to a general attribute) then use the built in hasProperty method: context.hasProperty('dirIndex') Acquisition won't be an issue. I'm glad to hear you like Python, you're soaking in it! 8^) /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/
participants (3)
-
Casey Duncan -
Florent Guillaume -
Lars Heber