[Zope] Duplicated keys in a BTreeFolder2
Thierry Florac
thierry.florac at onf.fr
Thu Aug 7 12:46:35 EDT 2003
On Thursday 07 August 2003 10:21, Andreas Jung wrote:
> --On Donnerstag, 7. August 2003 10:11 Uhr +0200 Thierry Florac
>
> <thierry.florac at onf.fr> wrote:
> > Hi,
> >
> > I currently use a custom subclass of BTreeFolder2 to store my site's
> > users profiles (currently 3700).
> >
> > I've noticed several problems :
> > - several keys (= user ids) are duplicated in this folder ; in the ZMI,
> > these duplicated keys appear at the start of the list, unordered.
> > - some keys are duplicated more than once ; if I try to delete one of
> > them, the other duplicated keys are kept and can't be deleted, because
> > the object doesn't exist !!!
> > - if I try to cut a duplicated object and paste it into another folder,
> > I receive an error message, saying that I'm trying to paste an object
> > from a foreign database connection !!!
> >
> > So here are my questions :
> > - is it a bug in BTreeFolder2 ?? Can I avoid this ?
> > - are duplicated keys pointing to the same object or no ?
> > - is it possible to repair this, without losing currently stored objects
> > ??
>
> Do you have a unittest to reproduce this? What Zope version are you
> running? This might be a problem with BTrees.
I'm afraid no !!
I can't get this to be easilly reproductible, but I just noticed that it
actually happens sometimes...
The only thing I can say to help is to give you the part of my Python script
which handles profiles creation ; his goal is just to automatically create a
profile for a newly connected user (anonymous access is forbidden, I use
ZSession to handle sessions ; "Intraforet" is the name of my product which
handle all my custom classes, "users" is the instance of my custom
BTreeFolder2 class) :
-----
from AccessControl import getSecurityManager
acl_user = getSecurityManager().getUser()
username = acl_user.getUserName().lower()
profile = None
if not session.has_key ('IF_USERNAME'):
profile = getattr (context.users, username, None)
if profile is None:
context.users.manage_addProduct['Intraforet'].manage_addIFUser
(username, 'if_sql_connexion', 'if_ldap_connexion')
profile = getattr (context.users, username)
session.set ('IF_USERNAME', username)
-----
This seems quite simple to me...
Perhaps another solution could be to do :
...
profile = IF_User (username, 'if_sql_connexion', 'if_ldap_connexion')
context.users._setObject (profile.id, profile)
...
but I don't think that this would change anything... No ??
Thierry
More information about the Zope
mailing list