[Fwd: [BTreeFolder2] BTree keys corruption problem] Related LDAP problem ??
Hi, I posted the following message a few weeks ago, to explain a problem of duplicated keys into a BTreeFolder2 subclass. After looking for the origins of this problem, I just discovered a possible one : - the authentication into my web site is done via an LDAPUserFolder component ; - for an unknown reason (I don't know LDAP very much !), if a user authenticate himself using spaces before or after his user name, authentication is OK ; - if I try to create a new entry into my profiles folder using this user name (including spaces !), the entry is created into the BTreeFolder2 without spaces, and that seems to create duplicated keys !! Could I be wrong ?? I tried to resolve this problem by just striping the user name automatically before creating or loading his profile, and that seems to work. But I would always like to know if I look into the right side, and if there is any way to repair my broken duplicated keys... Thanks for any help or advise. Thierry ======================================================================== Hi, I'm currently using a subclass of a "BTreeFolder2" as a container to store my Zope (2.6.1) intranet site users profiles (with actually nearly 6000 profiles). Everything works OK but I have a little problem : a few keys (~50) are duplicated into the folder, visible at the beginning of the folder content ; some of the keys are even duplicated several times and visible without real order (see 'jmdal' on the attached screenshot !). The problem also is that if I try to remove a duplicated key, the corresponding entry is removed, but the other keys are kept, pointing to nothing !! I've tried to use the "manage_cleanup" method available with the last release of BTreeFolder2, but without success : result is "No damage detected" !! So my questions are : - how can I avoid these duplicated keys, as long as I only add my users profiles via a simple Python script which shouldn't break keys, with : if not context.users.has_key(username): context.users.manage_addProduct['MyProduct'].manage_addUserProfile(username) - as the profile's creation is automatic as soon as the user is authenticated (it's an internal site !), could the problem be due to 'concurrent' method calls ?? - is it possible to rebuild the folder keys, without breaking the pointed records ?? Many thanks for any help or advise. Thierry
FLORAC Thierry wrote:
Hi,
I posted the following message a few weeks ago, to explain a problem of duplicated keys into a BTreeFolder2 subclass. After looking for the origins of this problem, I just discovered a possible one : - the authentication into my web site is done via an LDAPUserFolder component ; - for an unknown reason (I don't know LDAP very much !), if a user authenticate himself using spaces before or after his user name, authentication is OK ; - if I try to create a new entry into my profiles folder using this user name (including spaces !), the entry is created into the BTreeFolder2 without spaces, and that seems to create duplicated keys !!
You should verify that you do indeed have duplicate keys. In html you cannot see the spaces first and last in the keys. <span> someid</someid> will look exactly the same as <span>someid</someid> in a browser. If you choose view source you should be able to determine if it is indeed so. I don't believe that The BTreeFolder makes duplicate keys, but the other problem is very likely. And one I have made myself from time to time, when forgetting to do an "id.strip()" regards Max M
On Tue, 2004-02-24 at 15:20, Max M wrote:
FLORAC Thierry wrote:
Hi,
I posted the following message a few weeks ago, to explain a problem of duplicated keys into a BTreeFolder2 subclass. After looking for the origins of this problem, I just discovered a possible one : - the authentication into my web site is done via an LDAPUserFolder component ; - for an unknown reason (I don't know LDAP very much !), if a user authenticate himself using spaces before or after his user name, authentication is OK ; - if I try to create a new entry into my profiles folder using this user name (including spaces !), the entry is created into the BTreeFolder2 without spaces, and that seems to create duplicated keys !!
You should verify that you do indeed have duplicate keys.
In html you cannot see the spaces first and last in the keys.
<span> someid</someid>
will look exactly the same as
<span>someid</someid>
in a browser.
If you choose view source you should be able to determine if it is indeed so.
I don't believe that The BTreeFolder makes duplicate keys, but the other problem is very likely. And one I have made myself from time to time, when forgetting to do an "id.strip()"
Hi, That's right and I was quite stupid !!! By BTreeFolder2 just had false duplicated keys because of these extra spaces invisible in my HTML page... In fact, the origin of the problem is my LDAP server, which accept authentication even when the user ID includes spaces !! I just thought that this shouldn't be !! Using a simple "strip" nearly solved my problem... Thanks, Thierry P.S. : I said that my problem was nearly solved because each user profile is private, so the user identified with the user id " tflorac" can't access the profile called "tflorac". Is there any way to alter the user authentication name ??
FLORAC Thierry wrote:
On Tue, 2004-02-24 at 15:20, Max M wrote:
P.S. : I said that my problem was nearly solved because each user profile is private, so the user identified with the user id " tflorac" can't access the profile called "tflorac". Is there any way to alter the user authentication name ??
If I understand your problem correctly, you can write an external script that goes over your_acl users and strips the user name if it has spaces in it, and then creates a new user with the stripped id. You can find the api of the acl_users folder in: <ZOPE>\LIB\python\AccessControl\User.py The code would look something like this (untested ;-) ): acl = self.acl_users users_to_delete = [] for old_user_name in acl.getUserNames(): stripped_name = old_user_name.strip() if stripped_name != old_user_name: old_user = acl.getUser(old_user_name) password = old_user._getPassword() roles = old_user.getRoles() domains = old_user.getDomains() acl._doAddUser(stripped_name, password, roles, domains) users_to_delete.append(old_user_name) acl._doDelUsers(users_to_delete) regards Max M
FLORAC Thierry wrote at 2004-2-24 09:14 +0100:
... if a user authenticate himself using spaces before or after his user name, authentication is OK ; - if I try to create a new entry into my profiles folder using this user name (including spaces !), the entry is created into the BTreeFolder2 without spaces, and that seems to create duplicated keys !!
Could I be wrong ??
Almost surely, you are. There is no way to get duplicate keys in a "BTree" (on which "BTreeFolder2" is built). Use "strip" to normalize your user names before you use the result as keys to your "BTreeFolder2". -- Dieter
participants (3)
-
Dieter Maurer -
FLORAC Thierry -
Max M