how do I get the URI from a request data?

24 views
Skip to first unread message

shingle

unread,
Jun 17, 2008, 10:33:30 PM6/17/08
to Google App Engine
Hi,

In google's example http://code.google.com/appengine/docs/gettingstarted/handlingforms.html

there are two RequestHandlers MainPage, and Guestbook. Is it possible
to just create one RequestHandler and pass the request data to a
MainPage and Guestbook instances?

somewhat like, (pseudo code)
-------------------------------------------
MainRequestHandler

def get(self)

uri = GetURI --- how do i get this
URI(URI req. by the user)?

if uri == MainPage URI
MainPage instance.get(self) --- can self environement be
passed?

else
Guestbook instance.get(self) --- can self environement be
passed?
--------------------------------------------------

The main reason why I am doing this is to be able to define
RequestHandlers in different files. I don't want to place all
RequestHandlers in one place. And I don't know if this is the
conventional way of doing it. I am not a Python programmer and
neither an experienced web programmer. But I want to build a web app
and hopefully start with a nice designed web app.

Can anybody help me? Thanks!

Devraj Mukherjee

unread,
Jun 18, 2008, 1:58:52 AM6/18/08
to google-a...@googlegroups.com
Hi,

It is possible, but from what I can gather it will be a performance
hit. If you have multiple handlers then you can lazy load your modules
or files.

--
"I never look back darling, it distracts from the now", Edna Mode (The
Incredibles)

shingle

unread,
Jun 18, 2008, 6:55:58 AM6/18/08
to Google App Engine
Thanks,

Can you please explain further why it would be a performance hit? Is
it because of the files to be loaded where the RequestHandlers are
defined? Can you also explain further what's a "lazy load"? By the
way, how do I get the URI that the user has requested from a request
data?


like for ex.(pseudo code)

MainRequestHandler
def get(self)
uri = ??? --- how do i get this
from "self"???



On Jun 18, 1:58 am, "Devraj Mukherjee" <dev...@gmail.com> wrote:
> Hi,
>
> It is possible, but from what I can gather it will be a performance
> hit. If you have multiple handlers then you can lazy load your modules
> or files.
>
>
>
>
>
> On Wed, Jun 18, 2008 at 12:33 PM, shingle <peped...@yahoo.com> wrote:
>
> > Hi,
>
> > In google's examplehttp://code.google.com/appengine/docs/gettingstarted/handlingforms.html
> Incredibles)- Hide quoted text -
>
> - Show quoted text -

Mahmoud

unread,
Jun 18, 2008, 10:30:57 AM6/18/08
to Google App Engine
The path/uri/url passed to the handler, is :
self.request.path (which is a string)


For more information on how to handle request paths, see this post:
http://groups.google.com/group/google-appengine/browse_thread/thread/e18bc71b5cb1685e/e8e56748e830db1e?hl=en&lnk=gst&q=mahmoud#e8e56748e830db1e

and this article:
http://code.google.com/appengine/docs/webapp/running.html

-Mahmoud Arram

Manel

unread,
Jun 18, 2008, 10:28:41 AM6/18/08
to google-a...@googlegroups.com
self.request.url

from docs:

An instance of the Request class contains information about an incoming web request.

Request is provided by the google.appengine.ext.webapp module.

The Request class inherits from the WebOb Request class. For more information, see the WebOb documentation.



2008/6/18 shingle <pepe...@yahoo.com>:



--
manel
http://www.smaider.com

shingle

unread,
Jun 18, 2008, 1:37:03 PM6/18/08
to Google App Engine
Thank you very much guys!!! I will try both of your solns and as well
read the docs... :)

On Jun 18, 10:28 am, Manel <ma...@smaider.com> wrote:
> self.request.url
>
> from docs:
>
> An instance of the Request class contains information about an incoming web
> request.
>
> Request is provided by the google.appengine.ext.webapp module.
>
> The Request class inherits from the WebOb Request class. For more
> information, see the WebOb
> documentation<http://www.google.com/url?sa=D&q=http://pythonpaste.org/webob/referen...>
> .
>
> 2008/6/18 shingle <peped...@yahoo.com>:
> manelhttp://www.smaider.com- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages