Thanks Jonathan!

What would be the mapping of, say, myapp.com/yoursitename/xyz?


yoursitename would be the first arg
I guess xyz would be the second arg - although it'd be handy if it could be
a controller or function!

Your suggestion solves my problem - I've just added:

functions=['admin', 'about', 'faq', 'accounts', 'etc']

to the dict for the app in routes.py and everything works (so far)!

As you suggest my index function in the default controller now handles the
args for /yoursitename etc just fine.

So all I need to do now is add all black-listed functions to that list of
values as I go along.... functional but not very elegant.

I was playing with Flask and I have to say its solution to routing is very
nice:

http://flask.pocoo.org/docs/quickstart/#routing

The use of variable names anywhere within the URL structure is very handy.
Anything like this possible in web2py?

On 21 March 2011 22:30, Jonathan Lundell <jlund...@pobox.com> wrote:

> On Mar 21, 2011, at 2:37 PM, Tom Atkins wrote:
> > I am designing an app with a URL structure like this:
> >
> > myapp.com/yoursitename
> >
> > 'yoursitename' is effectively an argument as there could be many sites
> and users are allowed to create their own sites. But I'd like it to be 'top
> level'.
> >
> > Then within yoursitename there will be URLs like this:
> >
> > myapp.com/yoursitename/dashboard
> > myapp.com/yoursitename/users
> > myapp.com/yoursitename/settings
> >
> > I have a black-list of reserved top level words (e.g. /admin /about /faq
> /account etc) that are not allowed to be chosen.  So the site will have
> controllers to expose pages like:
> >
> > myapp.com/faq
> > myapp.com/about
> >
> > My question is what's the best / most efficient way to serve
> /yoursitename and the associated controllers?
> >
> > (I hope that makes sense!)
>
> What would be the mapping of, say, myapp.com/yoursitename/xyz? As a
> fully-expanded web2py URL? What are the app/controller/functions?
>
> If I understand your requirement correctly, the new router logic will do
> what you want. You'll need to specify a functions list in order to enable
> removal of the default function from the URL. So the expanded URL would be:
>
> myapp.com/yoursitename/users ->
> myapp.com/app/default/index/yoursitename/users, so you'd have
> request.args=['yoursitename', 'users'], and your default function would
> decide what to do with it.
>
> /admin and the like could be functions (like /app/default/admin), in which
> case you'd want to say: functions=['admin', 'about', 'faq', 'accounts',
> 'etc'] in the router control dict, or they can be controllers.

Reply via email to