Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes
CMFDiffTool.ATCompoundDiff.ATCompoundDiff Class Reference
Collaboration diagram for CMFDiffTool.ATCompoundDiff.ATCompoundDiff:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __getitem__
def generateSubDiffs
def getFields

Public Attributes

 id1
 id2

Static Public Attributes

string meta_type = "Compound Diff for AT types"

Private Attributes

 _diffs

Detailed Description

Text difference

Definition at line 25 of file ATCompoundDiff.py.


Constructor & Destructor Documentation

def CMFDiffTool.ATCompoundDiff.ATCompoundDiff.__init__ (   self,
  obj1,
  obj2,
  field,
  id1 = None,
  id2 = None 
)

Definition at line 30 of file ATCompoundDiff.py.

00030 
00031     def __init__(self, obj1, obj2, field, id1=None, id2=None):
00032         if not id1:
00033             id1 = obj1.getId()
00034         if not id2:
00035             id2 = obj2.getId()
00036         self.id1 = id1
00037         self.id2 = id2
00038 
00039         fields = self.getFields(obj1, obj2)
00040         self._diffs = self.generateSubDiffs(fields, obj1, obj2)


Member Function Documentation

Definition at line 41 of file ATCompoundDiff.py.

00041 
00042     def __getitem__(self, index):
00043         return self._diffs[index]

Here is the caller graph for this function:

def CMFDiffTool.ATCompoundDiff.ATCompoundDiff.generateSubDiffs (   self,
  fields,
  obj1,
  obj2 
)

Definition at line 44 of file ATCompoundDiff.py.

00044 
00045     def generateSubDiffs(self, fields, obj1, obj2):
00046         diff_list = []
00047         for field in fields:
00048             klass = field['klass']
00049             diff = klass(obj1, obj2, field['accessor'], id1=self.id1,
00050                               id2=self.id2, field_label=field['label'],
00051                               schemata=field['schemata'])
00052             diff_list.append(diff)
00053         return diff_list

def CMFDiffTool.ATCompoundDiff.ATCompoundDiff.getFields (   self,
  obj1,
  obj2 
)

Definition at line 54 of file ATCompoundDiff.py.

00054 
00055     def getFields(self, obj1, obj2):
00056         fields = []
00057         # Make sure we get the fields ordered by schemata, as in the edit view
00058         schematas = obj1.Schemata()
00059         schemata_names = schematas.keys()
00060 
00061         # Put default first and metadata last
00062         if 'default' in schemata_names and schemata_names[0] != 'default':
00063             schemata_names.remove('default')
00064             schemata_names.insert(0,'default')
00065         if 'metadata' in schemata_names and schemata_names[-1] != 'metadata':
00066             schemata_names.remove('metadata')
00067             schemata_names.insert(-1,'metadata')
00068 
00069         for schemata_name in schemata_names:
00070             schema = schematas[schemata_name]
00071             for field in schema.viewableFields(obj1):
00072                 if (AT_FIELD_MAPPING.has_key(field.type) and 
00073                         field.getName() not in AT_EXCLUDED_FIELDS):
00074                     is_primary = getattr(field, 'primary' , False)
00075                     label = field.widget.Label(obj1)
00076                     diff_type = AT_FIELD_MAPPING[field.type]
00077                     if IDifference.isImplementedByInstancesOf(diff_type):
00078                         fields.append({'name':field.getName(),
00079                                     'accessor':field.accessor,
00080                                     'klass':diff_type,
00081                                     'primary':is_primary,
00082                                     'label':label,
00083                                     'schemata':schemata_name})
00084                     elif 'raw' in diff_type:
00085                         #Handle Fields which diff against the edit accessor
00086                         diff_name = diff_type.split(':')[1]
00087                         diff_type = globals()[diff_name]
00088                         fields.append({'name':field.getName(),
00089                                     'accessor':field.edit_accessor,
00090                                     'klass':diff_type,
00091                                     'primary':is_primary,
00092                                     'label':label,
00093                                     'schemata':schemata_name})
00094                     elif diff_type == 'variable_binary':
00095                         diff_type = BinaryDiff
00096                         if 'text/' in field.getContentType(obj1) and \
00097                         'text/' in \
00098                             obj2.getField(field.getName()).getContentType(obj2):
00099                             diff_type = TextDiff
00100                         fields.append({'name':field.getName(),
00101                                     'accessor':field.accessor,
00102                                     'klass':diff_type,
00103                                     'primary':is_primary,
00104                                     'label':label,
00105                                     'schemata':schemata_name})
00106                     elif diff_type == 'variable_text':
00107                         diff_type = TextDiff
00108                         if 'html' in field.getContentType(obj1) and \
00109                         'html' in \
00110                             obj2.getField(field.getName()).getContentType(obj2):
00111                             diff_type = CMFDTHtmlDiff
00112                         fields.append({'name':field.getName(),
00113                                     'accessor':field.accessor,
00114                                     'klass':diff_type,
00115                                     'primary':is_primary,
00116                                     'label':label,
00117                                     'schemata':schemata_name})
00118         return fields
00119 
00120 InitializeClass(ATCompoundDiff)

Member Data Documentation

Definition at line 39 of file ATCompoundDiff.py.

Definition at line 35 of file ATCompoundDiff.py.

Definition at line 36 of file ATCompoundDiff.py.

string CMFDiffTool.ATCompoundDiff.ATCompoundDiff.meta_type = "Compound Diff for AT types" [static]

Definition at line 28 of file ATCompoundDiff.py.


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