Esempio n. 1
0
    def _updateProperty(self, id, value):

        if id == 'predicate':
            self._setPredicate(value)

        else:
            PropertyManager._updateProperty(self, id, value)
Esempio n. 2
0
 def _set_port_range(self, port_range):
     """ validate and set the port range """
     if port_range == '':
         PropertyManager._setPropValue(self, 'port_range', '')
     else:
         self._ports_list(port_range)  # smoke it!
         PropertyManager._setPropValue(self, 'port_range', port_range)
Esempio n. 3
0
    def _updateProperty( self, id, value ):

        if id == 'predicate':
            self._setPredicate( value )

        else:
            PropertyManager._updateProperty( self, id, value )
Esempio n. 4
0
    def _setPropValue(self, id, value):
        """ intercept from PropertyManager so we can do validation """

        if type(value) == type(''):
            value = value.strip()

        # mode-relevant props

        # hosts
        if id == 'etc_hosts' and value != self.etc_hosts:
            self._etc_hosts_set(value)
            self._mode_set()

        # domains
        elif id == 'vhost_db' and value != self.vhost_db:
            self._vhost_db_set(value)
            self._mode_set()

        # zopes
        elif id == 'instance_root' and value != self.instance_root:
            self._instance_root_set(value)
            self._mode_set()

        # secondary props

        elif id == 'skel_root' and value != self.skel_root:
            self._skel_root_set(value)
            self._mode_set()
        elif id == 'port_range':
            self._set_port_range(value)
        else:
            PropertyManager._setPropValue(self, id, value)
 def _delProperty(self, id):
     """ Extends the PropertyManager method of the same name.
     
     """
     PropertyManager._delProperty(self, id)
     if self._property_mapping.has_key(id):
         self._p_changed = 1
         mp = self._property_mapping[id]
         del(self._property_mapping[id])
 def _delProperty(self, id):
     """ Extends the PropertyManager method of the same name.
     
     """
     PropertyManager._delProperty(self, id)
     if self._property_mapping.has_key(id):
         self._p_changed = 1
         mp = self._property_mapping[id]
         del (self._property_mapping[id])
Esempio n. 7
0
 def _set_vhost_db(self, vhost_db):
     """ validate and set the vhost db"""
     from whichdb import whichdb
     if vhost_db == '':
         PropertyManager._setPropValue(self, 'vhost_db', '')
     elif whichdb(vhost_db) is None or whichdb(vhost_db) == '':
         raise CheezeError, "vhost_db must point to a valid dbm file"
     else:
         clean_path = self._scrub_path(vhost_db)
         PropertyManager._setPropValue(self, 'vhost_db', clean_path)
Esempio n. 8
0
 def _setPropValue(self, id, value):
     """ intercept from PropertyManager so we can do validation """
     if id == 'instance_root':
         self._set_instance_root(value)
     elif id == 'skel_root':
         self._set_skel_root(value)
     elif id == 'vhost_db':
         self._set_vhost_db(value)
     elif id == 'port_range':
         self._set_port_range(value)
     else:
         PropertyManager._setPropValue(self, id, value)
Esempio n. 9
0
 def _set_skel_root(self, skel_root):
     """ validate and set the skel root """
     if skel_root == '':
         PropertyManager._setPropValue(self, 'skel_root', '')
     elif not os.path.exists(skel_root):
         raise CheezeError, "Proposed skel root " \
                          + "'%s' does not exist" % skel_root
     elif not os.path.isdir(skel_root):
         raise CheezeError, "Proposed skel root '%s' " % skel_root \
                          + "does not point to a directory"
     else:
         clean_path = self._scrub_path(skel_root)
         PropertyManager._setPropValue(self, 'skel_root', clean_path)
Esempio n. 10
0
 def _set_instance_root(self, instance_root):
     """ validate and set the instance root """
     if instance_root == '':
         PropertyManager._setPropValue(self, 'instance_root', '')
     elif not os.path.exists(instance_root):
         raise CheezeError, "Proposed instance root " \
                          + "'%s' does not exist" % instance_root
     elif not os.path.isdir(instance_root):
         raise CheezeError, "Proposed instance root " \
                          + "'%s' " % instance_root \
                          + "does not point to a directory"
     else:
         clean_path = self._scrub_path(instance_root)
         PropertyManager._setPropValue(self, 'instance_root', clean_path)
 def setUp(self):
     self.props = PropertyManager()
     # PropertyManager has title property already
     self.props.manage_changeProperties(title='Player properties')
     self.props.manage_addProperty('plugins/controls/url', '${portal_path}flowplayer.controls.swf', 'string')
     self.props.manage_addProperty('plugins/controls/all', False, 'boolean')
     self.props.manage_addProperty('plugins/controls/play', True, 'boolean')
     self.props.manage_addProperty('plugins/controls/scrubber', True, 'boolean')
     self.props.manage_addProperty('plugins/controls/tooltips/fullscreen', 'Enter fullscreen mode', 'string')
     self.props.manage_addProperty('plugins/controls/tooltips/buttons', True, 'boolean')
     self.props.manage_addProperty('plugins/audio/url', '${portal_url}++resource++collective.flowplayer/flowplayer.audio.swf', 'string')
     self.props.manage_addProperty('clip/autoPlay', False, 'boolean')
     self.props.manage_addProperty('clip/autoBuffering', True, 'boolean')
     self.props.manage_addProperty('param/src', 'flowplayer.swf', 'string')
     self.props.manage_addProperty('param/wmode', 'opaque', 'string')
 def getProperty(self, id, d=None):
     """Get property value and apply transformer.  Overrides method in
     Zope's PropertyManager class.  Acquire values from aquisiton parents
     if needed.
     """
     ob = self._findParentWithProperty(id)
     return d if (ob is None) else PropertyManager.getProperty(ob, id, d)
    def _updateProperty(self, id, value):
        """ Hook for updating a particular property.
        
        """
        self._p_changed = 1
        # the check method should return the value to be stored or
        # raise an Exception
        check_method = getattr(self, 'check_%s' % id, None)
        if check_method:
            value = check_method(value)
        # use the regular property sheets storage
        PropertyManager._updateProperty(self, id, value)

        # run a reindex if we are CatalogAware
        if hasattr(self, 'reindex_object'):
            self.reindex_object()
 def _updateProperty(self, id, value):
     """ Hook for updating a particular property.
     
     """
     self._p_changed = 1
     # the check method should return the value to be stored or
     # raise an Exception
     check_method = getattr(self, 'check_%s' % id, None)
     if check_method:
         value = check_method(value)
     # use the regular property sheets storage
     PropertyManager._updateProperty(self, id, value)
     
     # run a reindex if we are CatalogAware
     if hasattr(self, 'reindex_object'):
         self.reindex_object()
Esempio n. 15
0
 def getProperty(self, id, d=None):
     """Get property value and apply transformer.  Overrides method in
     Zope's PropertyManager class.  Acquire values from aquisiton parents
     if needed.
     """
     ob = self._findParentWithProperty(id)
     return d if (ob is None) else PropertyManager.getProperty(ob, id, d)
 def hasProperty(self, id, useAcquisition=False):
     """Override method in PropertyManager to support acquisition.
     """
     if useAcquisition:
         hasProp = self._findParentWithProperty(id) is not None
     else:
         hasProp = PropertyManager.hasProperty(self, id)
     return hasProp
Esempio n. 17
0
 def hasProperty(self, id, useAcquisition=False):
     """Override method in PropertyManager to support acquisition.
     """
     if useAcquisition:
         hasProp = self._findParentWithProperty(id) is not None
     else:
         hasProp = PropertyManager.hasProperty(self, id)
     return hasProp
Esempio n. 18
0
def addSiteProperties(portal):
    """adds site_properties in portal_properties"""
    id = PROJECTNAME.lower() + '_properties'
    title = 'Site wide properties'
    p = PropertyManager('id')
    if id not in portal.portal_properties.objectIds():
        portal.portal_properties.addPropertySheet(id, title, p)
    p = getattr(portal.portal_properties, id)
Esempio n. 19
0
 def _etc_hosts_set(self, etc_hosts):
     """ validate and set the etc/hosts path """
     if etc_hosts == '':
         PropertyManager._setPropValue(self, 'etc_hosts', '')
     elif not os.path.exists(etc_hosts):
         raise CheezeError, "Proposed hosts path " \
                          + "'%s' does not exist" % etc_hosts
     elif not os.path.isfile(etc_hosts):
         raise CheezeError, "Proposed hosts path " \
                          + "'%s' " % etc_hosts \
                          + "does not point to a file"
     elif os.path.split(etc_hosts)[1] != 'hosts':
         raise CheezeError, "Proposed hosts file " \
                          + "'%s' " % os.path.split(etc_hosts)[1] \
                          + "is not named 'hosts'"
     else:
         clean_path = self._scrub_path(etc_hosts)
         PropertyManager._setPropValue(self, 'etc_hosts', clean_path)
Esempio n. 20
0
    def manage_editProperties(self,first_day_week,REQUEST=None):
        """ Manage the edited values """

        if first_day_week == 'Monday':
            calendar.setfirstweekday(0)
        else:
            calendar.setfirstweekday(6)
        self.ZCacheable_invalidate()
        return PropertyManager.manage_editProperties(self,REQUEST)
Esempio n. 21
0
 def getPropertyType(self, id):
     """
     Overrides methods from PropertyManager to support acquistion.
     """
     ob = self._findParentWithProperty(id)
     if ob is None:
         type = None
     else:
         type = PropertyManager.getPropertyType(ob, id)
     return type
Esempio n. 22
0
 def getPropertyType(self, id):
     """
     Overrides methods from PropertyManager to support acquistion.
     """
     ob = self._findParentWithProperty(id)
     if ob is None:
         type = None
     else:
         type = PropertyManager.getPropertyType(ob, id)
     return type
Esempio n. 23
0
def getZProperties(context):
    """
    Given a context, this function will return all of the ZProperties that
    are defined for this context (ignoring acquisition)
    @returns Dictionary of the form { 'zPropertyName' : 'zPropertyValue',}
    """
    properties = {}
    # make sure we actually have properties
    if not isinstance(context, ZenPropertyManager):
        return properties

    for zprop in filter(iszprop, context.propertyIds()):
        properties[zprop] = PropertyManager.getProperty(context, zprop)
    return properties
Esempio n. 24
0
def getZProperties(context):
    """
    Given a context, this function will return all of the ZProperties that
    are defined for this context (ignoring acquisition)
    @returns Dictionary of the form { 'zPropertyName' : 'zPropertyValue',}
    """
    properties = {}
    # make sure we actually have properties
    if not isinstance(context, ZenPropertyManager):
        return properties

    for zprop in filter(iszprop, context.propertyIds()):
        properties[zprop] = PropertyManager.getProperty(context, zprop)
    return properties
Esempio n. 25
0
 def afterSetUp(self):
     self.props = PropertyManager()
     # PropertyManager has title property already
     self.props.manage_changeProperties(title = 'Player properties')
     self.props.manage_addProperty('plugins/controls/url', '${portal_path}flowplayer.controls.swf', 'string')
     self.props.manage_addProperty('plugins/controls/all', False, 'boolean')
     self.props.manage_addProperty('plugins/controls/play', True, 'boolean')
     self.props.manage_addProperty('plugins/controls/scrubber', True, 'boolean')
     self.props.manage_addProperty('plugins/controls/tooltips/fullscreen', 'Enter fullscreen mode', 'string')
     self.props.manage_addProperty('plugins/controls/tooltips/buttons', True, 'boolean')
     self.props.manage_addProperty('plugins/audio/url', '${portal_url}++resource++collective.flowplayer/flowplayer.audio.swf', 'string')
     self.props.manage_addProperty('clip/autoPlay',False, 'boolean')
     self.props.manage_addProperty('clip/autoBuffering', True, 'boolean')
     self.props.manage_addProperty('param/src', 'flowplayer.swf', 'string')
     self.props.manage_addProperty('param/wmode', 'opaque', 'string')
Esempio n. 26
0
 def _set_port_range(self, port_range):
     if port_range == '':
         PropertyManager._setPropValue(self, 'port_range', '')
     else:
         self._ports_list(port_range)  # smoke it!
         PropertyManager._setPropValue(self, 'port_range', port_range)
Esempio n. 27
0
    def setUp(self):
        from OFS.PropertyManager import PropertyManager

        obj = PropertyManager('obj')
        obj.foobarbaz = ('Foo', 'Bar', 'Baz')
        obj._properties = ()
        obj._setProperty('foo_boolean', '', 'boolean')
        obj._setProperty('foo_date', '', 'date')
        obj._setProperty('foo_float', '', 'float')
        obj._setProperty('foo_int', '', 'int')
        obj._setProperty('foo_lines', '', 'lines')
        obj._setProperty('foo_long', '', 'long')
        obj._setProperty('foo_string', '', 'string')
        obj._setProperty('foo_text', '', 'text')
        obj._setProperty('foo_tokens', (), 'tokens')
        obj._setProperty('foo_selection', 'foobarbaz', 'selection')
        obj._setProperty('foo_mselection', 'foobarbaz', 'multiple selection')
        obj._setProperty('foo_boolean0', '', 'boolean')
        self.helpers = self._makeOne(obj)
Esempio n. 28
0
 def _setPropValue(self, id, value):
     PropertyManager._setPropValue(self, id, value)
     self.ZCacheable_invalidate()
Esempio n. 29
0
    def _makeOne(self, *args, **kw):
        from OFS.PropertyManager import PropertyManager

        return PropertyManager(*args, **kw)
class TestUtils(unittest.TestCase):

    layer = COLLECTIVE_FLOWPLAYER_INTEGRATION_TESTING

    def setUp(self):
        self.props = PropertyManager()
        # PropertyManager has title property already
        self.props.manage_changeProperties(title='Player properties')
        self.props.manage_addProperty('plugins/controls/url', '${portal_path}flowplayer.controls.swf', 'string')
        self.props.manage_addProperty('plugins/controls/all', False, 'boolean')
        self.props.manage_addProperty('plugins/controls/play', True, 'boolean')
        self.props.manage_addProperty('plugins/controls/scrubber', True, 'boolean')
        self.props.manage_addProperty('plugins/controls/tooltips/fullscreen', 'Enter fullscreen mode', 'string')
        self.props.manage_addProperty('plugins/controls/tooltips/buttons', True, 'boolean')
        self.props.manage_addProperty('plugins/audio/url', '${portal_url}++resource++collective.flowplayer/flowplayer.audio.swf', 'string')
        self.props.manage_addProperty('clip/autoPlay', False, 'boolean')
        self.props.manage_addProperty('clip/autoBuffering', True, 'boolean')
        self.props.manage_addProperty('param/src', 'flowplayer.swf', 'string')
        self.props.manage_addProperty('param/wmode', 'opaque', 'string')

    def test_parsing(self):
        parsed = properties_to_dict(self.props, 'http://localhost', ignore=['title'])
        self.assertEqual(len(parsed.keys()), 2)  # plugins, clip
        self.assertEqual(len(parsed['plugins'].keys()), 2)  # controls, audio
        self.assertEqual(parsed['plugins']['controls']['all'], False)
        self.assertEqual(parsed['plugins']['controls']['scrubber'], True)
        self.assertEqual(parsed['plugins']['controls']['url'], r'http%3A//localhost/flowplayer.controls.swf')
        self.assertEqual(parsed['plugins']['audio']['url'], r'http%3A//localhost/%2B%2Bresource%2B%2Bcollective.flowplayer/flowplayer.audio.swf')
        self.assertEqual(parsed['clip']['autoBuffering'], True)
        self.assertNotIn('param', parsed)

    def test_parsing_flash_props(self):
        parsed = flash_properties_to_dict(self.props, 'http://localhost')
        self.assertEqual(len(parsed.keys()), 2)  # src, wmode
        self.assertEqual(parsed['src'], 'flowplayer.swf')
        self.assertEqual(parsed['wmode'], 'opaque')
Esempio n. 31
0
    def setUp(self):
        from OFS.PropertyManager import PropertyManager

        obj = PropertyManager('obj')
        obj.foobarbaz = ('Foo', 'Bar', 'Baz')
        obj._properties = ()
        obj.manage_addProperty('foo_boolean', '', 'boolean')
        obj.manage_addProperty('foo_date', '1970/01/01', 'date')
        obj.manage_addProperty('foo_float', '0', 'float')
        obj.manage_addProperty('foo_int', '0', 'int')
        obj.manage_addProperty('foo_lines', '', 'lines')
        obj.manage_addProperty('foo_long', '0', 'long')
        obj.manage_addProperty('foo_string', '', 'string')
        obj.manage_addProperty('foo_text', '', 'text')
        obj.manage_addProperty('foo_tokens', '', 'tokens')
        obj.manage_addProperty('foo_selection', 'foobarbaz', 'selection')
        obj.manage_addProperty('foo_mselection', 'foobarbaz',
                               'multiple selection')
        obj.manage_addProperty('foo_boolean0', '', 'boolean')
        obj.manage_addProperty('foo_ro', '', 'string')
        obj._properties[-1]['mode'] = '' # Read-only, not exported or purged
        obj.manage_addProperty('foo_int_nodel', 0, 'int')
        obj._properties[-1]['mode'] = 'w' # Not deletable
        obj.manage_addProperty('foo_float_nodel', 0, 'float')
        obj._properties[-1]['mode'] = 'w' # Not deletable
        obj.manage_addProperty('foo_boolean_nodel', '', 'boolean')
        obj._properties[-1]['mode'] = 'w' # Not deletable
        self.helpers = self._makeOne(obj, DummySetupEnviron())
Esempio n. 32
0
    def setUp(self):
        from OFS.PropertyManager import PropertyManager

        obj = PropertyManager('obj')
        obj.foobarbaz = ('Foo', 'Bar', 'Baz')
        obj._properties = ()
        obj.manage_addProperty('foo_boolean', '', 'boolean')
        obj.manage_addProperty('foo_date', '1970/01/01', 'date')
        obj.manage_addProperty('foo_float', '0', 'float')
        obj.manage_addProperty('foo_int', '0', 'int')
        obj.manage_addProperty('foo_lines', '', 'lines')
        obj.manage_addProperty('foo_long', '0', 'long')
        obj.manage_addProperty('foo_string', '', 'string')
        obj.manage_addProperty('foo_text', '', 'text')
        obj.manage_addProperty('foo_tokens', '', 'tokens')
        obj.manage_addProperty('foo_selection', 'foobarbaz', 'selection')
        obj.manage_addProperty('foo_mselection', 'foobarbaz',
                               'multiple selection')
        obj.manage_addProperty('foo_boolean0', '', 'boolean')
        obj.manage_addProperty('foo_ro', '', 'string')
        obj._properties[-1]['mode'] = '' # Read-only, not exported or purged
        obj.manage_addProperty('foo_int_nodel', 0, 'int')
        obj._properties[-1]['mode'] = 'w' # Not deletable
        obj.manage_addProperty('foo_float_nodel', 0, 'float')
        obj._properties[-1]['mode'] = 'w' # Not deletable
        obj.manage_addProperty('foo_boolean_nodel', '', 'boolean')
        obj._properties[-1]['mode'] = 'w' # Not deletable
        self.helpers = self._makeOne(obj, DummySetupEnviron())
Esempio n. 33
0
File: sql.py Progetto: dtgit/dtedu
 def manage_editProperties(self, REQUEST):
     """Ensure the SQL methods get regenerated."""
     self.delSQLQueries()
     res = PropertyManager.manage_editProperties(self, REQUEST)
     self.addSQLQueries()
     return res
Esempio n. 34
0
 def _setPropValue(self, id, value):
     PropertyManager._setPropValue(self, id, value)
     self.ZCacheable_invalidate()
Esempio n. 35
0
class TestUtils(ZopeTestCase.ZopeTestCase):
    
    def afterSetUp(self):
        self.props = PropertyManager()
        # PropertyManager has title property already
        self.props.manage_changeProperties(title = 'Player properties')
        self.props.manage_addProperty('plugins/controls/url', '${portal_path}flowplayer.controls.swf', 'string')
        self.props.manage_addProperty('plugins/controls/all', False, 'boolean')
        self.props.manage_addProperty('plugins/controls/play', True, 'boolean')
        self.props.manage_addProperty('plugins/controls/scrubber', True, 'boolean')
        self.props.manage_addProperty('plugins/controls/tooltips/fullscreen', 'Enter fullscreen mode', 'string')
        self.props.manage_addProperty('plugins/controls/tooltips/buttons', True, 'boolean')
        self.props.manage_addProperty('plugins/audio/url', '${portal_url}++resource++collective.flowplayer/flowplayer.audio.swf', 'string')
        self.props.manage_addProperty('clip/autoPlay',False, 'boolean')
        self.props.manage_addProperty('clip/autoBuffering', True, 'boolean')
        self.props.manage_addProperty('param/src', 'flowplayer.swf', 'string')
        self.props.manage_addProperty('param/wmode', 'opaque', 'string')
    
    def test_parsing(self):
        parsed = properties_to_dict(self.props, 'http://localhost', ignore=['title'])
        self.assertEqual(len(parsed.keys()), 2) # plugins, clip
        self.assertEqual(len(parsed['plugins'].keys()), 2) # controls, audio
        self.assertEqual(parsed['plugins']['controls']['all'], False) 
        self.assertEqual(parsed['plugins']['controls']['scrubber'], True) 
        self.assertEqual(parsed['plugins']['controls']['url'], r'http%3A//localhost/flowplayer.controls.swf') 
        self.assertEqual(parsed['plugins']['audio']['url'], r'http%3A//localhost/%2B%2Bresource%2B%2Bcollective.flowplayer/flowplayer.audio.swf') 
        self.assertEqual(parsed['clip']['autoBuffering'], True) 
        self.failIf(parsed.has_key('param'))
        
    def test_parsing_flash_props(self):
        parsed = flash_properties_to_dict(self.props, 'http://localhost')
        self.assertEqual(len(parsed.keys()), 2) # src, wmode
        self.assertEqual(parsed['src'], 'flowplayer.swf')
        self.assertEqual(parsed['wmode'], 'opaque')
Esempio n. 36
0
 def manage_editProperties(self, REQUEST):
     """ re-render the page after changing the properties (encodings!!!) """
     result = PropertyManager.manage_editProperties(self, REQUEST)
     self._clear_cache()
     return result
Esempio n. 37
0
File: sql.py Progetto: dtgit/dtedu
 def manage_changeProperties(self, **kwargs):
     """Ensure the SQL methods get regenerated."""
     self.delSQLQueries()
     PropertyManager.manage_changeProperties(self, **kwargs)
     self.addSQLQueries()
Esempio n. 38
0
 def manage_changeProperties(self, REQUEST=None, **kw):
     result = PropertyManager.manage_changeProperties(self, REQUEST, **kw)
     self.reindex_object()
     return result
Esempio n. 39
0
    def setUp(self):
        from OFS.PropertyManager import PropertyManager

        obj = PropertyManager('obj')
        obj.foobarbaz = ('Foo', 'Bar', 'Baz')
        obj._properties = ()
        obj._setProperty('foo_boolean', '', 'boolean')
        obj._setProperty('foo_date', '', 'date')
        obj._setProperty('foo_float', '', 'float')
        obj._setProperty('foo_int', '', 'int')
        obj._setProperty('foo_lines', '', 'lines')
        obj._setProperty('foo_long', '', 'long')
        obj._setProperty('foo_string', '', 'string')
        obj._setProperty('foo_text', '', 'text')
        obj._setProperty('foo_tokens', (), 'tokens')
        obj._setProperty('foo_selection', 'foobarbaz', 'selection')
        obj._setProperty('foo_mselection', 'foobarbaz', 'multiple selection')
        obj._setProperty('foo_boolean0', '', 'boolean')
        self.helpers = self._makeOne(obj)
Esempio n. 40
0
 def manage_editProperties(self, REQUEST):
     """Change properties from ZMI"""
     result = PropertyManager.manage_editProperties(self, REQUEST)
     self.reindex_object()
     return result
Esempio n. 41
0
 def _setPropValue(self, id, value):
     """ set a property and invalidate the cache """
     PropertyManager._setPropValue(self, id, value)
     self.ZCacheable_invalidate()
Esempio n. 42
0
 def manage_editProperties(self, REQUEST):
     """ re-render the page after changing the properties (encodings!!!) """
     result = PropertyManager.manage_editProperties(self, REQUEST)        
     self._clear_cache()
     return result