defernia.creds — User credentials

Defernia provides various (currently two) ways to sign in: Login with Facebook, Login with Twitter, and other services could be added in the future.

Credential abstracts each detail of various login services.

In order to define a new credential service, subclass Credential and then define typeid class attribute:

class WindowsLive(Credential):
    '''The Microsoft's legendary SSO (single sign on) service,
    was Passport before.


    typeid = ''

Note that typeid should be the service’s canonical domain name such as ''. This attribute will be internally used for service identifier.

class defernia.creds.Credential(**kwargs)

Bases: sqlalchemy.ext.declarative.api.Base

Defernia user credentials.

typeid = NotImplemented

The class attribute to be defined for concrete subclasses. It is a default type of the class. It should be the service’s canonical domain name such as ''.


The foreign key id of user.


The owner.


The credential type e.g. '', ''. It should be the service’s canonical domain name.


The user identifier used in the service.


The extra data for the credential.


A class method that finds the subtype of the given typeid.

Parameters:typeid (basestring) – internally used typeid string e.g. ''
Returns:a subtype of Credential
Return type:type
Rairses :LookupError when cannot found the class
defernia.creds.list_types(mixin=<class 'defernia.creds.Credential'>)

Lists all credential types.

Parameters:mixin (type) – an optional mixin class filter. if it is present, lists only subclass of given mixin
Returns:a dictionary of credential types (keys are typeid strings)
Return type:dict
defernia.creds.data_property(key, doc=None)

Makes a descriptor that deals with data dictionary’s specific key.

class HongMinheeWebsite(Credential):
    typeid = ''
    gender = data_property('gender', "The ``'male'`` or ``'female'``.")
    birthday = data_property('birthday')
  • key – the key of data dictionary
  • doc (str) – an optional docstring

a descriptor for key

Return type:


class defernia.creds.PictureMixin(**kwargs)

Bases: defernia.creds.Credential

The credential mixin class for getting profile pictures.


The profile picture URL. To be overrided in the subclass. None if there’s no picture.

class defernia.creds.Facebook(**kwargs)

Bases: defernia.creds.PictureMixin

Login with Facebook.

class defernia.creds.Twitter(**kwargs)

Bases: defernia.creds.PictureMixin

Login with Twitter.


The Twitter screen name.

Project Versions

Previous topic — Repositories directory

Next topic

defernia.objsimplify — Object simplifier for generic serialization

This Page