At 09:46 AM 6/27/2001 -0400, Clark C . Evans wrote:
>1. How do I check if the request is a get or post?

request.method()

as in:
         self.request().method()

http://webware.sourceforge.net/Webware/WebKit/Docs/Source/Summaries/HTTPRequest.py.html


>2. I'd rather pass my "object identifiers" and such
>    via url-rewriting instead of a query string.
>    How do I do this?  i.e.
>
>     serve?type=invoice&key=345 -> serve/invoice/345

This has been discussed before, but is not currently supported out of the 
box. Terrel was the big champion here. See:
http://www.ics.uci.edu/~tshumway/webware/

and more specifically:
http://www.ics.uci.edu/~tshumway/webware/urldecode.html

Obviously, you'll have to do some serious work to get this happening.


>3. How do I get a good uri for the current servlet
>    such that I can pass to it get values?  I added
>    these methods to my SitePage...

You should be able to use request.uri().


>4. How do I get a good uri for _another_ servlet?
>    I was thinking something like...
>      self.getServletURI("AnotherServlet",args)
>
>    Where args is optional (see "uri()" above...)

I just make the URI like so:
         self.sendRedirect("SomeoneElse?x=%i&y=%i" % (x, y))

You can also make use of request.adapterName() if you have some reason to.


>5. How do I call a method in another servlet... without
>    "forwarding".  I know I can "import" the class and
>    then put my shared code in a module function.  Any
>    other approaches?

The only approaches I use and recommend (in no particular order):

* Make an abstract FooPage class from which the two classes descend.

* Make a mix-in class. This is very similar to the one just above, but the 
point is that the mix-in is not part of the primary inheritance tree of 
your pages and can be used here and there as you need it. It adds methods 
where methods are needed.

* Make an independent Py module featuring functions or "global" data. 
Perhaps the data is initialized only once when the module is imported. This 
is can be nice because importing modules is threadsafe in Python.

* Use composition. e.g., import a class from a shared module and create an 
instance which your servlet keeps around and uses.

Well, that's all that comes to mind. I've been happy with and have used all 
4 techniques.


-Chuck


_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to