yes. For example:
routes_in = [
('/$yoursitename/users','/init/default/users/$yoursitename'),
]
the optionally
@request.restful()
def users():
def GET(yoursitename):
return dict(message='your site name is: '+yoursitename)
return locals()
On Mar 23, 2011, at 8:31 AM, Anthony wrote:
> Massimo, I think Tom was referring to Flask's ability to include an arg at an
> arbitrary place in the URL path (e.g., '/<yoursitename>/users'), not the
> ability to specify the routes via decorators. I think the former *can* be
> achieved in web2py using the pattern-based rewrite system, right?
>
> Anthony
>
> On Wednesday, March 23, 2011 9:17:31 AM UTC-4, Massimo Di Pierro wrote:
> This is not an option in web2py because the controller is executed
> after the requests arrives not imported before (as in Flask). Anyway,
> that works better for simple apps but becomes a mess if you have many
> functions because the routing info is scattered all over the place.
> Moreover - when it comes to rest - it requires that you use the same
> function for multiple methods (GET/POST/etc) by using multiple
> decorators or that you use different functions with different names to
> handle different names (I do not like that).
>
> On Mar 22, 3:13 am, Tom Atkins <[email protected]> wrote:
> > I might be being naive here but in Flask I can do:
> >
> > @app.route('/<yoursitename>/users')
> > ... def editusers(yoursitename): pass
> >
> > print url_for('editprofile', yoursitename='Supersite')
> >
> > gives:
> >
> > /Supersite/users
> >
> > On 22 March 2011 05:23, Jonathan Lundell <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > On Mar 21, 2011, at 7:44 PM, Indra Gunawan wrote:
> >
> > > Agree, Flask way looks more elegant (see Variable Rules). It could be
> > > nice
> > > if this way also exists on Web2Py.
> >
> > > On 22 March 2011 06:05, Tom Atkins <[email protected]> wrote:
> >
> > >> 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?
> >
> > > Flask doesn't really allow variable names anywhere; near as I can tell
> > > they're a considerably restricted version of web2py's args list.