Ejemplo n.º 1
0
    def test_NodeInfo(self):
        # The ``INodeInfo`` providing object holds information about the
        # application node
        nodeinfo = NodeInfo()
        nodeinfo.node = BaseNode
        nodeinfo.addables = ['basenode']
        nodeinfo.title = 'Base Node'
        nodeinfo.description = 'Base Node Description'
        nodeinfo.factory = None
        nodeinfo.icon = 'base-node-icon'

        # check interface
        self.assertTrue(INodeInfo.providedBy(nodeinfo))

        # check superclass
        self.assertTrue(isinstance(nodeinfo, Properties))

        # Register node info
        register_node_info('basenode', nodeinfo)

        # Lookup Node info
        nodeinfo = get_node_info('basenode')
        self.assertTrue(nodeinfo.node is BaseNode)
        self.assertEqual(nodeinfo.addables, ['basenode'])
        self.assertEqual(nodeinfo.title, 'Base Node')
        self.assertEqual(nodeinfo.description, 'Base Node Description')
        self.assertEqual(nodeinfo.factory, None)
        self.assertEqual(nodeinfo.icon, 'base-node-icon')

        # ``__getattr__``. No AttributeError is raised if attribute missing
        self.assertTrue(nodeinfo.inexistent is None)

        # ``__getitem__``
        self.assertEqual(nodeinfo['addables'], ['basenode'])

        # ``__contains__``
        self.assertTrue('node' in nodeinfo)

        # ``get``
        self.assertTrue(nodeinfo.get('node') is BaseNode)
Ejemplo n.º 2
0
    def test_NodeInfo(self):
        # The ``INodeInfo`` providing object holds information about the
        # application node
        nodeinfo = NodeInfo()
        nodeinfo.node = BaseNode
        nodeinfo.addables = ['basenode']
        nodeinfo.title = 'Base Node'
        nodeinfo.description = 'Base Node Description'
        nodeinfo.factory = None
        nodeinfo.icon = 'base-node-icon'

        # check interface
        self.assertTrue(INodeInfo.providedBy(nodeinfo))

        # check superclass
        self.assertTrue(isinstance(nodeinfo, Properties))

        # Register node info
        register_node_info('basenode', nodeinfo)

        # Lookup Node info
        nodeinfo = get_node_info('basenode')
        self.assertTrue(nodeinfo.node is BaseNode)
        self.assertEqual(nodeinfo.addables, ['basenode'])
        self.assertEqual(nodeinfo.title, 'Base Node')
        self.assertEqual(nodeinfo.description, 'Base Node Description')
        self.assertEqual(nodeinfo.factory, None)
        self.assertEqual(nodeinfo.icon, 'base-node-icon')

        # ``__getattr__``. No AttributeError is raised if attribute missing
        self.assertTrue(nodeinfo.inexistent is None)

        # ``__getitem__``
        self.assertEqual(nodeinfo['addables'], ['basenode'])

        # ``__contains__``
        self.assertTrue('node' in nodeinfo)

        # ``get``
        self.assertTrue(nodeinfo.get('node') is BaseNode)
Ejemplo n.º 3
0
            logger.error(str(e))
            return iter(list())

    iterkeys = __iter__

    @locktree
    def __getitem__(self, name):
        # XXX: temporary hack until paster/webob/pyramid handle urllib
        # quoted slashes in path components
        name = unquote_slash(name)
        try:
            return BaseNode.__getitem__(self, name)
        except KeyError:
            try:
                model = self.backend[name]
            except AttributeError:
                raise KeyError(name)
            user = User(model, name, self)
            self[name] = user
            return user


info = NodeInfo()
info.title = _('users_node', 'Users')
info.description = _('users_node_description',
                     'Container for Users')
info.node = Users
info.addables = ['user']
info.icon = 'cone.ugm.static/images/users16_16.png'
registerNodeInfo('users', info)
Ejemplo n.º 4
0
            self[key] = revision
            return revision
    
    @locktree
    def __delitem__(self, key):
        todelete = self[key]
        if hasattr(self, '_todelete'):
            self._todelete.append(todelete)
        else:
            self._todelete = [todelete]
        AdapterNode.__delitem__(self, key)
    
    @locktree
    def __call__(self):
        if hasattr(self, '_todelete'):
            config = solr_config(self)
            for revision in self._todelete:
                unindex_doc(config, revision)
                del self.model[revision.__name__]
            del self._todelete
        self.model()
        self.metadata()


info = NodeInfo()
info.title = 'Media'
info.description = 'A media object.'
info.node = MediaAdapter
info.addables = ['revision']
info.icon = 'mdb-static/images/media16_16.png'
registerNodeInfo('media', info)
Ejemplo n.º 5
0
Archivo: model.py Proyecto: C3S/c3s.app
    def metadata(self):
        md = BaseMetadata()
        md.title = self.attrs.get("title")
        md.description = self.attrs.get("description")
        md.uid = self.attrs.get("uuid")
        md.creator = self.attrs.get("creator")
        md.created = self.attrs.get("created")
        md.modified = self.attrs.get("modified")
        return md


info = NodeInfo()
info.title = "Band"
info.description = "This is a band"
info.addables = ["track"]
info.icon = "c3sapp-static/B16_16.png"
info.node = Band
registerNodeInfo("band", info)


class Track(BaseNode):
    __metaclass__ = plumber
    __plumbing__ = UUIDAttributeAware

    node_info_name = "track"

    @property
    def properties(self):
        props = Properties()
        props.in_navtree = True
        props.action_list = True
Ejemplo n.º 6
0
    @property
    def metadata(self):
        md = BaseMetadata()
        md.title = self.attrs.get('title')
        md.description = self.attrs.get('description')
        md.uid = self.attrs.get('uuid')
        md.creator = self.attrs.get('creator')
        md.created = self.attrs.get('created')
        md.modified = self.attrs.get('modified')
        return md

info = NodeInfo()
info.title = 'Band'
info.description = 'This is a band'
info.addables = ['track']
info.icon = 'c3sapp-static/B16_16.png'
info.node = Band
registerNodeInfo('band', info)


class Track(BaseNode):
    __metaclass__ = plumber
    __plumbing__ = UUIDAttributeAware

    node_info_name = 'track'

    @property
    def properties(self):
        props = Properties()
        props.in_navtree = True
        props.action_list = True
Ejemplo n.º 7
0
        todelete = self[key]
        if hasattr(self, '_todelete'):
            self._todelete.append(todelete)
        else:
            self._todelete = [todelete]
        AdapterNode.__delitem__(self, key)
    
    @locktree
    def __call__(self):
        if hasattr(self, '_todelete'):
            config = solr_config(self)
            for media in self._todelete:
                unindex_doc(config, media)
                for revision in media.values():
                    unindex_doc(config, revision)
                path = os.path.join(self.model.__name__,
                                    *media.model.mediapath + ['media.info'])
                os.remove(path)
                del self.model[media.__name__]
            del self._todelete
        self.model()
        self.metadata()


info = NodeInfo()
info.title = 'Repository'
info.description = 'A repository.'
info.node = RepositoryAdapter
info.addables = ['media']
info.icon = 'mdb-static/images/repository16_16.png'
registerNodeInfo('repository', info)
Ejemplo n.º 8
0
    def metadata(self):
        if self.model:
            metadata = self.model.get('metadata')
            if metadata:
                return metadata
        return Properties()                                 #pragma NO COVERAGE
    
    def _get_state(self):
        return self.metadata.state
    
    def _set_state(self, val):
        self.metadata.state = val
    
    state = property(_get_state, _set_state)
    
    def __iter__(self):
        return iter(list())
    
    iterkeys = __iter__
    
    def __call__(self):
        self.model()


info = NodeInfo()
info.title = 'Revision'
info.description = 'A revision.'
info.node = RevisionAdapter
info.addables = []
info.icon = 'mdb-static/images/revision16_16.png'
registerNodeInfo('revision', info)
Ejemplo n.º 9
0
    @property
    def metadata(self):
        md = BaseMetadata()
        md.title = self.attrs.get('title')
        md.description = self.attrs.get('description')
        md.uid = self.attrs.get('uuid')
        md.creator = self.attrs.get('creator')
        md.created = self.attrs.get('created')
        md.modified = self.attrs.get('modified')
        return md

info = NodeInfo()
info.title = 'Band'
info.description = 'This is a band'
info.addables = ['track']
info.icon = 'myapp-static/B16_16.png'
info.node = Band
registerNodeInfo('band', info)


class Track(BaseNode):
    __metaclass__ = plumber
    __plumbing__ = UUIDAttributeAware

    node_info_name = 'track'

    @property
    def properties(self):
        props = Properties()
        props.in_navtree = True
        props.action_list = True