Hi,
you can also use inline view declaration in place of decorators:
config.add_route('p1', '/p1')
config.add_view(Main, route_name='p1')
Combining this with the __import__ tool, you may achieve your goal quite
easily.
View configuration docs :
http://pyramid.readthedocs.org/en/latest/narr/viewconfig.html
That's the way you would configure urls with url dispatch
(http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/urldispatch.html).
With url dispatch, you necessarily need to declare both routes and views.
If you want to use a root factory you're talking about url traversal
(http://pyramid.readthedocs.org/en/latest/narr/traversal.html).
To understand the difference between both methods, you may have a look
at this page :
http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/routing/combining.html
--
TJEBBES Gaston
Majerti
http://www.majerti.fr
Le 03/06/2013 15:33, wilk a écrit :
> Hi,
>
> I use my own framework since more than ten years and see now that it's
> very similar with pyramid, of course with a lot less features. Now
> i would like to use a community framework to can share my web
> applications and stop to reinvent te wheel (wheel that did not exists
> when i began...).
>
> My first question is about routes. I use class based view with a regexp
> or direct matching and the name of my module.
>
> views/page1.py
> /page2.py
>
> routes = [('/p1', 'page1', ('/p2', 'page2))
>
> page1.py :
>
> class Main(Page):
> def __call__(self):
> ...
> return Response
>
>
> I wonder how i can translate this for pyramid.
> For the object Page, it's ok because i already use webob.
>
> I can do like that :
>
> from pyramid.view import view_config
>
>
> @view_config(route_name='p1')
> class Main(Page):
> ...
>
> config.add_route('p1', '/p1')
> config.scan()
>
> But i would like to avoid using decorator to don't need to update all my
> files (one for each view) or use add_route + add_view for each route.
>
> I think i need to do my own root_factory, but i could not achieve this.
>
> Or maybe there is a good reason to use decorator ? But i think it's
> better to have all routes configuration in the same place...
>
> Any hints for me ?
>
> Thanks and sorry for my bad english...
>
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.