Request object or current url (url_for) access inside classes in lib
I'm trying to get a string of the cur开发者_如何学编程rent URL (either from the request object or a call to url_for) inside a class I wrote that resides in my projects lib directory. How do I do this? I tried to
request.url
and the request object is not accessible from within my class.
The request.url
is only accessible from inside a controller. I would suggest that the url is a parameter you hand down to your class (at construction-time or when calling the method). This will keep the concerns nicely separated.
Hope this helps.
精彩评论