[Zope-dev] SkinScripts instantiating new objects

Stefan Karlsson stefan@everynet.se
Fri, 16 Feb 2001 16:00:58 +0100


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