예제 #1
0
    def _updateProperty(self, id, value):

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

        else:
            PropertyManager._updateProperty(self, id, value)
예제 #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)
예제 #3
0
    def _updateProperty( self, id, value ):

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

        else:
            PropertyManager._updateProperty( self, id, value )
예제 #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])
예제 #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)
예제 #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)
예제 #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)
예제 #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()
예제 #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
예제 #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
예제 #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)
예제 #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)
예제 #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)
예제 #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
예제 #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
예제 #23
0
파일: utils.py 프로젝트: bbc/zenoss-prodbin
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
예제 #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
예제 #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')
예제 #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)
예제 #27
0
파일: test_utils.py 프로젝트: goschtl/zope
    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)
예제 #28
0
 def _setPropValue(self, id, value):
     PropertyManager._setPropValue(self, id, value)
     self.ZCacheable_invalidate()
예제 #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')
예제 #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())
예제 #32
0
파일: test_utils.py 프로젝트: dtgit/dtedu
    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())
예제 #33
0
파일: sql.py 프로젝트: 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
예제 #34
0
 def _setPropValue(self, id, value):
     PropertyManager._setPropValue(self, id, value)
     self.ZCacheable_invalidate()
예제 #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')
예제 #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
예제 #37
0
파일: sql.py 프로젝트: dtgit/dtedu
 def manage_changeProperties(self, **kwargs):
     """Ensure the SQL methods get regenerated."""
     self.delSQLQueries()
     PropertyManager.manage_changeProperties(self, **kwargs)
     self.addSQLQueries()
예제 #38
0
 def manage_changeProperties(self, REQUEST=None, **kw):
     result = PropertyManager.manage_changeProperties(self, REQUEST, **kw)
     self.reindex_object()
     return result
예제 #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)
예제 #40
0
 def manage_editProperties(self, REQUEST):
     """Change properties from ZMI"""
     result = PropertyManager.manage_editProperties(self, REQUEST)
     self.reindex_object()
     return result
예제 #41
0
 def _setPropValue(self, id, value):
     """ set a property and invalidate the cache """
     PropertyManager._setPropValue(self, id, value)
     self.ZCacheable_invalidate()
예제 #42
0
파일: ZReST.py 프로젝트: wpjunior/proled
 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