Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Static Private Attributes
kupu.plone.ReftextField.ReftextField Class Reference
Inheritance diagram for kupu.plone.ReftextField.ReftextField:
Inheritance graph
[legend]
Collaboration diagram for kupu.plone.ReftextField.ReftextField:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def set

Static Public Attributes

tuple security = ClassSecurityInfo()

Static Private Attributes

 __implements__ = TextField.__implements__
tuple _properties = TextField._properties.copy()

Detailed Description

Definition at line 13 of file ReftextField.py.


Member Function Documentation

def kupu.plone.ReftextField.ReftextField.set (   self,
  instance,
  value,
  kwargs 
)
Assign input value to object. If mimetype is not specified,
pass to processing method without one and add mimetype
returned to kwargs. Assign kwargs to instance.

Definition at line 29 of file ReftextField.py.

00029 
00030     def set(self, instance, value, **kwargs):
00031         """ Assign input value to object. If mimetype is not specified,
00032         pass to processing method without one and add mimetype
00033         returned to kwargs. Assign kwargs to instance.
00034         """
00035         if value is None:
00036             # nothing to do
00037             return
00038 
00039         TextField.set(self, instance, value, **kwargs)
00040 
00041         if isinstance(value, BaseUnit):
00042             # Baseunit: can occur when overriding atct text fields.
00043             value = value()
00044         if not isinstance(value, basestring):
00045             value.seek(0);
00046             value = value.read()
00047 
00048         # build list of uids from the value here
00049         uids = [ m.group('uid') for m in UID_PATTERN.finditer(value) ]
00050         uids = dict.fromkeys(uids).keys() # Remove duplicate uids.
00051 
00052         tool = getToolByName(instance, REFERENCE_CATALOG)
00053 
00054         relationship = self.relationship
00055         if relationship is None:
00056             relationship = self.__name__
00057 
00058         targetUIDs = [ref.targetUID for ref in
00059                       tool.getReferences(instance, relationship)]
00060 
00061         add = [v for v in uids if v and v not in targetUIDs]
00062         sub = [t for t in targetUIDs if t not in uids]
00063 
00064         # tweak keyword arguments for addReference
00065         addRef_kw = kwargs.copy()
00066         addRef_kw.setdefault('referenceClass', self.referenceClass)
00067         if addRef_kw.has_key('schema'): del addRef_kw['schema']
00068 
00069         for uid in add:
00070             __traceback_info__ = (instance, uid, value, targetUIDs)
00071             try:
00072                 # throws ReferenceException if uid is invalid
00073                 tool.addReference(instance, uid, relationship, **addRef_kw)
00074             except ReferenceException:
00075                 pass
00076         for uid in sub:
00077             tool.deleteReference(instance, uid, relationship)
00078 
00079 #         print "Result was:",[ref.targetUID for ref in
00080 #                       tool.getReferences(instance, relationship)]
00081 #         print "Objects:",[ref.getTargetObject() for ref in
00082 #                       tool.getReferences(instance, relationship)]

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

kupu.plone.ReftextField.ReftextField.__implements__ = TextField.__implements__ [static, private]

Definition at line 14 of file ReftextField.py.

tuple kupu.plone.ReftextField.ReftextField._properties = TextField._properties.copy() [static, private]

Definition at line 16 of file ReftextField.py.

tuple kupu.plone.ReftextField.ReftextField.security = ClassSecurityInfo() [static]

Definition at line 26 of file ReftextField.py.


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