Houston, we have a problem. Here's the code : from Products.PageTemplates.PageTemplateFile import PageTemplateFile from AccessControl import ClassSecurityInfo import Globals class User() : security = ClassSecurityInfo() security.declareObjectPublic() security.setDefaultAccess("allow") def viewProfile(self): """ """ userProfile = PageTemplateFile("vues/userProfile.pt",globals()).__of__(self) return userProfile() Globals.InitializeClass(Interlocuteur) And here's what I got : TypeError: attempt to wrap extension method using an object that is not an extension class instance. Traceback: * Module ZPublisher.Publish, line 101, in publish * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 39, in call_object ... * Module Products.PageTemplates.Expressions, line 74, in render * Module Products.GestionnaireInscriptions.Interlocuteur, line 39, in voirFiche TypeError: attempt to wrap extension method using an object that is not an extension class instance. Note : s/Interlocuteur/User/ s/voirFiche/viewProfile/ Besides, this solution do not seem elegant for me, because each time I try to view a user's profile, it requires an instanciation of PageTemplateFile. I find this useless. This PageTemplateFile should be a class attribute. --- On Mon, 9/15/08, chaouche yacine <yacinechaouche@yahoo.com> wrote:
From: chaouche yacine <yacinechaouche@yahoo.com> Subject: Re: [Zope] 'str' object has no attribute 'other' To: "Martijn Jacobs" <martijn@fourdigits.nl> Cc: "zope zope" <zope@zope.org>, marco.bizzarri@gmail.com Date: Monday, September 15, 2008, 9:14 PM Aha ! good point. I'll try that as soon as I get to work.
Thank you.
Marco, I'm using zope 2.7, python 2.3 (this is customer's configuration).
--- On Mon, 9/15/08, Martijn Jacobs <martijn@fourdigits.nl> wrote:
From: Martijn Jacobs <martijn@fourdigits.nl> Subject: Re: [Zope] 'str' object has no attribute 'other' To: yacinechaouche@yahoo.com Cc: "zope zope" <zope@zope.org> Date: Monday, September 15, 2008, 2:46 PM I think it has something to do with the PageTemplate not properly (explicit) acquiition wrapped .
Try changing the line : userProfile =
PageTemplateFile("views/userProfile.pt",globals())
into : userProfile =
PageTemplateFile("views/userProfile.pt",globals()).__of__(self)
See for more information :
http://www.zopelabs.com/cookbook/995992579
Regards,
Martijn.
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 ?
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
-- Martijn Jacobs Four Digits, Internet Solutions
a: Willemsplein 15-1 6811 KB Arnhem NL kvk: 091621370000 | btw: 8161.22.234.B01 e-mail: martijn@fourdigits.nl | web: http://www.fourdigits.nl tel: +31 (0)26 44 22 700 | fax: +31 (0)84 22 06 117
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )