Пример #1
0
class DocumentHandler(handlers.SilvaHandler):
    silvaconf.name('document')

    def getOverrides(self):
        return {(NS_SILVA_URI, 'content'): DocumentVersionHandler}

    def startElementNS(self, name, qname, attrs):
        if name == (NS_SILVA_URI, 'document'):
            uid = self.generateIdentifier(attrs)
            factory = self.parent().manage_addProduct['SilvaDocument']
            factory.manage_addDocument(uid, '', no_default_version=True)
            self.setResultId(uid)

    def endElementNS(self, name, qname):
        if name == (NS_SILVA_URI, 'document'):
            self.notifyImport()
Пример #2
0
class AgendaItemHandler(handlers.SilvaHandler):
    silvaconf.name('plainagendaitem')

    def getOverrides(self):
        return {(NS_URI, 'content'): AgendaItemContentHandler}

    def startElementNS(self, name, qname, attrs):
        if name == (NS_SILVA_NEWS, 'plainagendaitem'):
            id = attrs[(None, 'id')].encode('utf-8')
            uid = self.generateOrReplaceId(id)
            object = AgendaItem(uid)
            self.parent()._setObject(uid, object)
            self.setResultId(uid)

    def endElementNS(self, name, qname):
        if name == (NS_SILVA_NEWS, 'plainagendaitem'):
            self.notifyImport()
class SourceAssetHandler(handlers.SilvaHandler):
    silvaconf.name('source_asset')

    def getOverrides(self):
        return {(NS_SILVA_URI, 'content'): SourceAssetVersionHandler}

    def _createContent(self, identifier):
        factory = self.parent().manage_addProduct['SilvaExternalSources']
        factory.manage_addSourceAsset(identifier, '', no_default_version=True)

    def _verifyContent(self, content):
        return ISourceAsset.providedBy(content)

    def startElementNS(self, name, qname, attrs):
        if name == (NS_SOURCE_URI, 'source_asset'):
            self.createContent(attrs)

    def endElementNS(self, name, qname):
        if name == (NS_SOURCE_URI, 'source_asset'):
            self.notifyImport()