[Zope-dev] SkinScripts instantiating new objects
Hi, I want my SkinScript to instantiate a new object of type ProjektHandler and put it into an attribute called projekt. For this I have created an external method, returning a new object of type ProjektHandler (simplified): def getNewProjektHandler(self, parentId, parentClass): h = ProjektHandler() return h The skinscript look like this: WITH self.getNewProjektHandler(self.id, 'Projektagare') COMPUTE projekt=RESULT This works if I call it from python, e. g print self.mySpecialist.getItem('foo').projekt But it does not work when I call it from the web, e. g http://server/mySpecialist/foo/projekt (see the traceback from the log file below) Has anyone an idea why this doesn't work? Zope 2.3.0b2 ZPatterns 0.4.3b1 /Stefan Karlsson -- 2001-02-16T11:28:35 PROBLEM(100) ZPatterns Error computing attribute projekt Traceback (innermost last): File /home/stefan/myzope/zope2/lib/python/Products/ZPatterns/AttributeProviders.py, line 311, in _ AttributeFor (Object: GAPMixin) File Products/ZPatterns/Expressions.py, line 122, in eval File DocumentTemplate/DT_Util.py, line 336, in eval (Object: self . getNewProjektHandler ( self . id , 'Projektagare' )) (Info: self) File string, line 0, in ? File DocumentTemplate/DT_Util.py, line 140, in careful_getattr AttributeError: getNewProjektHandler ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] SkinScripts instantiating new objects
At 14:31 2001-02-16, Steve Alexander wrote: Stefan Karlsson wrote: Hi, I want my SkinScript to instantiate a new object of type ProjektHandler and put it into an attribute called projekt. In your example, there is no sense of the ProjektHandler instance being saved persistently in the attribute. A new object is created for each transaction. Is this what you want? Yes, that was my intention. BTW is it possible to save the ProjektHandler instance persistently in the attribute? Is there an easier way than creating a separate specialist for the ProjektHandler class and storing the instances there? For this I have created an external method, returning a new object of type ProjektHandler Where have you put this external method? That is, where in the ZODB? I have put it in the rack, the specialist and higher up in the hierarchy. Makes no difference. The skinscript look like this: WITH self.getNewProjektHandler(self.id, 'Projektagare') COMPUTE projekt=RESULT This works if I call it from python, e. g print self.mySpecialist.getItem('foo').projekt But it does not work when I call it from the web, e. g http://server/mySpecialist/foo/projekt That's as I expect. Generally, you call methods from URLs, you don't retrieve the values of attributes. So, what do you suggest, should I implement __bobo_traverse__ or something in foo to make the URL work? /Stefan Karlsson ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )