flexible routes

2 views
Skip to first unread message

eggy_

unread,
Nov 9, 2009, 5:18:37 AM11/9/09
to web2py-users
Hello,

I want to divide my controller logic up into packages, where the
controller part will be 'package/subpackage/module' instead of just
'module'. Currently, I can only use a module as the controller, and
the corresponding view will be a directory with the module's name,
containing a bunch of views that correspond with the request functions
in the controller. In this case I want the view files corresponding
with the request functions in 'module' to be located in 'applications/
myapp/views/package/subpackage/module/'.

regards,

Mark

mdipierro

unread,
Nov 9, 2009, 10:37:28 AM11/9/09
to web2py-users
Not sure I understand. You can put modules in modules/ and you can
have a subfolder structure.
You can also have a subfolder structure in views but your actions have
to be explicit on which view to use (response.view="....html").

controllers have to be files without a subfolder structure.

Timbo

unread,
Nov 9, 2009, 10:56:17 AM11/9/09
to web2py-users
Because web2py exec()s controllers rather than importing them,
packages are not currently an option. Whats you're reason for needing
packages? Maybe we can help you find a better solution.

On Nov 9, 4:18 am, eggy_ <markflorisso...@gmail.com> wrote:

mdipierro

unread,
Nov 9, 2009, 11:03:29 AM11/9/09
to web2py-users
I do not understand what you mean by "packages". You can use python
"import whatevermodule.py"

eggy_

unread,
Nov 9, 2009, 1:02:05 PM11/9/09
to web2py-users
I guess the term 'package' is not really applicable. What I meant was
that I want to have the ability to use subdirectories as part of the
controller. So that the controller part basically becomes
'somedirectory/somecontroller'. You can currently only have a
'somecontroller'.

mdipierro

unread,
Nov 9, 2009, 1:10:08 PM11/9/09
to web2py-users
This would require a change in the URL convention and could make
dispatching slower.
Why do you need this? I am not saying no but I need to be convinced.

eggy_

unread,
Nov 9, 2009, 1:22:46 PM11/9/09
to web2py-users
I don't "need" it as such, but I want to group certain related parts
of the web application that don't necessarily need to be in the same
controller. This would be akin to a python package structure. Of
course, in python code, any program written as a set of packages and
modules can be written as a sole set of modules or even just one
module, but that doesn't mean that would be a good, logical, approach.
The same logic could be applied to web2py controllers.

Christopher Steel

unread,
Nov 11, 2009, 4:41:51 PM11/11/09
to web2py-users
Is this what you mean?

Models

db.py
db_news.py
db_wiki.py

Controllers

/default.py
/news.py
/wiki.py
Reply all
Reply to author
Forward
0 new messages