Re: [Zope] getattr in Python Method problem

2000-11-27 Thread Dieter Maurer

Peter Bengtsson writes:
 > In the folder where dosomething_pym (Python Method) is located, is also a string 
 >property set called 'en' with the value 'English'
 > The Python Method object is called with no parameters, but is defined with the 
 >'self' parameter inside the Python Method object.
 > 
 > In a DTML Method this works fine:
 > 
 > and returns
 > "English"
 > 
 > This is what I try in the Python Method:
 > lang=getattr(self,'en')
 > 
 > but this raises an error!
 > Error Type: AttributeError
 > Error Value: validate
I have not yet seen a Python method specification.
Anyway, there are several Python method implementations around
that might be different in the relevant aspects.

Personnally, I would expect a bug in "getattr".
However, it might also be the case, that "self" is not
what we expect (and what it is for external methods:
the folder, the object is located in).

If you use a new version of Python Methods (now called Python Scripts),
then you might try "context" rather than "self".
I think, you can use it without the need to pass it as parameter.


Dieter







___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




[Zope] getattr in Python Method problem

2000-11-26 Thread Peter Bengtsson

In the folder where dosomething_pym (Python Method) is located, is also a string 
property set called 'en' with the value 'English'
The Python Method object is called with no parameters, but is defined with the 'self' 
parameter inside the Python Method object.

In a DTML Method this works fine:

and returns
"English"

This is what I try in the Python Method:
lang=getattr(self,'en')

but this raises an error!
Error Type: AttributeError
Error Value: validate

I have searched the mailing list but in vain. 
Some people say it should be
lang=getattr(self,'en')(self,REQUEST)

But that raises the same error.

Best regards, Peter


___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )