On Thu, 2003-03-06 at 13:52, Jim Bucher wrote:
> I like the idea of using components for reusability. But interfaces,
> inheritance and mixins seem to be a complex solution. How about doing it
> this way. Make the component a class that stands on its own. When the
> component needs to interact with a page, session, etc then give it
> access to those objects. It seems to be simple. What do you think?
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.
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).
--
Ian Bicking [EMAIL PROTECTED] http://colorstudy.com
4869 N. Talman Ave., Chicago, IL 60625 / 773-275-7241
"There is no flag large enough to cover the shame of
killing innocent people" -- Howard Zinn
-------------------------------------------------------
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