示例#1
0
 def _exportXml(self, evaluation, params):
     """exportation of an evaluation."""
     from MaKaC.common.xmlGen import XMLGen
     xmlGen = XMLGen()
     evaluation.exportXml(xmlGen)
     return send_file(Evaluation._XML_FILENAME,
                      StringIO(xmlGen.getXml()),
                      'XML',
                      inline=False)
示例#2
0
 def __init__(self):
     self.closed = False
     self.xml_generator = XMLGen()
     self.xml_generator.initXml()
     self.xml_generator.openTag(b'collection', [[b'xmlns', b'http://www.loc.gov/MARC21/slim']])
     # This is horrible. but refactoring all the code in the indico core would be just as bad.
     aw = AccessWrapper()
     aw.setUser(User.find_first(is_admin=True).as_avatar)
     self.output_generator = outputGenerator(aw, self.xml_generator)
示例#3
0
 def _process(self):
     filename = "%s - contribution.xml" % self._target.getTitle()
     from MaKaC.common.output import outputGenerator, XSLTransformer
     xmlgen = XMLGen()
     xmlgen.initXml()
     outgen = outputGenerator(self.getAW(), xmlgen)
     xmlgen.openTag("event")
     outgen.confToXML(self._target.getConference(),
                      0,
                      1,
                      1,
                      showContribution=self._target.getId(),
                      overrideCache=True)
     xmlgen.closeTag("event")
     basexml = xmlgen.getXml()
     path = Config.getInstance().getStylesheetsDir()
     stylepath = "%s.xsl" % (os.path.join(path, self._xmltype))
     if self._xmltype != "standard" and os.path.exists(stylepath):
         try:
             parser = XSLTransformer(stylepath)
             data = parser.process(basexml)
         except:
             data = "Cannot parse stylesheet: %s" % sys.exc_info()[0]
     else:
         data = basexml
     return send_file(filename, StringIO(data), 'XML')
示例#4
0
 def _process(self):
     filename = "%s - Contribution.xml" % self._target.getTitle().replace(
         "/", "")
     from MaKaC.common.xmlGen import XMLGen
     from MaKaC.common.output import outputGenerator
     xmlgen = XMLGen()
     xmlgen.initXml()
     outgen = outputGenerator(self.getAW(), xmlgen)
     xmlgen.openTag("marc:record", [
         ["xmlns:marc", "http://www.loc.gov/MARC21/slim"],
         ["xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"],
         [
             "xsi:schemaLocation",
             "http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"
         ]
     ])
     outgen.contribToXMLMarc21(self._target, xmlgen)
     xmlgen.closeTag("marc:record")
     data = xmlgen.getXml()
     self._req.headers_out["Content-Length"] = "%s" % len(data)
     cfg = Config.getInstance()
     mimetype = cfg.getFileTypeMimeType("XML")
     self._req.content_type = """%s""" % (mimetype)
     self._req.headers_out[
         "Content-Disposition"] = """inline; filename="%s\"""" % cleanHTMLHeaderFilename(
             filename)
     return data
示例#5
0
 def _process(self):
     filename = "%s - contribution.xml" % self._target.getTitle()
     from MaKaC.common.output import outputGenerator, XSLTransformer
     xmlgen = XMLGen()
     xmlgen.initXml()
     outgen = outputGenerator(self.getAW(), xmlgen)
     xmlgen.openTag("event")
     outgen.confToXML(self._target.getConference(),
                      0,
                      1,
                      1,
                      showContribution=self._target.getId(),
                      overrideCache=True)
     xmlgen.closeTag("event")
     basexml = xmlgen.getXml()
     path = Config.getInstance().getStylesheetsDir()
     stylepath = "%s.xsl" % (os.path.join(path, self._xmltype))
     if self._xmltype != "standard" and os.path.exists(stylepath):
         try:
             parser = XSLTransformer(stylepath)
             data = parser.process(basexml)
         except:
             data = "Cannot parse stylesheet: %s" % sys.exc_info()[0]
     else:
         data = basexml
     self._req.headers_out["Content-Length"] = "%s" % len(data)
     cfg = Config.getInstance()
     mimetype = cfg.getFileTypeMimeType("XML")
     self._req.content_type = """%s""" % (mimetype)
     self._req.headers_out[
         "Content-Disposition"] = """inline; filename="%s\"""" % cleanHTMLHeaderFilename(
             filename)
     return data
示例#6
0
 def _exportXml(self, evaluation, params):
     """exportation of an evaluation."""
     from MaKaC.common.xmlGen import XMLGen
     xmlGen = XMLGen()
     evaluation.exportXml(xmlGen)
     xmlFile = xmlGen.getXml()
     self._req.set_content_length(len(xmlFile))
     #I should use XML MimeType, but I want webbrowser to ask where to save the file...
     #self._req.content_type = str(Config.getInstance().getFileTypeMimeType("XML"))
     self._req.content_type = "application/octet-stream"
     self._req.headers_out["Content-Disposition"] = 'inline; filename="%s"'%Evaluation._XML_FILENAME
     return xmlFile
示例#7
0
 def _exportXml(self, evaluation, params):
     """exportation of an evaluation."""
     from MaKaC.common.xmlGen import XMLGen
     xmlGen = XMLGen()
     evaluation.exportXml(xmlGen)
     xmlFile = xmlGen.getXml()
     self._req.set_content_length(len(xmlFile))
     #I should use XML MimeType, but I want webbrowser to ask where to save the file...
     #self._req.content_type = str(Config.getInstance().getFileTypeMimeType("XML"))
     self._req.content_type = "application/octet-stream"
     self._req.headers_out[
         "Content-Disposition"] = 'inline; filename="%s"' % Evaluation._XML_FILENAME
     return xmlFile
示例#8
0
 def _process( self ):
     filename = "%s - contribution.xml"%self._target.getTitle()
     from MaKaC.common.output import outputGenerator, XSLTransformer
     xmlgen = XMLGen()
     xmlgen.initXml()
     outgen = outputGenerator(self.getAW(), xmlgen)
     xmlgen.openTag("event")
     outgen.confToXML(self._target.getConference(),0,1,1,showContribution=self._target.getId(), overrideCache=True)
     xmlgen.closeTag("event")
     basexml = xmlgen.getXml()
     path = Config.getInstance().getStylesheetsDir()
     stylepath = "%s.xsl" % (os.path.join(path,self._xmltype))
     if self._xmltype != "standard" and os.path.exists(stylepath):
         try:
             parser = XSLTransformer(stylepath)
             data = parser.process(basexml)
         except:
             data = "Cannot parse stylesheet: %s" % sys.exc_info()[0]
     else:
         data = basexml
     self._req.headers_out["Content-Length"] = "%s"%len(data)
     cfg = Config.getInstance()
     mimetype = cfg.getFileTypeMimeType( "XML" )
     self._req.content_type = """%s"""%(mimetype)
     self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename.replace("\r\n"," ")
     return data
示例#9
0
 def _process(self):
     filename = "%s - Subcontribution.xml" % self._subContrib.getTitle().replace("/","")
     from MaKaC.common.xmlGen import XMLGen
     from MaKaC.common.output import outputGenerator
     xmlgen = XMLGen()
     xmlgen.initXml()
     outgen = outputGenerator(self.getAW(), xmlgen)
     xmlgen.openTag("marc:record", [["xmlns:marc","http://www.loc.gov/MARC21/slim"],["xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"],["xsi:schemaLocation", "http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"]])
     outgen.subContribToXMLMarc21(self._subContrib, xmlgen)
     xmlgen.closeTag("marc:record")
     return send_file(filename, StringIO(xmlgen.getXml()), 'XML')
示例#10
0
 def _process(self):
     filename = "%s - Event.xml" % self._target.getTitle()
     from MaKaC.common.xmlGen import XMLGen
     from MaKaC.common.output import outputGenerator
     xmlgen = XMLGen()
     xmlgen.initXml()
     outgen = outputGenerator(self.getAW(), xmlgen)
     xmlgen.openTag("event")
     outgen.confToXML(self._target.getConference(),0,0,1)
     xmlgen.closeTag("event")
     return send_file(filename, StringIO(xmlgen.getXml()), 'XML')
示例#11
0
 def __init__(self):
     self.closed = False
     self.xml_generator = XMLGen()
     self.xml_generator.initXml()
     self.xml_generator.openTag(b'collection', [[b'xmlns', b'http://www.loc.gov/MARC21/slim']])
     # This is horrible. but refactoring all the code in the indico core would be just as bad.
     aw = AccessWrapper()
     aw.setUser(User.find_first(is_admin=True).as_avatar)
     self.output_generator = outputGenerator(aw, self.xml_generator)
示例#12
0
 def _process(self):
     filename = "%s - Event.xml" % self._target.getTitle()
     from MaKaC.common.xmlGen import XMLGen
     from MaKaC.common.output import outputGenerator
     xmlgen = XMLGen()
     xmlgen.initXml()
     outgen = outputGenerator(self.getAW(), xmlgen)
     xmlgen.openTag("event")
     outgen.confToXML(self._target.getConference(),0,0,1)
     xmlgen.closeTag("event")
     return send_file(filename, StringIO(xmlgen.getXml()), 'XML')
示例#13
0
 def _process( self ):
     filename = "%s - Event.xml"%cleanHTMLHeaderFilename(self._target.getTitle())
     from MaKaC.common.xmlGen import XMLGen
     from MaKaC.common.output import outputGenerator
     xmlgen = XMLGen()
     xmlgen.initXml()
     outgen = outputGenerator(self.getAW(), xmlgen)
     xmlgen.openTag("marc:record", [["xmlns:marc","http://www.loc.gov/MARC21/slim"],["xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"],["xsi:schemaLocation", "http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"]])
     outgen.confToXMLMarc21(self._target.getConference())
     xmlgen.closeTag("marc:record")
     return send_file(filename, StringIO(xmlgen.getXml()), 'XML')
示例#14
0
 def _process( self ):
     filename = "%s - Session.xml"%self._session.getTitle().replace("/","")
     from MaKaC.common.xmlGen import XMLGen
     from MaKaC.common.output import outputGenerator
     xmlgen = XMLGen()
     xmlgen.initXml()
     outgen = outputGenerator(self.getAW(), xmlgen)
     xmlgen.openTag("marc:record", [["xmlns:marc","http://www.loc.gov/MARC21/slim"],["xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"],["xsi:schemaLocation", "http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"]])
     outgen.sessionToXMLMarc21(self._session, xmlgen)
     xmlgen.closeTag("marc:record")
     data = xmlgen.getXml()
     self._req.headers_out["Content-Length"] = "%s"%len(data)
     cfg = Config.getInstance()
     mimetype = cfg.getFileTypeMimeType( "XML" )
     self._req.content_type = """%s"""%(mimetype)
     self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%cleanHTMLHeaderFilename(filename)
     return data
示例#15
0
    def _getMetadata(self, records, logger=None):
        """
        Retrieves the MARCXML metadata for the record
        """
        xg = XMLGen()
        mg = MARCXMLGenerator(xg)
        # set the permissions
        mg.setPermissionsOf(self._access)

        xg.initXml()
        xg.openTag("collection", [["xmlns", "http://www.loc.gov/MARC21/slim"]])

        for record, recId, operation in records:
            deleted = operation & STATUS_DELETED
            try:
                if deleted:
                    mg.generate(recId, overrideCache=True, deleted=True)
                else:
                    if record.getOwner():
                        # caching is disabled because ACL changes do not trigger
                        # notifyModification, and consequently can be classified as a hit
                        # even if they were changed
                        # TODO: change overrideCache to False when this problem is solved
                        mg.generate(record, overrideCache=True, deleted=False)
                    else:
                        logger.warning('%s (%s) is marked as non-deleted and has no owner' % \
                                       (record, recId))
            except:
                if logger:
                    logger.exception(
                        "Something went wrong while processing '%s' (recId=%s) (owner=%s)! Possible metadata errors."
                        % (record, recId, record.getOwner()))
                    # avoid duplicate record
                self._removeUnfinishedRecord(mg._XMLGen)

        xg.closeTag("collection")

        return xg.getXml()
示例#16
0
 def _process( self ):
     filename = "%s - contribution.xml"%self._target.getTitle()
     from MaKaC.common.output import outputGenerator, XSLTransformer
     xmlgen = XMLGen()
     xmlgen.initXml()
     outgen = outputGenerator(self.getAW(), xmlgen)
     xmlgen.openTag("event")
     outgen.confToXML(self._target.getConference(),0,1,1,showContribution=self._target.getId(), overrideCache=True)
     xmlgen.closeTag("event")
     basexml = xmlgen.getXml()
     path = Config.getInstance().getStylesheetsDir()
     stylepath = "%s.xsl" % (os.path.join(path,self._xmltype))
     if self._xmltype != "standard" and os.path.exists(stylepath):
         try:
             parser = XSLTransformer(stylepath)
             data = parser.process(basexml)
         except:
             data = "Cannot parse stylesheet: %s" % sys.exc_info()[0]
     else:
         data = basexml
     return send_file(filename, StringIO(data), 'XML')
示例#17
0
    def _process(self):
        filename = "%s - Contribution.xml" % self._target.getTitle().replace("/", "")
        from MaKaC.common.xmlGen import XMLGen
        from MaKaC.common.output import outputGenerator

        xmlgen = XMLGen()
        xmlgen.initXml()
        outgen = outputGenerator(self.getAW(), xmlgen)
        xmlgen.openTag(
            "marc:record",
            [
                ["xmlns:marc", "http://www.loc.gov/MARC21/slim"],
                ["xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"],
                [
                    "xsi:schemaLocation",
                    "http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd",
                ],
            ],
        )
        outgen.contribToXMLMarc21(self._target, xmlgen)
        xmlgen.closeTag("marc:record")
        return send_file(filename, StringIO(xmlgen.getXml()), "XML")
示例#18
0
文件: bistate.py 项目: jt1/indico
    def _getMetadata(self, records, logger=None):
        """
        Retrieves the MARCXML metadata for the record
        """
        xg = XMLGen()
        mg = MARCXMLGenerator(xg)
        # set the permissions
        mg.setPermissionsOf(self._access)

        xg.initXml()
        xg.openTag("collection", [["xmlns", "http://www.loc.gov/MARC21/slim"]])

        for record, recId, operation in records:
            deleted = operation & STATUS_DELETED
            try:
                if deleted:
                    mg.generate(recId, overrideCache=True, deleted=True)
                else:
                    if record.getOwner():
                        # caching is disabled because ACL changes do not trigger
                        # notifyModification, and consequently can be classified as a hit
                        # even if they were changed
                        # TODO: change overrideCache to False when this problem is solved
                        mg.generate(record, overrideCache=True, deleted=False)
                    else:
                        logger.warning("%s (%s) is marked as non-deleted and has no owner" % (record, recId))
            except:
                if logger:
                    logger.exception(
                        "Something went wrong while processing '%s' (recId=%s) (owner=%s)! Possible metadata errors."
                        % (record, recId, record.getOwner())
                    )
                    # avoid duplicate record
                self._removeUnfinishedRecord(mg._XMLGen)

        xg.closeTag("collection")

        return xg.getXml()
示例#19
0
    def _process(self):
        filename = "%s - Abstract.xml" % self._target.getTitle()

        x = XMLGen()
        x.openTag("abstract")
        x.writeTag("Id", self._target.getId())
        x.writeTag("Title", self._target.getTitle())
        afm = self._target.getConference().getAbstractMgr().getAbstractFieldsMgr()
        for f in afm.getFields():
            id = f.getId()
            if f.isActive() and self._target.getField(id).strip() != "":
                x.writeTag("field", self._target.getField(id), [("id", id)])
        x.writeTag("Conference", self._target.getConference().getTitle())
        l = []
        for au in self._target.getAuthorList():
            if self._target.isPrimaryAuthor(au):
                x.openTag("PrimaryAuthor")
                x.writeTag("FirstName", au.getFirstName())
                x.writeTag("FamilyName", au.getSurName())
                x.writeTag("Email", au.getEmail())
                x.writeTag("Affiliation", au.getAffiliation())
                x.closeTag("PrimaryAuthor")
            else:
                l.append(au)

        for au in l:
            x.openTag("Co-Author")
            x.writeTag("FirstName", au.getFirstName())
            x.writeTag("FamilyName", au.getSurName())
            x.writeTag("Email", au.getEmail())
            x.writeTag("Affiliation", au.getAffiliation())
            x.closeTag("Co-Author")

        for au in self._target.getSpeakerList():
            x.openTag("Speaker")
            x.writeTag("FirstName", au.getFirstName())
            x.writeTag("FamilyName", au.getSurName())
            x.writeTag("Email", au.getEmail())
            x.writeTag("Affiliation", au.getAffiliation())
            x.closeTag("Speaker")

        # To change for the new contribution type system to:
        # x.writeTag("ContributionType", self._target.getContribType().getName())
        x.writeTag("ContributionType", self._target.getContribType())

        for t in self._target.getTrackList():
            x.writeTag("Track", t.getTitle())

        x.closeTag("abstract")

        data = x.getXml()

        self._req.headers_out["Content-Length"] = "%s" % len(data)
        cfg = Config.getInstance()
        mimetype = cfg.getFileTypeMimeType("XML")
        self._req.content_type = """%s""" % (mimetype)
        self._req.headers_out["Content-Disposition"] = """inline; filename="%s\"""" % cleanHTMLHeaderFilename(filename)
        return data
示例#20
0
    def _process(self):
        filename = "%s - contribution.xml"%self._target.getTitle()
        x = XMLGen()
        x.openTag("contribution")
        x.writeTag("Id", self._target.getId())
        x.writeTag("Title", self._target.getTitle())
        x.writeTag("Description", self._target.getDescription())
        afm = self._target.getConference().getAbstractMgr().getAbstractFieldsMgr()
        for f in afm.getFields():
            id = f.getId()
            if f.isActive() and self._target.getField(id).strip() != "":
                x.writeTag(f.getName().replace(" ","_"),self._target.getField(id))
        x.writeTag("Conference", self._target.getConference().getTitle())
        session = self._target.getSession()
        if session!=None:
            x.writeTag("Session", self._target.getSession().getTitle())
        l = []
        for au in self._target.getAuthorList():
            if self._target.isPrimaryAuthor(au):
                x.openTag("PrimaryAuthor")
                x.writeTag("FirstName", au.getFirstName())
                x.writeTag("FamilyName", au.getFamilyName())
                x.writeTag("Email", au.getEmail())
                x.writeTag("Affiliation", au.getAffiliation())
                x.closeTag("PrimaryAuthor")
            else:
                l.append(au)

        for au in l:
            x.openTag("Co-Author")
            x.writeTag("FirstName", au.getFirstName())
            x.writeTag("FamilyName", au.getFamilyName())
            x.writeTag("Email", au.getEmail())
            x.writeTag("Affiliation", au.getAffiliation())
            x.closeTag("Co-Author")

        for au in self._target.getSpeakerList():
            x.openTag("Speaker")
            x.writeTag("FirstName", au.getFirstName ())
            x.writeTag("FamilyName", au.getFamilyName())
            x.writeTag("Email", au.getEmail())
            x.writeTag("Affiliation", au.getAffiliation())
            x.closeTag("Speaker")

        #To change for the new contribution type system to:
        typeName = ""
        if self._target.getType():
            typeName = self._target.getType().getName()
        x.writeTag("ContributionType", typeName)

        t = self._target.getTrack()
        if t!=None:
            x.writeTag("Track", t.getTitle())

        x.closeTag("contribution")

        data = x.getXml()

        cfg = Config.getInstance()
        mimetype = cfg.getFileTypeMimeType("XML")
        self._req.content_type = """%s"""%(mimetype)
        self._req.headers_out["Content-Length"] = "%s"%len(data)
        self._req.headers_out["Content-Disposition"] = """inline; filename="%s\""""%filename.replace("\r\n"," ")
        return data
示例#21
0
class MARCXMLGenerator:
    """Generate MARCXML based on Indico objects."""

    @classmethod
    def records_to_xml(cls, records):
        mg = MARCXMLGenerator()
        for entry, change in records.iteritems():
            mg.safe_add_object(entry, bool(change & SimpleChange.deleted))
        return mg.get_xml()

    @classmethod
    def objects_to_xml(cls, objs, change_type=SimpleChange.created):
        mg = MARCXMLGenerator()
        for obj in objs:
            mg.safe_add_object(obj_ref(obj), bool(change_type & SimpleChange.deleted))
        return mg.get_xml()

    def __init__(self):
        self.closed = False
        self.xml_generator = XMLGen()
        self.xml_generator.initXml()
        self.xml_generator.openTag(b'collection', [[b'xmlns', b'http://www.loc.gov/MARC21/slim']])
        # This is horrible. but refactoring all the code in the indico core would be just as bad.
        aw = AccessWrapper()
        aw.setUser(User.find_first(is_admin=True).as_avatar)
        self.output_generator = outputGenerator(aw, self.xml_generator)

    def safe_add_object(self, obj, deleted=False):
        try:
            self.add_object(obj, deleted)
        except Exception:
            current_plugin.logger.exception('Could not process %s', obj)

    def add_object(self, obj, deleted=False):
        if self.closed:
            raise RuntimeError('Cannot add object to closed xml generator')
        if deleted:
            xg = XMLGen(init=False)
            xg.openTag(b'record')
            xg.openTag(b'datafield', [[b'tag', b'970'], [b'ind1', b' '], [b'ind2', b' ']])
            xg.writeTag(b'subfield', b'INDICO.{}'.format(compound_id(obj)), [[b'code', b'a']])
            xg.closeTag(b'datafield')
            xg.openTag(b'datafield', [[b'tag', b'980'], [b'ind1', b' '], [b'ind2', b' ']])
            xg.writeTag(b'subfield', b'DELETED', [[b'code', b'c']])
            xg.closeTag(b'datafield')
            xg.closeTag(b'record')
            self.xml_generator.xml += xg.xml
        elif isinstance(obj, (Event, Contribution, SubContribution)):
            if obj.is_deleted or obj.event_new.is_deleted:
                pass
            elif isinstance(obj, Event):
                self.xml_generator.xml += self._event_to_marcxml(obj)
            elif isinstance(obj, Contribution):
                self.xml_generator.xml += self._contrib_to_marcxml(obj)
            elif isinstance(obj, SubContribution):
                self.xml_generator.xml += self._subcontrib_to_marcxml(obj)
        elif isinstance(obj, Category):
            pass  # we don't send category updates
        else:
            raise ValueError('unknown object ref: {}'.format(obj))
        return self.xml_generator.getXml()

    def get_xml(self):
        if not self.closed:
            self.xml_generator.closeTag(b'collection')
        return self.xml_generator.getXml()

    def _event_to_marcxml(self, obj):
        xg = XMLGen(init=False)
        xg.openTag(b'record')
        self.output_generator.confToXMLMarc21(obj, out=xg, overrideCache=True)
        xg.closeTag(b'record')
        return xg.xml

    def _contrib_to_marcxml(self, obj):
        xg = XMLGen(init=False)
        xg.openTag(b'record')
        self.output_generator.contribToXMLMarc21(obj, out=xg, overrideCache=True)
        xg.closeTag(b'record')
        return xg.xml

    def _subcontrib_to_marcxml(self, obj):
        xg = XMLGen(init=False)
        xg.openTag(b'record')
        self.output_generator.subContribToXMLMarc21(obj, out=xg, overrideCache=True)
        xg.closeTag(b'record')
        return xg.xml
示例#22
0
 def _exportXml(self, evaluation, params):
     """exportation of an evaluation."""
     from MaKaC.common.xmlGen import XMLGen
     xmlGen = XMLGen()
     evaluation.exportXml(xmlGen)
     return send_file(Evaluation._XML_FILENAME, StringIO(xmlGen.getXml()), 'XML', inline=False)
示例#23
0
    def _process(self):
        filename = "%s - contribution.xml"%self._target.getTitle()
        x = XMLGen()
        x.openTag("contribution")
        x.writeTag("Id", self._target.getId())
        x.writeTag("Title", self._target.getTitle())
        x.writeTag("Description", self._target.getDescription())
        afm = self._target.getConference().getAbstractMgr().getAbstractFieldsMgr()
        for f in afm.getFields():
            id = f.getId()
            if f.isActive() and str(self._target.getField(id)).strip() != "":
                x.writeTag(f.getCaption().replace(" ", "_"), self._target.getField(id))
        x.writeTag("Conference", self._target.getConference().getTitle())
        session = self._target.getSession()
        if session!=None:
            x.writeTag("Session", self._target.getSession().getTitle())
        l = []
        for au in self._target.getAuthorList():
            if self._target.isPrimaryAuthor(au):
                x.openTag("PrimaryAuthor")
                x.writeTag("FirstName", au.getFirstName())
                x.writeTag("FamilyName", au.getFamilyName())
                x.writeTag("Email", au.getEmail())
                x.writeTag("Affiliation", au.getAffiliation())
                x.closeTag("PrimaryAuthor")
            else:
                l.append(au)

        for au in l:
            x.openTag("Co-Author")
            x.writeTag("FirstName", au.getFirstName())
            x.writeTag("FamilyName", au.getFamilyName())
            x.writeTag("Email", au.getEmail())
            x.writeTag("Affiliation", au.getAffiliation())
            x.closeTag("Co-Author")

        for au in self._target.getSpeakerList():
            x.openTag("Speaker")
            x.writeTag("FirstName", au.getFirstName ())
            x.writeTag("FamilyName", au.getFamilyName())
            x.writeTag("Email", au.getEmail())
            x.writeTag("Affiliation", au.getAffiliation())
            x.closeTag("Speaker")

        #To change for the new contribution type system to:
        typeName = ""
        if self._target.getType():
            typeName = self._target.getType().getName()
        x.writeTag("ContributionType", typeName)

        t = self._target.getTrack()
        if t!=None:
            x.writeTag("Track", t.getTitle())

        x.closeTag("contribution")

        return send_file(filename, StringIO(x.getXml()), 'XML')
示例#24
0
def createXML(resvs, req):

    req.content_type="text/xml"

    xml = XMLGen()

    xml.openTag("bookings")

    for collision in resvs:
        resv = collision.withReservation
        xml.openTag("booking")
        xml.writeTag("room", "%s %s-%s"%(str(resv.room.building), resv.room.floor, str(resv.room.roomNr)))
        xml.writeTag("startTime", collision.startDT.strftime("%Y-%m-%d %H:%M:%S"))
        xml.writeTag("endTime", collision.endDT.strftime("%Y-%m-%d %H:%M:%S"))
        xml.writeTag("reason", resv.reason or "")
        xml.closeTag("booking")

    xml.closeTag("bookings")

    return xml.getXml()
示例#25
0
    def _process(self):
        filename = "%s - Abstract.xml" % self._target.getTitle()

        x = XMLGen()
        x.openTag("abstract")
        x.writeTag("Id", self._target.getId())
        x.writeTag("Title", self._target.getTitle())
        afm = self._target.getConference().getAbstractMgr(
        ).getAbstractFieldsMgr()
        for f in afm.getFields():
            id = f.getId()
            if f.isActive() and self._target.getField(id).strip() != "":
                x.writeTag("field", self._target.getField(id), [("id", id)])
        x.writeTag("Conference", self._target.getConference().getTitle())
        l = []
        for au in self._target.getAuthorList():
            if self._target.isPrimaryAuthor(au):
                x.openTag("PrimaryAuthor")
                x.writeTag("FirstName", au.getFirstName())
                x.writeTag("FamilyName", au.getSurName())
                x.writeTag("Email", au.getEmail())
                x.writeTag("Affiliation", au.getAffiliation())
                x.closeTag("PrimaryAuthor")
            else:
                l.append(au)

        for au in l:
            x.openTag("Co-Author")
            x.writeTag("FirstName", au.getFirstName())
            x.writeTag("FamilyName", au.getSurName())
            x.writeTag("Email", au.getEmail())
            x.writeTag("Affiliation", au.getAffiliation())
            x.closeTag("Co-Author")

        for au in self._target.getSpeakerList():
            x.openTag("Speaker")
            x.writeTag("FirstName", au.getFirstName())
            x.writeTag("FamilyName", au.getSurName())
            x.writeTag("Email", au.getEmail())
            x.writeTag("Affiliation", au.getAffiliation())
            x.closeTag("Speaker")

        #To change for the new contribution type system to:
        #x.writeTag("ContributionType", self._target.getContribType().getName())
        x.writeTag("ContributionType", self._target.getContribType())

        for t in self._target.getTrackList():
            x.writeTag("Track", t.getTitle())

        x.closeTag("abstract")

        data = x.getXml()

        self._req.headers_out["Content-Length"] = "%s" % len(data)
        cfg = Config.getInstance()
        mimetype = cfg.getFileTypeMimeType("XML")
        self._req.content_type = """%s""" % (mimetype)
        self._req.headers_out[
            "Content-Disposition"] = """inline; filename="%s\"""" % cleanHTMLHeaderFilename(
                filename)
        return data
示例#26
0
    def _process( self ):
        filename = "%s - Abstract.xml"%self._target.getTitle()

        x = XMLGen()
        x.openTag("abstract")
        x.writeTag("Id", self._target.getId())
        x.writeTag("Title", self._target.getTitle())
        afm = self._target.getConference().getAbstractMgr().getAbstractFieldsMgr()
        for f in afm.getFields():
            id = f.getId()
            if f.isActive() and str(self._target.getField(id)).strip() != "":
                x.writeTag("field",self._target.getField(id),[("id",id)])
        x.writeTag("Conference", self._target.getConference().getTitle())
        l = []
        for au in self._target.getAuthorList():
            if self._target.isPrimaryAuthor(au):
                x.openTag("PrimaryAuthor")
                x.writeTag("FirstName", au.getFirstName())
                x.writeTag("FamilyName", au.getSurName())
                x.writeTag("Email", au.getEmail())
                x.writeTag("Affiliation", au.getAffiliation())
                x.closeTag("PrimaryAuthor")
            else:
                l.append(au)

        for au in l:
            x.openTag("Co-Author")
            x.writeTag("FirstName", au.getFirstName())
            x.writeTag("FamilyName", au.getSurName())
            x.writeTag("Email", au.getEmail())
            x.writeTag("Affiliation", au.getAffiliation())
            x.closeTag("Co-Author")

        for au in self._target.getSpeakerList():
            x.openTag("Speaker")
            x.writeTag("FirstName", au.getFirstName ())
            x.writeTag("FamilyName", au.getSurName())
            x.writeTag("Email", au.getEmail())
            x.writeTag("Affiliation", au.getAffiliation())
            x.closeTag("Speaker")

        #To change for the new contribution type system to:
        #x.writeTag("ContributionType", self._target.getContribType().getName())
        x.writeTag("ContributionType", self._target.getContribType())

        for t in self._target.getTrackList():
            x.writeTag("Track", t.getTitle())

        x.closeTag("abstract")

        return send_file(filename, StringIO(x.getXml()), 'XML')
示例#27
0
 def _subcontrib_to_marcxml(self, obj):
     xg = XMLGen(init=False)
     xg.openTag(b'record')
     self.output_generator.subContribToXMLMarc21(obj, out=xg, overrideCache=True)
     xg.closeTag(b'record')
     return xg.xml
示例#28
0
文件: common.py 项目: bubbas/indico
def getBasicXMLRepresentation(aw, IndicoID, contentType, videoFormat, languages):
    '''Generate the basic XML that is to be transformed using one of the XSL files.'''

    # Incantation to initialize XML that I don't fully understand
    xmlGen = XMLGen()
    xmlGen.initXml()

    # aw stands for AccessWrapper. I don't really understand exactly what
    # this command does, but it is apparently necessary
    og = outputGenerator(aw, xmlGen)

    # Generate XML event tag to enclose the entire conference
    xmlGen.openTag("event")

    # Given the IndicoID, retrieve the type of talk and IDs
    parsed = parseIndicoID(IndicoID)

    # populate dictionary with RecordingManager parameters to be used by methods in outputGenerator
    # such as confToXML, _confToXML, _sessionToXML, _contribToXML, _subContributionToXML
    tags = {'talkType':    parsed['type'],
            'talkId':      parsed[parsed['type']],
            'contentType': contentType,
            'videoFormat': videoFormat,
            'languages':   languages}

#    Logger.get('RecMan').info("tags: [%s] [%s] [%s] [%s]" %\
#                              (tags['talkType'],
#                              tags['talkId'],
#                              tags['contentType'],
#                              tags['videoFormat']))
#    for l in tags["languages"]:
#        Logger.get('RecMan').info("language: %s" % l)

    # Given the conference ID, retrieve the corresponding Conference object
    conference = ConferenceHolder().getById(parsed["conference"])

    # Defining the dictionary 'tags' is how we identify ourselves to the outputGenerator
    # methods.
    # Call ConfToXML with different args depending on talk type.
    # includeSession - descend into each session.
    #                  This is necessary for sessions, contributions, and subcontributions,
    #                  since contributions and subcontributions are children of sessions.
    # includeContribution - necessary for contributions and subcontributions
    # includeMaterial - this is always set to "1".
    # showSession - create XML for a particular session, identified by ID
    # showContribution - create XML for a particular contribution, identified by ID
    # showSubContribution - create XML for a particular subcontribution, identified by ID
    # overrideCache - True means force it NOT to use the cache.
    # recordingManagerTags - this is how we pass along all the necessary RecordingManager args to the outputGenerator methods.
    #
    # Nobody outside CERN should have access to CERN access lists.
    # OAI harvesters outside CERN call the same methods we'll be calling,
    # and we don't want to make the access lists available to them.
    if parsed["type"] == 'conference':
#        Logger.get('RecMan').info("generating MARC XML for a conference")
        og.confToXML(conference,
                     0, # includeSession
                     0, # includeContribution
                     1, # includeMaterial
                     showSession         = None,
                     showContribution    = None,
                     showSubContribution = None,
                     overrideCache       = True,
                     recordingManagerTags = tags)
    elif parsed["type"] == 'session':
#        Logger.get('RecMan').info("generating MARC XML for a session")
        og.confToXML(conference,
                     1, # includeSession
                     0, # includeContribution
                     1, # includeMaterial
                     showSession         = parsed["session"],
                     showContribution    = None,
                     showSubContribution = None,
                     overrideCache       = True,
                     recordingManagerTags = tags)
    elif parsed["type"] == 'contribution':
#        Logger.get('RecMan').info("generating MARC XML for a contribution")
        og.confToXML(conference,
                     1, # includeSession
                     1, # includeContribution
                     1, # includeMaterial
                     showSession         = parsed["session"],
                     showContribution    = parsed["contribution"],
                     showSubContribution = None,
                     overrideCache       = True,
                     recordingManagerTags = tags)
    elif parsed["type"] == 'subcontribution':
#        Logger.get('RecMan').info("generating MARC XML for a subcontribution")
        og.confToXML(conference,
                     1, # includeSession
                     1, # includeContribution
                     1, # includeMaterial
                     showSession         = None,
                     showContribution    = parsed["contribution"], # maybe I should turn this on?
                     showSubContribution = parsed["subcontribution"],
                     overrideCache       = True,
                     recordingManagerTags = tags)
    else:
        raise RecordingManagerException(_("IndicoID %s is not a known conference, session, contribution or subcontribution.") % IndicoID)

    xmlGen.closeTag("event")

    # Retrieve the entire basic XML string
    return xmlGen.getXml()
示例#29
0
 def add_object(self, ref, deleted=False):
     if self.closed:
         raise RuntimeError('Cannot add object to closed xml generator')
     if deleted:
         xg = XMLGen(init=False)
         xg.openTag(b'record')
         xg.openTag(b'datafield', [[b'tag', b'970'], [b'ind1', b' '], [b'ind2', b' ']])
         xg.writeTag(b'subfield', b'INDICO.{}'.format(make_compound_id(ref)), [[b'code', b'a']])
         xg.closeTag(b'datafield')
         xg.openTag(b'datafield', [[b'tag', b'980'], [b'ind1', b' '], [b'ind2', b' ']])
         xg.writeTag(b'subfield', b'DELETED', [[b'code', b'c']])
         xg.closeTag(b'datafield')
         xg.closeTag(b'record')
         self.xml_generator.xml += xg.xml
     elif ref['type'] in {EntryType.event, EntryType.contribution, EntryType.subcontribution}:
         obj = obj_deref(ref)
         if obj is None:
             raise ValueError('Cannot add deleted object')
         elif isinstance(obj, Category) and not obj.getOwner():
             raise ValueError('Cannot add object without owner: {}'.format(obj))
         if obj.is_deleted or obj.event_new.is_deleted:
             pass
         elif ref['type'] == EntryType.event:
             self.xml_generator.xml += self._event_to_marcxml(obj)
         elif ref['type'] == EntryType.contribution:
             self.xml_generator.xml += self._contrib_to_marcxml(obj)
         elif ref['type'] == EntryType.subcontribution:
             self.xml_generator.xml += self._subcontrib_to_marcxml(obj)
     elif ref['type'] == EntryType.category:
         pass  # we don't send category updates
     else:
         raise ValueError('unknown object ref: {}'.format(ref['type']))
     return self.xml_generator.getXml()
示例#30
0
class MARCXMLGenerator:
    """Generates MARCXML based on Indico objects"""

    @classmethod
    def records_to_xml(cls, records):
        mg = MARCXMLGenerator()
        for ref, change in records.iteritems():
            mg.safe_add_object(ref, bool(change & SimpleChange.deleted))
        return mg.get_xml()

    @classmethod
    def objects_to_xml(cls, objs, change_type=SimpleChange.created):
        mg = MARCXMLGenerator()
        for obj in objs:
            mg.safe_add_object(obj_ref(obj), bool(change_type & SimpleChange.deleted))
        return mg.get_xml()

    def __init__(self):
        self.closed = False
        self.xml_generator = XMLGen()
        self.xml_generator.initXml()
        self.xml_generator.openTag(b'collection', [[b'xmlns', b'http://www.loc.gov/MARC21/slim']])
        # This is horrible. but refactoring all the code in the indico core would be just as bad.
        aw = AccessWrapper()
        aw.setUser(User.find_first(is_admin=True).as_avatar)
        self.output_generator = outputGenerator(aw, self.xml_generator)

    def safe_add_object(self, ref, deleted=False):
        try:
            self.add_object(ref, deleted)
        except Exception:
            current_plugin.logger.exception('Could not process %s', ref)

    def add_object(self, ref, deleted=False):
        if self.closed:
            raise RuntimeError('Cannot add object to closed xml generator')
        if deleted:
            xg = XMLGen(init=False)
            xg.openTag(b'record')
            xg.openTag(b'datafield', [[b'tag', b'970'], [b'ind1', b' '], [b'ind2', b' ']])
            xg.writeTag(b'subfield', b'INDICO.{}'.format(make_compound_id(ref)), [[b'code', b'a']])
            xg.closeTag(b'datafield')
            xg.openTag(b'datafield', [[b'tag', b'980'], [b'ind1', b' '], [b'ind2', b' ']])
            xg.writeTag(b'subfield', b'DELETED', [[b'code', b'c']])
            xg.closeTag(b'datafield')
            xg.closeTag(b'record')
            self.xml_generator.xml += xg.xml
        elif ref['type'] in {EntryType.event, EntryType.contribution, EntryType.subcontribution}:
            obj = obj_deref(ref)
            if obj is None:
                raise ValueError('Cannot add deleted object')
            elif isinstance(obj, Category) and not obj.getOwner():
                raise ValueError('Cannot add object without owner: {}'.format(obj))
            if obj.is_deleted or obj.event_new.is_deleted:
                pass
            elif ref['type'] == EntryType.event:
                self.xml_generator.xml += self._event_to_marcxml(obj)
            elif ref['type'] == EntryType.contribution:
                self.xml_generator.xml += self._contrib_to_marcxml(obj)
            elif ref['type'] == EntryType.subcontribution:
                self.xml_generator.xml += self._subcontrib_to_marcxml(obj)
        elif ref['type'] == EntryType.category:
            pass  # we don't send category updates
        else:
            raise ValueError('unknown object ref: {}'.format(ref['type']))
        return self.xml_generator.getXml()

    def get_xml(self):
        if not self.closed:
            self.xml_generator.closeTag(b'collection')
        return self.xml_generator.getXml()

    def _event_to_marcxml(self, obj):
        xg = XMLGen(init=False)
        xg.openTag(b'record')
        self.output_generator.confToXMLMarc21(obj, out=xg, overrideCache=True)
        xg.closeTag(b'record')
        return xg.xml

    def _contrib_to_marcxml(self, obj):
        xg = XMLGen(init=False)
        xg.openTag(b'record')
        self.output_generator.contribToXMLMarc21(obj, out=xg, overrideCache=True)
        xg.closeTag(b'record')
        return xg.xml

    def _subcontrib_to_marcxml(self, obj):
        xg = XMLGen(init=False)
        xg.openTag(b'record')
        self.output_generator.subContribToXMLMarc21(obj, out=xg, overrideCache=True)
        xg.closeTag(b'record')
        return xg.xml
示例#31
0
文件: common.py 项目: shirabe/indico
def getBasicXMLRepresentation(aw, IndicoID, contentType, videoFormat,
                              languages):
    '''Generate the basic XML that is to be transformed using one of the XSL files.'''

    # Incantation to initialize XML that I don't fully understand
    xmlGen = XMLGen()
    xmlGen.initXml()

    # aw stands for AccessWrapper. I don't really understand exactly what
    # this command does, but it is apparently necessary
    og = outputGenerator(aw, xmlGen)

    # Generate XML event tag to enclose the entire conference
    xmlGen.openTag("event")

    # Given the IndicoID, retrieve the type of talk and IDs
    parsed = parseIndicoID(IndicoID)

    # populate dictionary with RecordingManager parameters to be used by methods in outputGenerator
    # such as confToXML, _confToXML, _sessionToXML, _contribToXML, _subContributionToXML
    tags = {
        'talkType': parsed['type'],
        'talkId': parsed[parsed['type']],
        'contentType': contentType,
        'videoFormat': videoFormat,
        'languages': languages
    }

    #    Logger.get('RecMan').info("tags: [%s] [%s] [%s] [%s]" %\
    #                              (tags['talkType'],
    #                              tags['talkId'],
    #                              tags['contentType'],
    #                              tags['videoFormat']))
    #    for l in tags["languages"]:
    #        Logger.get('RecMan').info("language: %s" % l)

    # Given the conference ID, retrieve the corresponding Conference object
    conference = ConferenceHolder().getById(parsed["conference"])

    # Defining the dictionary 'tags' is how we identify ourselves to the outputGenerator
    # methods.
    # Call ConfToXML with different args depending on talk type.
    # includeSession - descend into each session.
    #                  This is necessary for sessions, contributions, and subcontributions,
    #                  since contributions and subcontributions are children of sessions.
    # includeContribution - necessary for contributions and subcontributions
    # includeMaterial - this is always set to "1".
    # showSession - create XML for a particular session, identified by ID
    # showContribution - create XML for a particular contribution, identified by ID
    # showSubContribution - create XML for a particular subcontribution, identified by ID
    # overrideCache - True means force it NOT to use the cache.
    # recordingManagerTags - this is how we pass along all the necessary RecordingManager args to the outputGenerator methods.
    #
    # Nobody outside CERN should have access to CERN access lists.
    # OAI harvesters outside CERN call the same methods we'll be calling,
    # and we don't want to make the access lists available to them.
    if parsed["type"] == 'conference':
        #        Logger.get('RecMan').info("generating MARC XML for a conference")
        og.confToXML(
            conference,
            0,  # includeSession
            0,  # includeContribution
            1,  # includeMaterial
            showSession=None,
            showContribution=None,
            showSubContribution=None,
            overrideCache=True,
            recordingManagerTags=tags)
    elif parsed["type"] == 'session':
        #        Logger.get('RecMan').info("generating MARC XML for a session")
        og.confToXML(
            conference,
            1,  # includeSession
            0,  # includeContribution
            1,  # includeMaterial
            showSession=parsed["session"],
            showContribution=None,
            showSubContribution=None,
            overrideCache=True,
            recordingManagerTags=tags)
    elif parsed["type"] == 'contribution':
        #        Logger.get('RecMan').info("generating MARC XML for a contribution")
        og.confToXML(
            conference,
            1,  # includeSession
            1,  # includeContribution
            1,  # includeMaterial
            showSession=parsed["session"],
            showContribution=parsed["contribution"],
            showSubContribution=None,
            overrideCache=True,
            recordingManagerTags=tags)
    elif parsed["type"] == 'subcontribution':
        #        Logger.get('RecMan').info("generating MARC XML for a subcontribution")
        og.confToXML(
            conference,
            1,  # includeSession
            1,  # includeContribution
            1,  # includeMaterial
            showSession=None,
            showContribution=parsed[
                "contribution"],  # maybe I should turn this on?
            showSubContribution=parsed["subcontribution"],
            overrideCache=True,
            recordingManagerTags=tags)
    else:
        raise RecordingManagerException(
            _("IndicoID %s is not a known conference, session, contribution or subcontribution."
              ) % IndicoID)

    xmlGen.closeTag("event")

    # Retrieve the entire basic XML string
    return xmlGen.getXml()
示例#32
0
    def _process( self ):
        filename = "%s - Abstract.xml"%self._target.getTitle()

        x = XMLGen()
        x.openTag("abstract")
        x.writeTag("Id", self._target.getId())
        x.writeTag("Title", self._target.getTitle())
        afm = self._target.getConference().getAbstractMgr().getAbstractFieldsMgr()
        for f in afm.getFields():
            id = f.getId()
            if f.isActive() and str(self._target.getField(id)).strip() != "":
                x.writeTag("field",self._target.getField(id),[("id",id)])
        x.writeTag("Conference", self._target.getConference().getTitle())
        l = []
        for au in self._target.getAuthorList():
            if self._target.isPrimaryAuthor(au):
                x.openTag("PrimaryAuthor")
                x.writeTag("FirstName", au.getFirstName())
                x.writeTag("FamilyName", au.getSurName())
                x.writeTag("Email", au.getEmail())
                x.writeTag("Affiliation", au.getAffiliation())
                x.closeTag("PrimaryAuthor")
            else:
                l.append(au)

        for au in l:
            x.openTag("Co-Author")
            x.writeTag("FirstName", au.getFirstName())
            x.writeTag("FamilyName", au.getSurName())
            x.writeTag("Email", au.getEmail())
            x.writeTag("Affiliation", au.getAffiliation())
            x.closeTag("Co-Author")

        for au in self._target.getSpeakerList():
            x.openTag("Speaker")
            x.writeTag("FirstName", au.getFirstName ())
            x.writeTag("FamilyName", au.getSurName())
            x.writeTag("Email", au.getEmail())
            x.writeTag("Affiliation", au.getAffiliation())
            x.closeTag("Speaker")

        #To change for the new contribution type system to:
        #x.writeTag("ContributionType", self._target.getContribType().getName())
        x.writeTag("ContributionType", self._target.getContribType())

        for t in self._target.getTrackList():
            x.writeTag("Track", t.getTitle())

        x.closeTag("abstract")

        return send_file(filename, StringIO(x.getXml()), 'XML')
示例#33
0
 def _subcontrib_to_marcxml(self, obj):
     xg = XMLGen(init=False)
     xg.openTag(b'record')
     self.output_generator.subContribToXMLMarc21(obj, out=xg, overrideCache=True)
     xg.closeTag(b'record')
     return xg.xml
示例#34
0
 def add_object(self, obj, deleted=False):
     if self.closed:
         raise RuntimeError('Cannot add object to closed xml generator')
     if deleted:
         xg = XMLGen(init=False)
         xg.openTag(b'record')
         xg.openTag(b'datafield', [[b'tag', b'970'], [b'ind1', b' '], [b'ind2', b' ']])
         xg.writeTag(b'subfield', b'INDICO.{}'.format(compound_id(obj)), [[b'code', b'a']])
         xg.closeTag(b'datafield')
         xg.openTag(b'datafield', [[b'tag', b'980'], [b'ind1', b' '], [b'ind2', b' ']])
         xg.writeTag(b'subfield', b'DELETED', [[b'code', b'c']])
         xg.closeTag(b'datafield')
         xg.closeTag(b'record')
         self.xml_generator.xml += xg.xml
     elif isinstance(obj, (Event, Contribution, SubContribution)):
         if obj.is_deleted or obj.event_new.is_deleted:
             pass
         elif isinstance(obj, Event):
             self.xml_generator.xml += self._event_to_marcxml(obj)
         elif isinstance(obj, Contribution):
             self.xml_generator.xml += self._contrib_to_marcxml(obj)
         elif isinstance(obj, SubContribution):
             self.xml_generator.xml += self._subcontrib_to_marcxml(obj)
     elif isinstance(obj, Category):
         pass  # we don't send category updates
     else:
         raise ValueError('unknown object ref: {}'.format(obj))
     return self.xml_generator.getXml()