Well, when I run it, I am able to do the following: ------------------------------------ class A: pass class B(A): pass b = B() B.__bases__ = () print B.__bases__ ------------------------------------ Not so on the version that comes with zope. (B.__bases__ will remain unchanged.) What I aim to do is have the User Object inherit from a custom class (AlienUser). -----Original Message----- From: Andreas Jung [mailto:lists@andreas-jung.com] Sent: Friday, May 20, 2005 12:46 PM To: Dan Pozmanter; zope@zope.org Subject: Re: [Zope] Modifying __bases__ --On Freitag, 20. Mai 2005 12:32 Uhr -0400 Dan Pozmanter <dan@siteworx.com> wrote:
Hey,
I noticed that the version of python that ships with zope is restricted, such that when you create an instance of a class, you are no longer able to modify __bases__ for that class object.
This is not the case with standard python.
Is this intentional? If so, what is the reasoning behind this?
You mean the Windows binaries? This should be a standard Python version. However by do you want to modify __bases__? This sounds like a very evil hack to me. What's your usecase? -aj
Am Freitag, den 20.05.2005, 13:48 -0400 schrieb Dan Pozmanter:
Well, when I run it, I am able to do the following:
------------------------------------ class A: pass
class B(A): pass
b = B()
B.__bases__ = ()
print B.__bases__ ------------------------------------
Not so on the version that comes with zope. (B.__bases__ will remain unchanged.)
What I aim to do is have the User Object inherit from a custom class (AlienUser).
Well, you can just inherit with a class from zopes extension classes. You cannot modify the class bases like this with extension classes. You can work around that like I did with the history (monkey) patch: http://www.zope.org/Members/tino/PatchHistory/view Otherwise it sounds evil and you failed to show the true motivation with your example above. Tino. PS: Votes for a true implementation in current zope instead of the monkey patch? If so, tell me.
On Fri, May 20, 2005 at 01:48:46PM -0400, Dan Pozmanter wrote:
What I aim to do is have the User Object inherit from a custom class (AlienUser).
You can do that in two ways off the top of my head: 1) the good way: write a custom UserFolder. You could probably get away with just inheriting from UserFolder and overriding _doAddUser(). 2) the hacky way: monkeypatch User.py to replace SimpleUser with your class. either way the stuff you are interested in is in AccessControl/User.py. -- Paul Winkler http://www.slinkp.com
You might also be able to do the __bases__ hack with Zope 2.8 (as long as Python 2.3+ allows you to assign to it), as it reimplements ExtensionClass using metaclasses instead of custom C hackery. On Fri, 2005-05-20 at 14:46 -0400, Paul Winkler wrote:
On Fri, May 20, 2005 at 01:48:46PM -0400, Dan Pozmanter wrote:
What I aim to do is have the User Object inherit from a custom class (AlienUser).
You can do that in two ways off the top of my head:
1) the good way: write a custom UserFolder. You could probably get away with just inheriting from UserFolder and overriding _doAddUser().
2) the hacky way: monkeypatch User.py to replace SimpleUser with your class.
either way the stuff you are interested in is in AccessControl/User.py.
participants (4)
-
Chris McDonough -
Dan Pozmanter -
Paul Winkler -
Tino Wildenhain