I've done a few Zope 2 projects, and am trying to wrap my head around Zope 3
now. The style I evolved for putting together Zope 2 applications may not
have been very orthodox. 

Basically I found that I disliked (and mistrusted, maybe because at the time
I didn't understand the security wrappers very well) calling any methods
from within ZPTs. Thus my pattern eventually became that all pages were
themselves methods of my objects, which would do whatever setup is
necessary, stuff the self.REQUEST object with whatever is required, and the
method would then return the ZTP object. Something like this...

  _page = PageTemplateFile('www/somePage.htm', globals())

  def page(self):
    """do whatever is necessary to set up REQUEST then call template"""
    self.REQUEST.set('some', 'info')
    self.REQUEST.set('data', self.inaccessableFromWeb())
    return self._page()

It's a fairly straight forward approach really (probably betraying deep and
ugly CGI roots). It may not be the most efficient, but it makes it very
explicit for my templates where info is coming from: it *always* all comes
from the method which returns the template before calling the template.

So, now, Zope 3... somewhat different, to say the least! There is the, if
not 100% enforced, certainly more strongly segregated, "view" portion of an
app. And perhaps it's time to change. Perhaps I have no choice. Perhaps I
have a choice, but it would be just easier (and better) in the long run to
figure out the more zope3ish ways of doing things.

In the maze of interfaces and frighteningly magical zcml glue, I can't even
figure out how to get ahold of the request object outside of a ZPT. (-:
I've looked through bugtracker and a few other bits of code that have some
slight use of 'self.request', but still can not figure it out (at least
everything i have tried has not worked in my tries at it. And many of the
samples I found seem to get the request via different methods, which is a
bit confusing. Do I implement, adapt, subclass, call... what? I'm sure it
would be possible for me, eventually, figure out how to perpetuate my
pattern in a zope 3 context... (though the paradigm shift has been pretty
brutally painful so far, and I've barely yet begun) and it would make
porting a whole lot faster... (assuming also i can figure out how to get
traversal working, or restructure my code so I don't need it...)

So still, I wonder... how can I get that request object I love so to abuse?

[Sort of a long post, for the simple anti-climatic question. Sorry! But if
anyone read this far and has any thoughts, or pointers to sample code
and/or obscure documentation, pertaining to any of the above ramble, I'd
love to hear about it...]



_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to