Package enomalism2 :: Module identity
[hide private]

Module identity

Holds abstractions related to Enomalism users and groups.


Requires:

Status: Stable

Classes [hide private]
  Visit
Abstraction representing a visit to Enomalism by some client.
  VisitIdentity
An abstraction that links a visit to a user.
  PermissionsMixin
Mixing class that has permissions handling.
  EnomalismUser
An abstraction representing an Enomalism user.
  EnomalismGroup
An abstraction representing an Enomalism group.
Functions [hide private]
 
auth()
enomalism2.identity.EnomalismUser
get()
Special user getter.
Function
lockwrap(fn)
Defines a decorator that wraps the specified function in a lock.
 
validate_permission(_uuid, permission)
Confirm that the current enomalism user has the specified permission on the specified uuid.
Variables [hide private]
tubogears.database.PackageHub hub = PackageHub('enomalism2')
The Enomalism database connection hub.
turbogears.database.PackageHub __connection__ = PackageHub('enomalism2')
The actual database connection.
thread.allocate_lock plocker = allocate_lock()
The locker.
Function Details [hide private]

get()

 

Special user getter. Can be used to replace turbogears.identity.user.current in order to work properly in background threads that are not part of the web request queue. Basically, when BG threads like a valet job are run, the request is long gone, along with identity. Transaction.run_inside puts some thread local stuff together so we know who ran it, so we can use that to get the correct user.

Example usage:

>>> from enomalism2 import identity
>>> identity.get()
Returns: enomalism2.identity.EnomalismUser
The current user.
Raises:
  • None - No exceptions are raised by this method.

Status: Stable

lockwrap(fn)

 

Defines a decorator that wraps the specified function in a lock.

Example usage:

>>> from enomalism2 import identity
>>> @identity.lockwrap
... def myfunc(): pass
Parameters:
  • fn (Function) - The function we are decorating.
Returns: Function
The modified function that is now wrapped in a lock.
Raises:
  • None - No exceptions are raised by this method.

Status: Stable

validate_permission(_uuid, permission)

 

Confirm that the current enomalism user has the specified permission on the specified uuid. If the user does not have permission, a e2_permission_error exception is raised.

Example usage:

>>> from enomalism2 import identity
>>> from enomalism2.exceptions import E2PermissionError
>>> try:
...     identity.validate_permission('123', 'c')
... except E2PermissionError:
...     print 'Permission Denied!'
Parameters:
  • _uuid (Str) - The uuid of the resource to check permissions on.
  • permission (String) - The permission to validate.