Changeset 2369 in products for quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/adapters.py
- Timestamp:
- May 21, 2010 10:36:44 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
quintagroup.canonicalpath/trunk/quintagroup/canonicalpath/adapters.py
r2105 r2369 5 5 6 6 from OFS.interfaces import ITraversable 7 from OFS.interfaces import IPropertyManager 8 7 9 from Products.CMFCore.utils import getToolByName 8 10 … … 18 20 19 21 20 class Default CanonicalAdapter(object):21 """Generic canonicaladapter.22 class DefaultPropertyAdapter(object): 23 """Generic property adapter. 22 24 """ 23 adapts(I Traversable)25 adapts(IPropertyManager) 24 26 25 27 prop = None … … 27 29 def __init__(self, context): 28 30 self.context = context 29 self.purl = getToolByName(self.context,'portal_url')30 31 def _validate(self, value):32 value.strip()33 if not _is_canonical(value):34 raise InvalidValue(value)35 return value36 31 37 32 def getDefault(self): … … 51 46 """ First validate value, than add/updater self.prop 52 47 """ 53 value = self._validate(value)54 55 48 if self.context.hasProperty(self.prop): 56 49 self.context._updateProperty(self.prop, value) … … 65 58 66 59 60 class DefaultCanonicalAdapter(DefaultPropertyAdapter): 61 """Generic canonical adapter. 62 Add validation support to functionality of DefaultPropertyAdapter. 63 """ 64 adapts(ITraversable) 65 66 def _validate(self, value): 67 value.strip() 68 if not _is_canonical(value): 69 raise InvalidValue(value) 70 return value 71 72 def setProp(self, value): 73 """ First validate value, than add/updater self.prop 74 """ 75 value = self._validate(value) 76 super(DefaultCanonicalAdapter, self).setProp(value) 77 78 67 79 class DefaultCanonicalPathAdapter(DefaultCanonicalAdapter): 68 80 """Adapts base content to canonical path. … … 71 83 72 84 prop = PROPERTY_PATH 85 86 def __init__(self, context): 87 super(DefaultCanonicalPathAdapter, self).__init__(context) 88 self.purl = getToolByName(self.context,'portal_url') 73 89 74 90 def getDefault(self):
Note: See TracChangeset
for help on using the changeset viewer.