Back to index

plone3  3.1.7
Public Member Functions | Public Attributes | Private Member Functions
plone.app.controlpanel.filter.FilterControlPanelAdapter Class Reference
Inheritance diagram for plone.app.controlpanel.filter.FilterControlPanelAdapter:
Inheritance graph
[legend]
Collaboration diagram for plone.app.controlpanel.filter.FilterControlPanelAdapter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def nasty_tags
def stripped_tags
def custom_tags
def style_whitelist
def class_blacklist
def stripped_attributes
def stripped_combinations

Public Attributes

 context
 transform
 kupu_tool

Private Member Functions

def _settransform

Detailed Description

Definition at line 106 of file filter.py.


Constructor & Destructor Documentation

Definition at line 110 of file filter.py.

00110 
00111     def __init__(self, context):
00112         super(FilterControlPanelAdapter, self).__init__(context)
00113         self.context = context
00114         self.transform = getattr(
00115             getToolByName(context, 'portal_transforms'), 'safe_html')
00116         self.kupu_tool = getToolByName(context, 'kupu_library_tool')

Here is the caller graph for this function:


Member Function Documentation

Definition at line 117 of file filter.py.

00117 
00118     def _settransform(self, **kwargs):
00119         # Cannot pass a dict to set transform parameters, it has
00120         # to be separate keys and values
00121         # Also the transform requires all dictionary values to be set
00122         # at the same time: other values may be present but are not
00123         # required.
00124         for k in ('valid_tags', 'nasty_tags'):
00125             if k not in kwargs:
00126                 kwargs[k] = self.transform.get_parameter_value(k)
00127 
00128         for k in list(kwargs):
00129             if isinstance(kwargs[k], dict):
00130                 v = kwargs[k]
00131                 kwargs[k+'_key'] = v.keys()
00132                 kwargs[k+'_value'] = [str(s) for s in v.values()]
00133                 del kwargs[k]
00134         self.transform.set_parameters(**kwargs)
00135         self.transform._p_changed = True
00136         self.transform.reload()

Here is the caller graph for this function:

Ideally the form should allow setting a class whitelist,
but that will have to be added later.

Definition at line 206 of file filter.py.

00206 
00207     def class_blacklist():
00208         '''Ideally the form should allow setting a class whitelist,
00209         but that will have to be added later.'''
00210         def get(self):
00211             return  self.kupu_tool.getClassBlacklist()
00212         def set(self, value):
00213             self.kupu_tool.class_blacklist = list(value)
00214         return property(get, set)

Here is the call graph for this function:

Definition at line 176 of file filter.py.

00176 
00177     def custom_tags():
00178         def get(self):
00179             valid = set(self.transform.get_parameter_value('valid_tags'))
00180             custom = valid - XHTML_TAGS
00181             return sorted(custom)
00182         def set_(self, value):
00183             valid = dict(self.transform.get_parameter_value('valid_tags'))
00184             # Remove all non-standard tags
00185             for v in valid.keys():
00186                 if v not in XHTML_TAGS:
00187                     del valid[v]
00188             # Now add in the custom tags
00189             for v in value:
00190                 if v not in valid:
00191                     valid[v] = 1
00192 
00193             self._settransform(valid_tags=valid)
00194 
00195         return property(get, set_)
00196 

Here is the call graph for this function:

Definition at line 138 of file filter.py.

00138 
00139     def nasty_tags():
00140         def get(self):
00141             return sorted(self.transform.get_parameter_value('nasty_tags'))
00142         def set(self, value):
00143             value = dict.fromkeys(value, 1)
00144             valid = self.transform.get_parameter_value('valid_tags')
00145             for v in value:
00146                 if v in valid:
00147                     del valid[v]
00148             self._settransform(nasty_tags=value, valid_tags=valid)
00149         return property(get, set)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 216 of file filter.py.

00216 
00217     def stripped_attributes():
00218         def get(self):
00219             return self.kupu_tool.get_stripped_attributes()
00220         def set(self, value):
00221             self.kupu_tool.set_stripped_attributes(value)
00222         return property(get, set)

Here is the call graph for this function:

Definition at line 224 of file filter.py.

00224 
00225     def stripped_combinations():
00226         def get(self):
00227             return  [TagAttrPair(' '.join(t),' '.join(a)) for (t,a) in \
00228                      self.kupu_tool.get_stripped_combinations()]
00229         def set(self, value):
00230             stripped = []
00231             for ta in value:
00232                 tags = ta.tags.replace(',', ' ').split()
00233                 attributes = ta.attributes.replace(',', ' ').split()
00234                 stripped.append((tags,attributes))
00235 
00236             self.kupu_tool.set_stripped_combinations(stripped)
00237         return property(get, set)
00238 

Here is the call graph for this function:

Definition at line 151 of file filter.py.

00151 
00152     def stripped_tags():
00153         def get(self):
00154             valid = set(self.transform.get_parameter_value('valid_tags'))
00155             stripped = XHTML_TAGS - valid
00156             return sorted(stripped)
00157         def set_(self, value):
00158             valid = dict(self.transform.get_parameter_value('valid_tags'))
00159             stripped = set(value)
00160             for v in XHTML_TAGS:
00161                 if v in stripped:
00162                     if v in valid:
00163                         del valid[v]
00164                 else:
00165                     valid[v] = VALID_TAGS.get(v, 1)
00166 
00167             # Nasty tags must never be valid
00168             for v in self.nasty_tags:
00169                 if v in valid:
00170                     del valid[v]
00171             self._settransform(valid_tags=valid)
00172             self.kupu_tool.set_stripped_tags(value)
00173 
00174         return property(get, set_)

Here is the call graph for this function:

Definition at line 198 of file filter.py.

00198 
00199     def style_whitelist():
00200         def get(self):
00201             return self.kupu_tool.getStyleWhitelist()
00202         def set(self, value):
00203             self.kupu_tool.style_whitelist = list(value)
00204         return property(get, set)

Here is the call graph for this function:


Member Data Documentation

Definition at line 112 of file filter.py.

Definition at line 115 of file filter.py.

Definition at line 113 of file filter.py.


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