Behalf Of Florian Lindner
> Sent: Friday, April 08, 2005 8:18 PM
> To: zope3-dev@zope.org; [EMAIL PROTECTED]
> Subject: Re: [Zope3-dev] RE: [Zope3-Users] page uses foreign 
> view:contextchanged
> 
> Am Mittwoch, 6. April 2005 18:26 schrieb Roger Ineichen:
> > Hi Florian
> >
> > Behalf Of Florian Lindner
> >
> > > Sent: Wednesday, April 06, 2005 11:10 PM
> > > To: zope3-dev@zope.org; [EMAIL PROTECTED]
> > > Subject: Re: [Zope3-dev] RE: [Zope3-Users] page uses foreign
> > > view: contextchanged
> > >
> > > Am Mittwoch, 6. April 2005 17:01 schrieb Roger Ineichen:
> > > > Hi Florian
> > > >
> > > > Behalf Of Florian Lindner
> > > >
> > > > > Sent: Wednesday, April 06, 2005 10:22 PM
> > > > > To: zope3-users@zope.org
> > > > > Subject: [Zope3-Users] page uses foreign view: context changed
> > > > >
> > > > > Hello,
> > > > > I'vw a viewA on a objectA including a macro:
> > > > >
> > > > >
> > > > > <metal:block define-macro="info">
> > > > >   <span tal:replace="context/__name__" />
> > > > > </metal:block>
> > > > >
> > > > > A view of objectB uses this macro and inserts it into its
> > >
> > > own viewB:
> > > > I can't follow. What do you try to say?
> > > > What is "A view of objectB" and "its own viewB"?
> > >
> > > A object uses a macro which is defined in a view of 
> another object.
> > > In this macros I want to access the data from the object 
> the view was
> > > originaly registered for.
> >
> > Ok, I was thinking about that you mean somthing like this.
> > This isn't possible. Or let's say you mix up some parts.
> >
> > The macro which you suggest is just a page template. This template
> > you are useing in a view. If this macro is also used in 
> another view,
> > it has in this usecase nothing to do with the other view. There is
> > no relation, if you register a page template as a macro and a second
> > time as a view, between the macro and the view.
> >
> > Perhaps I don't understand this correctly. Can you post the ZCML
> > directive, then I see what you mean?
> 
> Ok, I've understand the problem.
> 
> What I want:
> 
> A folderish object f has a view. This should display 
> information from the 
> children of f. The children provide this information as a 
> snippet of HTML 
> code which could be inserted directly in f's view.
> 
> f
> |- a
> |- b
> |- c
> |- d
> 
> The view of f should iterate through [a,b,c,d] and get the 
> snippet from every 
> object. The snippets should be in the same order like the 
> objects in the 
> folder. Only direct children should be called.
> 
> The problem I see with pagelets that the order is undefinied 
> and that all 
> children (recursivly) and not only direct children are called.
> 
> Or is the best way to implement a own MacroCollector for that?

No pagelets are not the concept for collecting information 
from objects others then the context.

If you like to use parts of the pagelet concept, you can use
pagedata adapters. But I whould use a simply view on the folder
for this.

Write a view 'childView' for childs and a view 'folderView' for 
folder "f" with a method getHTML like: 


def __init__(self, context, request):
  self.context = context
  self.request = request

def getHTML(self):
  
  htmlcode = ""

  # get the childs of folder 'f'
  childs = self.context.values()

  for item in childs:

    # get the 'childView' for each item
    view = zapi.getMultiAdapter((self.context, item), name='childView')

    # call the view, this returns the html code of the view
    htmlcode += view()

  # return all html code where get collected
  return htmlcode

The view 'childView' is a page template where contains the html.


The result of getHTML can be used in the folder view like:

<tal:block content="structure context/getHTML" />

I think this is the easiest way. You can also implement some
permission checks before you access the childs. If you use
different permissions on childs.

Regards
Roger Ineichen

> Bye,
> 
> Florian
> 
> _______________________________________________
> Zope3-dev mailing list
> Zope3-dev@zope.org
> Unsub: 
> http://mail.zope.org/mailman/options/zope3-dev/dev%40projekt01.ch
> 
> 

_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to