Re: [python] cherrypy + autorizace

2017-03-31 Tema obsahu martin.stibor...@gmail.com
Zdravím, fajn návod. Ale jak můžu zamknout celou třídu ?
___
Python mailing list
python@py.cz
http://www.py.cz/mailman/listinfo/python

Visit: http://www.py.cz


Re: [python] cherrypy + autorizace

2007-05-26 Tema obsahu [EMAIL PROTECTED]
Zdravím, fajn návod. Ale jak můžu zamknout celou třídu ?
___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python


Re: [python] cherrypy + autorizace

2007-04-20 Tema obsahu Vladislav Ludík
Skvělé, už jsem to rozběhal. Díky za pomoc.

VL#!/usr/bin/python2.4

import cherrypy

class Login:
def check(cls, fn):
def _check(self, *args, **kwargs):
if cherrypy.session.has_key('userid'):
# User is logged in; allow access
return fn(self, *args, **kwargs)
else:
# User isn't logged in yet.
# See if the user just tried to log in
try:
submit = kwargs['login']
email = kwargs['loginEmail']
password = kwargs['loginPassword']
except KeyError:
# No, this wasn't a login attempt.  Send the user to
# the login "page".
return self.loginPage(cherrypy.url())

# Now look up the user id by the email and password
userid = self.getUserId(email, password)
if userid is None:
# Bad login attempt
return self.loginPage(cherrypy.url(), 'Invalid email 
address or password.')
# User is now logged in, so retain the userid and show the 
content
cherrypy.session['userid'] = userid
return fn(self, *args, **kwargs)
return _check
check = classmethod(check)

def getUserId(self, email, password):
'''Simple function to look up a user id from email and password.
Naturally, this would be stored in a database rather than
hardcoded, and the password would be stored in a hashed format
rather than in cleartext.

Returns the userid on success, or None on failure.
'''

accounts = {('[EMAIL PROTECTED]', 'foo'): 'vlada'}

return accounts.get((email,password), None)

def loginPage(self, targetPage, message=None):
'''Return a login "pagelet" that replaces the regular content if
the user is not logged in.'''
result = []
result.append('Sitename Login')
if message is not None:
result.append('%s' % message)
result.append('' % targetPage)
result.append('Email Address: ')
result.append('Password: ')
result.append('')
result.append('')
return '\n'.join(result)

def logOut(self):
'''Log Out.'''
del cherrypy.session['userid']
return 'You are no more logged in' + self.index()
logOut.exposed = True

class Page(Login):

def index(self):
return '''SiteName
Home Page
Public Page
Private Page (registered users 
only)
'''
index.exposed = True

def public(self):
return '''SiteName
Public Page
Go back home'''
public.exposed = True

def private(self, *args, **kwargs):
return '''SiteName
Private Page
Log Out
Go back home'''
private = Login.check(private)
private.exposed = True

root = Page()
cherrypy.tree.mount(root, '/')


if __name__ == "__main__":

import os.path
cherrypy.config.update(os.path.join(os.path.dirname(__file__), 
'check-1.conf'))
cherrypy.server.quickstart()
cherrypy.engine.start()

check-1.conf
Description: Binary data
___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python

Re: [python] cherrypy + autorizace

2007-04-20 Tema obsahu Jan Jakubuv
dobry den,

zrejme pouzivate novejsi verzi cherrypy nez pro kterou byl modul
urcen. musite si skript upravit podle toho jakou verzi cherrypy
pouzivate.
1) verze 2.2 http://www.cherrypy.org/wiki/WhatsNewIn22
2) verze 3.0 http://www.cherrypy.org/wiki/WhatsNewIn30
zmena pro verzi 2.2. je trivialni pro 3.0 by mela byt take jednoducha
(podle tvrzeni na jejich strankach) viz
http://www.cherrypy.org/wiki/UpgradeTo30

h.

2007/4/19, Vladislav Ludík <[EMAIL PROTECTED]>:
> Zkouším a stále nějaký problém to spustit:
> Např. v cherrypy jsem modul filtr nenašel:
> /Traceback (most recent call last):
> from multiauth import auth
>   File "C:\Python24\lib\site-packages\multiauth\auth.py", line 4, in ?
> from cherrypy.lib.filter.basefilter import BaseFilter
> ImportError: No module named filter.basefilter
> /
> díky VL
>
> ___
> Python mailing list
> Python@py.cz
> http://www.py.cz/mailman/listinfo/python
>
>
___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python


Re: [python] cherrypy + autorizace

2007-04-20 Tema obsahu radek
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 <[EMAIL PROTECTED]>
To: python@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@py.cz
> http://www.py.cz/mailman/listinfo/python
>   

___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python
AdmID:64A48D2733E7D8C6D856DBFC192BAF02
___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python

Re: [python] cherrypy + autorizace

2007-04-20 Tema obsahu Radek Smidl
To zmen na:
cherrypy.session['userid']

Je to normalni slovnik, viz. treba tady 
http://cherrypy.org/wiki/CherryPySessions.

Radek


 Original Message  
Subject: Re:[python] cherrypy + autorizace
From: Vladislav Ludík <[EMAIL PROTECTED]>
To: Konference PyCZ 
Date: Fri Apr 20 2007 11:17:54 GMT+0200 (CEST)
> Dne 20 Duben 2007, 10:37, Radek Smidl napsal(a):
>   
>> To je prave ta zmena :-)
>>
>> Normalne naimportuj cherrypy:
>> import cherrypy
>>
>> Tohle:
>> cpg.request.sessionMap.has_key('userid')
>> zmen na:
>> cherrypy.session.has_key('userid')
>>
>> Tohle:
>> cpg.request.path
>> na:
>> cherrypy.url()
>>
>> A main na neco jako:
>> if __name__ == "__main__":
>> root = Site()
>> cherrypy.tree.mount(root, '/')
>>
>> cherrypy.server.quickstart()
>> cherrypy.engine.start()
>>
>> Radek
>> 
>
> A ještě mě tam zůstalo:
>
> cpg.request.sessionMap['userid'] = userid
>
> Ty sessions neovládám. Díky
>
> ___
> Python mailing list
> Python@py.cz
> http://www.py.cz/mailman/listinfo/python
>   

___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python


Re: [python] cherrypy + autorizace

2007-04-20 Tema obsahu Vladislav Ludík

Dne 20 Duben 2007, 10:37, Radek Smidl napsal(a):
> To je prave ta zmena :-)
>
> Normalne naimportuj cherrypy:
> import cherrypy
>
> Tohle:
> cpg.request.sessionMap.has_key('userid')
> zmen na:
> cherrypy.session.has_key('userid')
>
> Tohle:
> cpg.request.path
> na:
> cherrypy.url()
>
> A main na neco jako:
> if __name__ == "__main__":
> root = Site()
> cherrypy.tree.mount(root, '/')
>
> cherrypy.server.quickstart()
> cherrypy.engine.start()
>
> Radek

A ještě mě tam zůstalo:

cpg.request.sessionMap['userid'] = userid

Ty sessions neovládám. Díky

___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python


Re: [python] cherrypy + autorizace

2007-04-20 Tema obsahu Radek Smidl
To je prave ta zmena :-)

Normalne naimportuj cherrypy:
import cherrypy

Tohle:
cpg.request.sessionMap.has_key('userid')
zmen na:
cherrypy.session.has_key('userid')

Tohle:
cpg.request.path
na:
cherrypy.url()

A main na neco jako:
if __name__ == "__main__":
root = Site()
cherrypy.tree.mount(root, '/')

cherrypy.server.quickstart()   
cherrypy.engine.start()

Radek

---- Original Message  ----
Subject: Re:[python] cherrypy + autorizace
From: Vladislav Ludík <[EMAIL PROTECTED]>
To: Konference PyCZ 
Date: Fri Apr 20 2007 10:26:26 GMT+0200 (CEST)
> Dne 20 Duben 2007, 9:22, Radek Smidl napsal(a):
>   
>> 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
>>
>> 
> Zkouším ledacos, ale stále mi nějaký modul chybí:
>
> Traceback (most recent call last):
>   File "\check.py", line 1, in ?
> from cherrypy import cpg
> ImportError: cannot import name cpg
>
> ___
> Python mailing list
> Python@py.cz
> http://www.py.cz/mailman/listinfo/python
>   

___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python


Re: [python] cherrypy + autorizace

2007-04-20 Tema obsahu Vladislav Ludík

Dne 20 Duben 2007, 9:22, Radek Smidl napsal(a):
> 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
>
Zkouším ledacos, ale stále mi nějaký modul chybí:

Traceback (most recent call last):
  File "\check.py", line 1, in ?
from cherrypy import cpg
ImportError: cannot import name cpg

___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python


Re: [python] cherrypy + autorizace

2007-04-20 Tema obsahu Radek Smidl
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 <[EMAIL PROTECTED]>
To: python@py.cz
Date: Wed Apr 18 2007 13:00:55 GMT+0200 (CEST)
> Hledám jednoduchou možnost ověřeného přístupu na mnou vytvářený web. 
> Přístupů může být současně více. Našel 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()
>
> /Nenašel jsem však modul userauth. Pomůže mi někdo s tímto problémem?
>
> Používám Linux s právy root + Appache + mysql
>
> Díky
> ___
> Python mailing list
> Python@py.cz
> http://www.py.cz/mailman/listinfo/python
>   

___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python


Re: [python] cherrypy + autorizace

2007-04-19 Tema obsahu Tomáš Brabenec
Vladislav Ludík napsal(a):
> A nějaké konkrétní řešení bys mi mohl ukázat?
>   
Jaky konkretni reseni mas na mysli, podivej se do jakehokoliv tutorialu
(Python, PHP, ASP, ) vsude jsou autorizace vicemene reseny stejne.
Ja osobne pouzivam v PHP i Pythonu (a je jedno jestli CherryPy, Webware,
Pylons, ...) v podstate stejny zpusob.

TB

___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python


Re: [python] cherrypy + autorizace

2007-04-19 Tema obsahu Vladislav Ludík
Ale sessions neumím zatím používat, můžu požádat o pomoc?

Díky VL


Lukoko napsal(a):
> V CherryPy jsem si psal autentizaci vzdycky sam pomoci sessions 
> proste pokud se ti user formularem na strance prihlasis, tak zahajis
> sessoin a ukladas si tam ze je prihlasenej. Kdyz se chce odhlasit, tak
> proste zrusis tu session a uz neni prihlasenej ;-)
___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python


Re: [python] cherrypy + autorizace

2007-04-19 Tema obsahu Vladislav Ludík
Zkouším a stále nějaký problém to spustit:
Např. v cherrypy jsem modul filtr nenašel:
/Traceback (most recent call last):
from multiauth import auth
  File "C:\Python24\lib\site-packages\multiauth\auth.py", line 4, in ?
from cherrypy.lib.filter.basefilter import BaseFilter
ImportError: No module named filter.basefilter
/
díky VL

___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python


Re: [python] cherrypy + autorizace

2007-04-19 Tema obsahu Jan Jakubuv
dobry den,

take muzete zkusit toto:

http://tools.cherrypy.org/wiki/MultiAuth
http://projects.dowski.com/projects/multiauth
http://www.netwinsite.com/authent/multiauth.htm

honza.

18.4.07, Vladislav Ludík <[EMAIL PROTECTED]>:
> /Lukoko napsal(a)://
>
> /
>
> //V CherryPy jsem si psal autentizaci vzdycky sam pomoci sessions 
> proste pokud se ti user formularem na strance prihlasis, tak zahajis
> sessoin a ukladas si tam ze je prihlasenej. Kdyz se chce odhlasit, tak
> proste zrusis tu session a uz neni prihlasenej ;-)//
>
> A nějaké konkrétní řešení bys mi mohl ukázat?
> ___
> Python mailing list
> Python@py.cz
> http://www.py.cz/mailman/listinfo/python
>
>
___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python


Re: [python] cherrypy + autorizace

2007-04-18 Tema obsahu Vladislav Ludík
/Lukoko napsal(a)://

/

//V CherryPy jsem si psal autentizaci vzdycky sam pomoci sessions 
proste pokud se ti user formularem na strance prihlasis, tak zahajis
sessoin a ukladas si tam ze je prihlasenej. Kdyz se chce odhlasit, tak
proste zrusis tu session a uz neni prihlasenej ;-)//

A nějaké konkrétní řešení bys mi mohl ukázat?
___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python


Re: [python] cherrypy + autorizace

2007-04-18 Tema obsahu Lukoko
V CherryPy jsem si psal autentizaci vzdycky sam pomoci sessions 
proste pokud se ti user formularem na strance prihlasis, tak zahajis
sessoin a ukladas si tam ze je prihlasenej. Kdyz se chce odhlasit, tak
proste zrusis tu session a uz neni prihlasenej ;-)

___
Python mailing list
Python@py.cz
http://www.py.cz/mailman/listinfo/python