[Zope-CMF] Creator info not properly cataloged
Ivo van der Wijk
ivo@amaze.nl
Mon, 18 Nov 2002 11:46:47 +0100
On Sat, Nov 16, 2002 at 11:52:12PM +0100, Ivo van der Wijk wrote:
> On Sat, Nov 16, 2002 at 11:04:22PM +0100, Ivo van der Wijk wrote:
> > On Sat, Nov 16, 2002 at 08:42:44PM +0100, Dieter Maurer wrote:
> > > Ivo van der Wijk writes:
> > > > After putting my locally developed CMF site online, I noticed that
> > > > references to here/Creator were replaced with 'Anonymous User', while
> > > > the object definately had a proper owner (and still has).
> > > "Creator" is defined by means of "getOwner".
> > >
> > > The Owner of your documents is apparently wrong.
> > > Check, what "owner_info" tells you for your objects.
> > >
> >
> > It returns 'Anonymous user'. It does this, because Owned.getOwner()
> > attempts to find the userfolder the user is defined in, but fails,
> > because the location (relative to the physicalRoot) changed.
> >
> > this part of getOwner to be more specific:
> >
> > root=self.getPhysicalRoot()
> > udb=root.unrestrictedTraverse(udb, None)
> > if udb is None:
> > user = SpecialUsers.nobody
> > else:
> > user = udb.getUserById(oid, None)
> >
> >
>
I boiled the issue down to a bug in Zope itself. Here's what happens:
- Create a folder 'a' with acl_users, with user 'john'
- have user john create an object 'b' in 'a' (/a/b), owned by him.
- object b will have the following properties:
owner_info():
'userCanChangeOwnershipType': 1, 'id': 'john', 'explicit': 1, 'path': 'a/acl_users'}
getOwner():
'john'
Note the path in owner_info: a/acl_users - this is the path of the userfolder
the owner is defined in.
- Now create a folder /elsewhere, *cut* (not copy) /a and paste it into
/elsewhere. This will result in /elsewhere/a/b etc.
- object b, now in /elsewhere/a/b will have the following properties:
owner_info():
'userCanChangeOwnershipType': 1, 'id': 'john', 'explicit': 1, 'path': 'a/acl_users'}
getOwner():
'Anonymous User'
getOwner() will result the wrong Owner, unless semi-loss of ownership is
expected behaviour in such cases. This is because 'path' hasn't been adjusted
to the new location of the acl_users, it's no longer in /a/acl_users (that's
why you had to 'cut'), but now in '/elsewhere/a'. And getOwner() (in Owned.py)
explicitly resolves the userobject using this path.
Does this qualify as a bug? Does anyone know a clean fix? (I've written
some hacky code to fix the problem afterwards, but it would be way better
to have this info updated directly after the move).
Note that this problem especially occurs when exporting/importing a site
with local users (such as a CMF site) from one server to another, and the
relative location changes (which can be quite common when moving from a
development machine to a virtual hosting environment)
Cheers
Ivo
--
Drs. I.R. van der Wijk -=-
Brouwersgracht 132 Amaze Internet Services V.O.F.
1013 HA Amsterdam, NL -=-
T +31-20-4688336 F +31-20-4688337 Linux/Web/Zope/SQL/MMBase
W http://www.amaze.nl E info@amaze.nl Network Solutions
W http://vanderwijk.info E ivo@amaze.nl Consultancy
PGP http://vanderwijk.info/pgp -=-