Beispiel #1
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()
Beispiel #2
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()
Beispiel #3
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()
Beispiel #4
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')
Beispiel #5
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')
    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')
Beispiel #7
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
Beispiel #8
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
Beispiel #9
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