Discussion:
[Erp5-dev] minor changes to make security and project work
Bartek Gorny
2006-07-24 17:45:28 UTC
Permalink
Hello

To make security system work, I made two changes:

(1) assign destination_project base category to category_type "assignment"

(2) Products.ERP5Type.ERP5Type.py, line 365
- group_id = group_id_generator(**category_dict)
+ group_id = group_id_generator(self,**category_dict)

The latter was needed to make asSecurityGroupId run as external method.

Is it ok?

B.
--
"Software is largely a service industry operating under the persistent
but unfounded delusion that it is a manufacturing industry."
Eric S.Raymond, "The Magic Cauldron"
Yoshinori Okuji
2006-07-24 20:51:16 UTC
Permalink
Post by Bartek Gorny
(1) assign destination_project base category to category_type "assignment"
(2) Products.ERP5Type.ERP5Type.py, line 365
- group_id = group_id_generator(**category_dict)
+ group_id = group_id_generator(self,**category_dict)
The latter was needed to make asSecurityGroupId run as external method.
As I haven't tested asSecurityGroupId as an external method, I might be
seriosly wrong, but...

According to the code, group_id_generator is obtained from "object", so the
method should be bound to "object". Thus I _guess_ "self" in an external
method becomes "object" automatically. What is wrong with this behavior?

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
Bartek Gorny
2006-07-25 15:02:25 UTC
Permalink
Post by Yoshinori Okuji
Post by Bartek Gorny
(1) assign destination_project base category to category_type "assignment"
(2) Products.ERP5Type.ERP5Type.py, line 365
- group_id = group_id_generator(**category_dict)
+ group_id = group_id_generator(self,**category_dict)
The latter was needed to make asSecurityGroupId run as external method.
As I haven't tested asSecurityGroupId as an external method, I might be
seriosly wrong, but...
According to the code, group_id_generator is obtained from "object", so the
method should be bound to "object". Thus I _guess_ "self" in an external
method becomes "object" automatically. What is wrong with this behavior?
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.

B.
Post by Yoshinori Okuji
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
_______________________________________________
Erp5-dev mailing list
Erp5-dev at erp5.org
http://erp5.org/mailman/listinfo/erp5-dev
--
"Software is largely a service industry operating under the persistent
but unfounded delusion that it is a manufacturing industry."
Eric S.Raymond, "The Magic Cauldron"
Yoshinori Okuji
2006-07-25 18:16:44 UTC
Permalink
Post by Bartek Gorny
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
Loading...