Comments below.

Ian Bicking wrote:
I don't think the page should be passed in as necessary -- that will
make the interface unstable.  It's too common, in my experience, to need
to pass information about the request in as you flesh out your
component.  For instance, if you want to have browser compatibility, or
make something multilingual.

Now, that might just mean that components would get the page as part of
their constructor.  Or we could have something like a sub-servlet, where
components have an awake/respond/sleep cycle, and the components are
pooled and potentially reused.  The difference there being that the
component is generally (but not necessarily) supposed to be controlled
by a Pythonic interface (like the add and remove methods of the menu
component) -- so it's not quite the same as forwarding to another
servlet.  Not URL-controlled either.

I thought about putting Page in the constructor, but decided against it. You don't want a component to be tied to a page. You will probably only create the menu items once and display them on many different pages. With a tree component, the tree model might change, and so it should be seperate from the page.



Maybe such an interface would look like:

class Component:
    # __init__ is entirely specific to your component

def awake(self, servlet):
self._servlet = servlet
# and we also have direct accessors for requests, etc., # like Page (and a sleep, of course)


    def respond(self):
        # And here we do the actual work



Now, presumably repond will write to the response, though maybe there
should also be a way to get a string from the component.  Maybe putting
a fake response in would work -- in general I'd like it to be easier to
capture a response.  Or perhaps just defer it -- then at some point you
could merge the response, or inspect the response and get things out of
it (like headers, cookies, or the actual body).


Sub-servlets are a good idea. How about Component subclasses Page. Components can have child components. awake(), reponse() etc. are recursively called. There would be no need to change Page to work with the component architecture, its just an added layer.


class Component(Page):
    children = []
    # __init__ is entirely specific to your component

    def awake(self, transaction):
        for child in children:
           child.awake(transaction)

    def respond(self):
        for child in children:
           child.respond()




-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to