[Zope] 'str' object has no attribute 'other'

Marco Bizzarri marco.bizzarri at gmail.com
Mon Sep 15 13:23:31 EDT 2008


On Mon, Sep 15, 2008 at 11:09 AM, chaouche yacine
<yacinechaouche at yahoo.com> wrote:
> HAI list,
>
> I am developing a zope product composed of a bunch of python classes, some which are instanciated in the ZODB, like plone's tools, and some that are just helper classes, they do not need to be instanciated in the ZODB.
>
> UserManager is a class that is in the ZODB. UserManager retrieves users from MySQL, and create User objects. User is a classic python class (that is not instanciated in the ZODB).
>
> For every user, i wish to display its profile on the site using a Page Template. So I tried something like this :
>
> from Products.PageTemplates.PageTemplateFile import PageTemplateFile
> from AccessControl                           import ClassSecurityInfo
> from Utilisateur                             import Utilisateur
> import Globals
>
> class User() :
>    security = ClassSecurityInfo()
>    security.declareObjectPublic()
>    security.setDefaultAccess("allow")
>
>    userProfile = PageTemplateFile("views/userProfile.pt",globals())
>
>    ...
>
> Globals.InitializeClass(User)
>
>
> Then, in UserManager, I have another Page Template that displays a user profile this way :
>
> <html>
> <body>
>  <h1>User profile </h1>
>  <hr/>
>  <ins tal:define="myUser request/SESSION/myUser" tal:replace="myUser/userProfile"
> </body>
> </html>
>
>
> This code produces the following error :
>
>
> Module ZPublisher.Publish, line 101, in publish
> Module ZPublisher.mapply, line 88, in mapply
> Module ZPublisher.Publish, line 39, in call_object
> ...
> Module Shared.DC.Scripts.Bindings, line 1, in ?
> Module Shared.DC.Scripts.Bindings, line 286, in _getTraverseSubpath
> AttributeError: 'str' object has no attribute 'other'
>
>
> Any ideas ?
>

What version of zope are you running? Can you edit
Shared.DC.Scripts.Bindings, at line 286, and see what is the code
saying there. In Zope 2.9.6 the only occurence of "other" inside
Bindings.py is:

    def _getTraverseSubpath(self):
        # Utility for bindcode.
        if hasattr(self, 'REQUEST'):
            return self.REQUEST.other.get('traverse_subpath', [])
        else:
            return []

So, I assume for some very strange reason other is applied to
something which is a string. Have you tried to add an

import pdb; pdb.set_trace()

just before the return, and inspect what is going on there? Of course,
you've to run your zope instance in foreground...

I suggest you to check python pages on pdb, and on how to debug things
with zope debug.

Regards
Marco

-- 
Marco Bizzarri
http://notenotturne.blogspot.com/
http://iliveinpisa.blogspot.com/


More information about the Zope mailing list