On Wed, Dec 3, 2008 at 9:03 PM, Khaoz wrote:
> url_map = Map([
> Rule('/', endpoint='myapp.module1.views.list')
> ])
just a comment. i wanted to avoid long strings as end points, because
to build url's you would end with something like this in a template:
{{ url_for('myapp.module1.views.list', ...) }}
what i did was to create an extra map to register available endpoints
and their modules. so for example i register:
Rule('/', endpoint='module1/list')
(somewhere else i have a dict 'handlers' mapping 'module1/list' to a
tuple ('myapp.module1.views.list', 'ClassName'). then to match i do:
endpoint, args = url_adapter.match(path)
module_name, class_name = handlers[endpoint]
... and import the module/class that matched:
__import__(module_name)
cls = getattr(sys.modules[module_name], class_name)
ta-da! seems a bit too much maybe, but i like this setup. :-)
-- rodrigo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pocoo-libs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pocoo-libs?hl=en
-~----------~----~----~----~------~----~------~--~---