[bottlepy] Bottle equivalent of url_for function?

504 views
Skip to first unread message

felciano

unread,
May 17, 2010, 12:45:55 AM5/17/10
to bottlepy
Hi --

I need to embed a pointer to a view-based static file directory in my
templates, e.g. as the base path for serving up CSS files. Some
frameworks have a url_for method that will return the absolute URL for
a given view or endpoint (e.g. http://flask.pocoo.org/docs/api/#useful-functions-and-classes).
Is there a similar method in Bottle that I can use?

Thx,

Ramon

--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottle.paws.de/ for news and documentation.

Volodymyr GL

unread,
May 20, 2010, 2:52:27 PM5/20/10
to bottlepy
Bottle has no urlhelpers

On May 17, 7:45 am, felciano <felci...@gmail.com> wrote:
> Hi --
>
> I need to embed a pointer to a view-based static file directory in my
> templates, e.g. as the base path for serving up CSS files. Some
> frameworks have a url_for method that will return the absolute URL for
> a given view or endpoint (e.g.http://flask.pocoo.org/docs/api/#useful-functions-and-classes).

Marcel Hellkamp

unread,
May 20, 2010, 3:44:43 PM5/20/10
to bott...@googlegroups.com
Am Sonntag, den 16.05.2010, 21:45 -0700 schrieb felciano:
> Hi --
>
> I need to embed a pointer to a view-based static file directory in my
> templates, e.g. as the base path for serving up CSS files. Some
> frameworks have a url_for method that will return the absolute URL for
> a given view or endpoint (e.g. http://flask.pocoo.org/docs/api/#useful-functions-and-classes).
> Is there a similar method in Bottle that I can use?
>
> Thx,
>
> Ramon
>

There is some very basic support for this but it is neither documented
nor matured enough to be an official feature:

>>> import bottle
>>> @bottle.route('/test/:x/:y', name='test')
... def test(x,y):
... return '%x - %y' % (x,y)
...
>>> bottle.url('test', x='a', y='b')
'/test/a/b'


--
Mit freundlichen Grüßen
Marcel Hellkamp
Reply all
Reply to author
Forward
0 new messages