Hi Astrid,
The point is mostly neatness - the hierarchical notation in the second
example makes more sense for certain types of URLs than query
parameters, particularly when it's being used to access distinct
resources that happen to use the same handlers internally - it's good
practice to isolate your URL structure from how you handle requests.
For more details, see Wikipedia's article on REST:
http://en.wikipedia.org/wiki/REST
As far as encoding and decoding goes, creating the URLs is much the
same as with any other scheme: Simply use your preferred method of
string construction, be it concatenation, templates, or '/'.join
(['index', '1', 'model', '2'). When it comes to interpreting URLs, the
default framework's support for regular expression groups can be
handy. If you define the following regular expression in your handler
map:
/index/(\d+)/model/(\d+)
Then your handler will get called with two arguments for the
parenthesized groups, like so:
class MyHandler(webapp.Handler):
def get(self, indexnum, modelnum):
# Note that indexnum and modelnum are strings, so you should call
int() on them first.
-Nick Johnson
On Apr 16, 1:02 am, "astrid.thuec...@googlemail.com"
wrote:
> I've seen some people hosting on the appengine to encode their urls
> for data from the datastore (non-static data) in the following way:
>
> http://abc.appspot.com?index=2&model=1becomes something
> likehttp://abc.appspot.com/index/2/model/1
>
> whats the point in doing that and how can I easily do it? Is there a
> function for that that encodes and decodes those urls?
>
> Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---