Back to index

plone3  3.1.7
Public Member Functions | Public Attributes
plone.app.vocabularies.users.UsersSource Class Reference

List of all members.

Public Member Functions

def __init__
def __contains__
def search
def get

Public Attributes

 context
 users

Detailed Description

  >>> from plone.app.vocabularies.tests.base import DummyContext
  >>> from plone.app.vocabularies.tests.base import DummyTool

  >>> context = DummyContext()

  >>> tool = DummyTool('acl_users')
  >>> users = ('user1', 'user2')
  >>> def getUserById(value, default):
  ...     return value in users and value or default
  >>> tool.getUserById = getUserById
  >>> def searchUsers(fullname=None):
  ...     return [dict(userid=u) for u in users]
  >>> tool.searchUsers = searchUsers
  >>> context.acl_users = tool

  >>> source = UsersSource(context)
  >>> source
  <plone.app.vocabularies.users.UsersSource object at ...>

  >>> len(source.search(None))
  2

  >>> 'user1' in source, 'noone' in source
  (True, False)

  >>> source.get('user1'), source.get('noone')
  ('user1', None)

Definition at line 11 of file users.py.


Constructor & Destructor Documentation

Definition at line 44 of file users.py.

00044 
00045     def __init__(self, context):
00046         self.context = context
00047         self.users = getToolByName(context, "acl_users")

Here is the caller graph for this function:


Member Function Documentation

Return whether the value is available in this source

Definition at line 48 of file users.py.

00048 
00049     def __contains__(self, value):
00050         """Return whether the value is available in this source
00051         """
00052         if self.get(value) is None:
00053             return False
00054         return True

Here is the call graph for this function:

def plone.app.vocabularies.users.UsersSource.get (   self,
  value 
)

Definition at line 58 of file users.py.

00058 
00059     def get(self, value):
00060         return self.users.getUserById(value, None)
00061 

Definition at line 55 of file users.py.

00055 
00056     def search(self, query):
00057         return [u['userid'] for u in self.users.searchUsers(fullname=query)]
        

Here is the caller graph for this function:


Member Data Documentation

Definition at line 45 of file users.py.

Definition at line 46 of file users.py.


The documentation for this class was generated from the following file: