[python] cherrypy + autorizace

radek na smidl.info radek na smidl.info
Pátek Duben 20 11:40:27 CEST 2007


Ahoj,

ja pouzivam toto: 
http://tools.cherrypy.org/attachment/wiki/PasswordProtectedPages/check.py

Samozrejme je to treba prizpusobit verzi CherryPy (toto je navod pro 
2.0), ale to je docela snadne.

Radek

-------- Original Message  --------
Subject: [python] cherrypy + autorizace
From: Vladislav Ludík <vlada na ludik.cz>
To: python na py.cz
Date: Wed Apr 18 2007 13:00:55 GMT+0200 (CEST)
> Hledám jednoduchou monost oveného pístupu na mnou vytváený web. 
> Pístup me být souasn více. Nael jsem napíklad:
>
> /import userauth
> from userauth import authorize, UserAuth
> import cherrypy
> import os
>
> class Root:
>     @cherrypy.expose
>     def index(self):
>         return "This is always accessible by anyone."
>
> class Members(UserAuth):
>     """ Unless otherwise stated (secret()), no pages under this
>         module will be viewable by any member outside of the
>         members and admins groups.
>     """
> _db = 'sqlite:' + os.path.abspath('filename.db')
> _authorized = ['members', 'admins']
> _unauthorized = '/login'
> @cherrypy.expose
> def index(self):
>     return "You're only here if you are a member!"
> @authorize(['secret'], '/nowhere')
> @cherrypy.expose
> def secret(self):
>     # It would work to just make this another section all-together, but
>     # it could be useful...
>     return "Only members of secret can access this..."
> cherrypy.root = Root()
> cherrypy.root.members = Members()
>
> /Nenael jsem vak modul userauth. Pome mi nkdo s tímto problémem?
>
> Pouívám Linux s právy root + Appache + mysql
>
> Díky
> _______________________________________________
> Python mailing list
> Python na py.cz
> http://www.py.cz/mailman/listinfo/python
>   

_______________________________________________
Python mailing list
Python na py.cz
http://www.py.cz/mailman/listinfo/python
------------- dal¹í èást ---------------
AdmID:64A48D2733E7D8C6D856DBFC192BAF02


Další informace o konferenci Python