Changeset 34406d in indico


Ignore:
Timestamp:
06/10/10 18:11:36 (3 years ago)
Author:
Jeremy Herr <jeremy.herr@…>
Branches:
master, burotel, hello-world-walkthrough, ipv6, new-webex, v0.97-series, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 00b052b1a13a63c5c79db7f3ad310f643651dc50
Children:
a11194
Parents:
b04aa4
git-author:
David Martín Clavo <david.martin.clavo@…> (04/16/10 18:27:52)
git-committer:
Jeremy Herr <jeremy.herr@…> (06/10/10 18:11:36)
Message:

[REF] Changed 2 classes to use classmethods

Location:
indico/MaKaC
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/common/output.py

    r26e87f r34406d  
    268268                    # because we have verified that the RecordingManager plugin is installed. 
    269269                    from MaKaC.plugins.Collaboration.RecordingManager.output import MarcAccessListGenerator 
    270                     MarcAccessListGenerator().generateAccessListXML(out, conf) 
    271                     MarcAccessListGenerator().generateVideoXML(out, recordingManagerTags) 
    272                     MarcAccessListGenerator().generateLanguagesXML(out, recordingManagerTags) 
     270                    MarcAccessListGenerator.generateAccessListXML(out, conf) 
     271                    MarcAccessListGenerator.generateVideoXML(out, recordingManagerTags) 
     272                    MarcAccessListGenerator.generateLanguagesXML(out, recordingManagerTags) 
    273273 
    274274        if conf.canModify( self.__aw ) and vars and modificons: 
     
    563563                    # only now do we know it's safe to import the necessary method 
    564564                    from MaKaC.plugins.Collaboration.RecordingManager.output import MarcAccessListGenerator 
    565                     MarcAccessListGenerator().generateAccessListXML(out, session) 
    566                     MarcAccessListGenerator().generateVideoXML(out, recordingManagerTags) 
    567                     MarcAccessListGenerator().generateLanguagesXML(out, recordingManagerTags) 
     565                    MarcAccessListGenerator.generateAccessListXML(out, session) 
     566                    MarcAccessListGenerator.generateVideoXML(out, recordingManagerTags) 
     567                    MarcAccessListGenerator.generateLanguagesXML(out, recordingManagerTags) 
    568568 
    569569        out.closeTag("session") 
     
    797797                    # only now do we know it's safe to import the necessary method 
    798798                    from MaKaC.plugins.Collaboration.RecordingManager.output import MarcAccessListGenerator 
    799                     MarcAccessListGenerator().generateAccessListXML(out, contribution) 
    800                     MarcAccessListGenerator().generateVideoXML(out, recordingManagerTags) 
    801                     MarcAccessListGenerator().generateLanguagesXML(out, recordingManagerTags) 
     799                    MarcAccessListGenerator.generateAccessListXML(out, contribution) 
     800                    MarcAccessListGenerator.generateVideoXML(out, recordingManagerTags) 
     801                    MarcAccessListGenerator.generateLanguagesXML(out, recordingManagerTags) 
    802802 
    803803        out.closeTag("contribution") 
     
    882882                    # only now do we know it's safe to import the necessary method 
    883883                    from MaKaC.plugins.Collaboration.RecordingManager.output import MarcAccessListGenerator 
    884                     MarcAccessListGenerator().generateAccessListXML(out, subCont) 
    885                     MarcAccessListGenerator().generateVideoXML(out, recordingManagerTags) 
    886                     MarcAccessListGenerator().generateLanguagesXML(out, recordingManagerTags) 
     884                    MarcAccessListGenerator.generateAccessListXML(out, subCont) 
     885                    MarcAccessListGenerator.generateVideoXML(out, recordingManagerTags) 
     886                    MarcAccessListGenerator.generateLanguagesXML(out, recordingManagerTags) 
    887887 
    888888        out.closeTag("subcontribution") 
  • indico/MaKaC/plugins/Collaboration/RecordingManager/common.py

    rb04aa4 r34406d  
    198198    cds_indico_matches = getCDSRecords(conference.getId()) 
    199199    Logger.get('RecMan').info('cds_indico_pending...') 
    200     cds_indico_pending = MicalaCommunication().getCDSPending(conference.getId(), cds_indico_matches) 
     200    cds_indico_pending = MicalaCommunication.getCDSPending(conference.getId(), cds_indico_matches) 
    201201 
    202202    # In case there are any records that were pending and are now appearing in CDS, 
    203203    # then update the micala database accordingly. 
    204     MicalaCommunication().updateMicalaCDSExport(cds_indico_matches, cds_indico_pending) 
     204    MicalaCommunication.updateMicalaCDSExport(cds_indico_matches, cds_indico_pending) 
    205205 
    206206    Logger.get('RecMan').info("cds_indico_matches: %s, cds_indico_pending: %s" % (cds_indico_matches, cds_indico_pending)) 
     
    219219 
    220220    # Get list of matching IndicoID's and LOIDs from the Micala database 
    221     existing_matches = MicalaCommunication().getMatches(conference.getId()) 
     221    existing_matches = MicalaCommunication.getMatches(conference.getId()) 
    222222 
    223223    # insert any existing matches into the recordable_events array 
     
    516516 
    517517    # Update the micala database with our current task status 
    518     idMachine = MicalaCommunication().getIdMachine(CollaborationTools.getOptionValue("RecordingManager", "micalaDBMachineName")) 
    519     idTask    = MicalaCommunication().getIdTask(CollaborationTools.getOptionValue("RecordingManager", "micalaDBStatusExportCDS")) 
    520     idLecture = MicalaCommunication().getIdLecture(IndicoID, pattern_cern, pattern_umich) 
     518    idMachine = MicalaCommunication.getIdMachine(CollaborationTools.getOptionValue("RecordingManager", "micalaDBMachineName")) 
     519    idTask    = MicalaCommunication.getIdTask(CollaborationTools.getOptionValue("RecordingManager", "micalaDBStatusExportCDS")) 
     520    idLecture = MicalaCommunication.getIdLecture(IndicoID, pattern_cern, pattern_umich) 
    521521    if idLecture == '': 
    522         idLecture = MicalaCommunication().createNewMicalaLecture(IndicoID, contentType, pattern_cern, pattern_umich) 
    523     MicalaCommunication().reportStatus('START', '', idMachine, idTask, idLecture) 
     522        idLecture = MicalaCommunication.createNewMicalaLecture(IndicoID, contentType, pattern_cern, pattern_umich) 
     523    MicalaCommunication.reportStatus('START', '', idMachine, idTask, idLecture) 
    524524 
    525525    # temporary, for my own debugging 
  • indico/MaKaC/plugins/Collaboration/RecordingManager/micala.py

    rb04aa4 r34406d  
    66 
    77class MicalaCommunication(object): 
    8     def _init_(self): 
    9         pass 
    10  
    11     def getIp(self): 
     8 
     9    @classmethod 
     10    def getIp(cls): 
    1211        '''This should return the IP of the current machine.''' 
    1312        return("") 
    1413 
    15     def getIdMachine(self, machine_name): 
     14    @classmethod 
     15    def getIdMachine(cls, machine_name): 
    1616        '''Look up ID of this machine in database''' 
    1717 
     
    4646        return(idMachine) 
    4747 
    48     def getIdTask(self, task_name): 
     48    @classmethod 
     49    def getIdTask(cls, task_name): 
    4950        '''Look up ID of this task in database''' 
    5051 
     
    7778        return(idTask) 
    7879 
    79     def getIdLecture(self, lecture_name, pattern_cern, pattern_umich): 
     80    @classmethod 
     81    def getIdLecture(cls, lecture_name, pattern_cern, pattern_umich): 
    8082        '''Look up ID of this lecture in database''' 
    8183 
     
    116118        return(idLecture) 
    117119 
    118     def createNewMicalaLecture(self, lecture_name, contentType, pattern_cern, pattern_umich): 
     120    @classmethod 
     121    def createNewMicalaLecture(cls, lecture_name, contentType, pattern_cern, pattern_umich): 
    119122        '''insert a record into the micala database for a new lecture''' 
    120123 
     
    153156        connection.close() 
    154157 
    155         return self.getIdLecture(lecture_name, pattern_cern, pattern_umich) 
    156  
    157     def getMatches(self, confID): 
     158        return cls.getIdLecture(lecture_name, pattern_cern, pattern_umich) 
     159 
     160    @classmethod 
     161    def getMatches(cls, confID): 
    158162        '''For the current conference, get list from the database of IndicoID's already matched to Lecture Object.''' 
    159163 
     
    180184        return (match_array) 
    181185 
    182     def reportStatus(self, status, message, idMachine, idTask, idLecture): 
     186    @classmethod 
     187    def reportStatus(cls, status, message, idMachine, idTask, idLecture): 
    183188        '''Make status report to the database''' 
    184189 
     
    206211 
    207212    # WHO THE HELL CALLS THIS?! 
    208     def updateMicala(self, IndicoID, contentType, LOID): 
     213    @classmethod 
     214    def updateMicala(cls, IndicoID, contentType, LOID): 
    209215        """Submit Indico ID to the micala DB""" 
    210216 
     
    239245            pass 
    240246 
    241     def getCDSPending(self, confId, cds_indico_matches): 
     247    @classmethod 
     248    def getCDSPending(cls, confId, cds_indico_matches): 
    242249        """Query the Micala database to find Indico IDs whose MARC has been exported to CDS, but no CDS record exists yet. 
    243250        Return a list of these Indico IDs.""" 
     
    280287        return talk_array 
    281288 
    282     def updateMicalaCDSExport(self, cds_indico_matches, cds_indico_pending): 
     289    @classmethod 
     290    def updateMicalaCDSExport(cls, cds_indico_matches, cds_indico_pending): 
    283291        '''If there are records found in CDS but not yet listed in the micala database as COMPLETE, then update it. 
    284292        cds_indico_matches is a dictionary of key-value pairs { IndicoID1: CDSID1, IndicoID2: CDSID2, ... } 
     
    289297            try: 
    290298                new_record = cds_indico_matches[pending] 
    291                 idMachine = self.getIdMachine(CollaborationTools.getOptionValue("RecordingManager", "micalaDBMachineName")) 
    292                 idTask    = self.getIdTask(CollaborationTools.getOptionValue("RecordingManager", "micalaDBStatusExportCDS")) 
     299                idMachine = cls.getIdMachine(CollaborationTools.getOptionValue("RecordingManager", "micalaDBMachineName")) 
     300                idTask    = cls.getIdTask(CollaborationTools.getOptionValue("RecordingManager", "micalaDBStatusExportCDS")) 
    293301                import re 
    294302                pattern_cern  = re.compile('([sc\d]+)$') 
    295303                pattern_umich = re.compile('(\d+\-[\w\d]+\-\d)$') 
    296                 idLecture = self.getIdLecture(pending, pattern_cern, pattern_umich) 
    297                 self.reportStatus("COMPLETE", "CDS record: %s" % new_record, idMachine, idTask, idLecture) 
     304                idLecture = cls.getIdLecture(pending, pattern_cern, pattern_umich) 
     305                cls.reportStatus("COMPLETE", "CDS record: %s" % new_record, idMachine, idTask, idLecture) 
    298306 
    299307                # I should still update the Lectures table to add the CDS record 
  • indico/MaKaC/plugins/Collaboration/RecordingManager/output.py

    rb04aa4 r34406d  
    66 
    77class MarcAccessListGenerator(object): 
    8     def __init__(self): 
    9         pass 
    108 
    11     def generateAccessListXML(self, out, obj): 
     9    @classmethod 
     10    def generateAccessListXML(cls, out, obj): 
    1211        """Generate a comprehensive access list showing all users and e-groups who may access 
    1312        this object, taking into account the permissions and access lists of its owners. 
     
    4140                out.closeTag("allowedAccessEmails") 
    4241 
    43     def generateVideoXML(self, out, recordingManagerTags): 
     42    @classmethod 
     43    def generateVideoXML(cls, out, recordingManagerTags): 
    4444        """Generate XML variables needed for video records.""" 
    4545 
     
    6262            out.writeTag("videoFormat", contentTypeWebLecture) 
    6363 
    64     def generateLanguagesXML(self, out, recordingManagerTags): 
     64    @classmethod 
     65    def generateLanguagesXML(cls, out, recordingManagerTags): 
    6566        """Generate XML variables needed for language information.""" 
    6667 
  • indico/MaKaC/plugins/Collaboration/RecordingManager/services.py

    rb04aa4 r34406d  
    3939    def _getAnswer(self): 
    4040#        here is where we make a submission to the database? 
    41         MicalaCommunication().updateMicala(self._params.get('IndicoID', None), self._params.get('LOID', None)) 
     41        MicalaCommunication.updateMicala(self._params.get('IndicoID', None), self._params.get('LOID', None)) 
    4242        return {'some':'thing'} 
    4343 
     
    7373    def _getAnswer(self): 
    7474        # Update the micala database 
    75         resultUpdateMicala = MicalaCommunication().updateMicala(self._IndicoID, 
     75        resultUpdateMicala = MicalaCommunication.updateMicala(self._IndicoID, 
    7676                                          self._contentType, 
    7777                                          self._params.get('LOID', None)) 
Note: See TracChangeset for help on using the changeset viewer.