google-code-export / gaeframework

Automatically exported from code.google.com/p/gaeframework
0 stars 0 forks source link

Create reverce urls function #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Idea
Use function {% url app_name action_name parameters %} to generate correct url 
to application action.

We have urls.yaml file in the each application where we see routing like this:

- url: /page(?P<page>[0-9]+)
  run: articles_list

We need create function url() for create url from application handler and 
parameters.

In this case, we can call: url("articles_list", {"page": 10}) and in result we 
should see "/articles/page10".

Also we can get url to other application by adding application name before 
handler name like this: url("articles.articles_list", {"page": 10})

Recommendations
Function url(action_name, ...params...) have one or more parameters:
 * "application name"
 * "action_name" - name of action for given application
 * and list of parameters for this action

Than, we search all patterns in urls mapping, and get first pattern with given 
parameters. If pattern not found than we raise exception.

See also
Django reverse() function 
http://docs.djangoproject.com/en/dev/topics/http/urls/#reverse

Original issue reported on code.google.com by anton.danilchenko on 28 Jan 2011 at 3:48

GoogleCodeExporter commented 9 years ago

Original comment by anton.danilchenko on 7 Feb 2011 at 9:06

GoogleCodeExporter commented 9 years ago

Original comment by anton.danilchenko on 7 Feb 2011 at 9:07

GoogleCodeExporter commented 9 years ago
Should be added people readable urls like this:
{% url "go back" %}
{% url "previous page" %}
{% url "current page" %}

And linked to application action like this:
{% url "blog.create_entity" %}
{% url "blog.edit_entity" entity.key.name %}

Original comment by anton.danilchenko on 7 Feb 2011 at 9:10

GoogleCodeExporter commented 9 years ago
Was implemented

Original comment by anton.danilchenko on 16 Feb 2011 at 8:53