Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Private Attributes
validation.validators.IdValidator.IdValidator Class Reference

List of all members.

Public Member Functions

def __init__
def __call__

Public Attributes

 name
 title
 description

Static Private Attributes

tuple __implements__ = (ivalidator,)

Detailed Description

Definition at line 10 of file IdValidator.py.


Constructor & Destructor Documentation

def validation.validators.IdValidator.IdValidator.__init__ (   self,
  name,
  title = '',
  description = '' 
)

Definition at line 13 of file IdValidator.py.

00013 
00014     def __init__( self, name, title='', description=''):
00015         self.name = name
00016         self.title = title or name
00017         self.description = description
    

Member Function Documentation

def validation.validators.IdValidator.IdValidator.__call__ (   self,
  id,
  instance,
  args,
  kwargs 
)

Definition at line 18 of file IdValidator.py.

00018 
00019     def __call__(self, id, instance, *args, **kwargs):
00020         try:
00021             # try to use the check_id script of CMFPlone
00022             check_id = aq_get(instance, 'check_id', None, 1)
00023             if check_id is None:
00024                 raise AttributeError('check_id script not found')
00025             return check_id(id, required=kwargs.get('required', 0)) or 1
00026         except AttributeError:
00027             # space test
00028             if ' ' in id:
00029                 return 'Spaces are not allowed in ids'
00030             
00031             # in parent test
00032             parent = aq_parent(aq_inner(instance))
00033             # If the id is given to a different object already
00034             if id in parent.objectIds() and getattr(aq_base(parent), id) is not aq_base(instance):
00035                 return 'Id %s is already in use' % id
00036             
00037             # objet manager test
00038             # XXX: This is f***ed
00039             try:
00040                 ObjectManager.checkValidId(self, id, allow_dup=1)
00041             except BadRequest, m:
00042                 return str(m)
00043             return 1


Member Data Documentation

tuple validation.validators.IdValidator.IdValidator.__implements__ = (ivalidator,) [static, private]

Definition at line 11 of file IdValidator.py.

Definition at line 16 of file IdValidator.py.

Definition at line 14 of file IdValidator.py.

Definition at line 15 of file IdValidator.py.


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