List Info

Thread: how to mounting application under url /user//




how to mounting application under url /user/<login_user>/
user name
2006-12-12 10:29:00
Hi all.
Can anyone tell mi please how mount my aplication under url
like
www.myaps.com/user/<user_login>/

For now my apps are mounted like that:
cherrypy.root = PublicContainer()
cherrypy.root.user = PersonalContainer()
cherrypy.server.start()
but I must change url for logged user, so it can't be
www.myaps.com/user/method
but it must be like this
 www.myaps.com/user/<user_login>/method
Methods are common for every user (exacly class
PersonalContainer is
common for every user), I just only want to called that
method from
different url's for each user
 e.g. www.myaps.com/user/smith/method,
www.myaps.com/user/gregor/method
What is the best way to do this?
I read something about virtual filter, and tryed to use it,
but I
didn't get any results.
I'm using cherrypy 2.2.1
Thanks for any help
Gregor


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en

-~----------~----~----~----~------~----~------~--~---

how to mounting application under url /user/<login_user>/
user name
2006-12-12 15:54:11
On 12/12/06, gregor <GSlusarekgmail.com> wrote:
>
> Hi all.
> Can anyone tell mi please how mount my aplication under
url like
> www.myaps.com/user/<user_login>/

[snip]

> Methods are common for every user (exacly class
PersonalContainer is
> common for every user), I just only want to called that
method from
> different url's for each user
>  e.g. www.myaps.com/user/smith/method,
> www.myaps.com/user/gregor/method
> What is the best way to do this?

I would suggest using a callable "default" class.

class UrlActionDispatcher(object):
    exposed = True
    def __call__(self, user, action, **params):
        meth = getattr(self, action, None)
        if meth and getattr(meth, 'exposed', False):
            return meth(user, **params)
        else:
            raise cherrypy.NotFound

    def preferences(self, user):
        return preferences_for(user).html()
    preferences.exposed = True

Something along those lines.  Then...

cherrypy.root.user.default = UrlActionDispatcher()

Then, a request to www.yourapps.com/user/guido/preferences
would call
the preferences method of UrlActionDispatcher with
"guido" as the
parameter.

You could even make the UrlActionDispatcher class a bit more
generic
and only provide a  __call__ method and then inherit from it
anywhere
you wanted this sort of dispatching...

class ArticleActions(UrlActionDispatcher):
    def view(...):


Does that make sense?

Christian
http://www.dowski.com

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en

-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )