[Erp5-dev] minor changes to make security and project work

Yoshinori Okuji yo at nexedi.com
Tue Jul 25 20:16:44 CEST 2006


On Tuesday 25 July 2006 17:02, Bartek Gorny wrote:
> I'm not sure what behaviour you mean - inside my external method, a
> variable named "object" points to a <type 'object'>, and "self" does
> not exist unless explicitly passed as an argument. This much I know
> for sure, because I checked it. Therefore to gain access to ERP5
> objects I have to pass "self", unless there is some other way to do it
> of which I do not know.

I am afraid that you mistake the behavior. Inside an external method, "object" 
is a type object, because it is a builtin variable since Python 2.2, unless 
you override the meaning of "object" explicitly inside the scope (e.g. 
defining a variable named "object", which is really bad). In Python, when 
calling a method, the first parameter in a method (usually, "self") is the 
bound object to the method, when the method is a bound method, regardless of 
however the parameter is named. If you do this:

method = getattr(ob, method_id)

The method is bound to "ob" automatically, thus when calling this method, 
"self" (or whatever the first parameter) is identical to "ob".

YO
-- 
Yoshinori Okuji, Nexedi CTO
Nexedi: Consulting and Development of Free / Open Source Software
http://www.nexedi.com
ERP5: Full Featured High End Open Source ERP
http://www.erp5.com
ERP5 Wiki: Developer Zone for ERP5 Community
http://wiki.erp5.org



More information about the Erp5-dev mailing list