langdev.user — LangDev users

This module provides user and authentication facilities that is service-agnostic. Many services for LangDev can provide single sign on based on this module.

>>> sess = langdev.orm.Session()  
>>> sess.query(User).filter_by(login=u'dahlia')[0]  
<langdev.user.User id=1>
class langdev.user.User(**kwargs)

An user object.

LOGIN_PATTERN = <_sre.SRE_Pattern object at 0x35b92f0>

The re pattern that matches to valid login names.

EMAIL_PATTERN = <_sre.SRE_Pattern object at 0x35bf530>

The re pattern that matches to valid email addresses.

id

Unique primary key.

login

Login name.

password_hash

Hashed password.

name

Screen name.

email

Email address.

url

His/her website.

created_at

(datetime.datetime) Registered time.

validate_login(key, login)

Validates the login name format.

Raises :ValueError when it’s invalid
validate_email(key, email)

Validates the email format.

Raises :ValueError when it’s invalid
password

Password.

class langdev.user.Password(hash_string)

Tests two passwords’ equality. It overloads == and != operators. Stripped password string can be an operand.

>>> u = User(login=u'test-for-password',
...          name=u'Test for password',
...          password=u'password string')
>>> u.password == u'password string'
True
>>> u.password != u'wrong password'
True

Of cource, Password can be an operand also:

>>> u.password == u.password
True
>>> u.password != u.password
False
Parameters:hash_string (str) – a hashed password string
ENCODING = 'utf-8'

UTF-8 by default.

hash_algorithm()

Hash algorithm. MD5 is used.

hash_string = None

Hashed password string.

Project Versions

Previous topic

langdev.orm — Object-relational mapping powered by SQLAlchemy

Next topic

langdev.forum — LangDev forum

This Page