Changeset d285dc in indico
- Timestamp:
- 03/22/11 15:35:01 (2 years ago)
- Branches:
- master, burotel, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
- Children:
- 8b580b
- Parents:
- 1ce14b
- Location:
- indico
- Files:
-
- 1 added
- 10 edited
-
MaKaC/common/utils.py (modified) (1 diff)
-
MaKaC/conference.py (modified) (2 diffs)
-
MaKaC/export/oai2.py (modified) (1 diff)
-
ext/livesync/agent.py (modified) (5 diffs)
-
ext/livesync/base.py (modified) (1 diff)
-
ext/livesync/bistate.py (modified) (3 diffs)
-
ext/livesync/cern_search/agent.py (modified) (2 diffs)
-
ext/livesync/components.py (modified) (4 diffs)
-
ext/livesync/invenio/agent.py (modified) (3 diffs)
-
ext/livesync/tasks.py (modified) (2 diffs)
-
util/event.py (added)
Legend:
- Unmodified
- Added
- Removed
-
indico/MaKaC/common/utils.py
r75d0bf rd285dc 570 570 elif isinstance(obj, conference.SubContribution): 571 571 ret="%s.%s.%s"%(obj.getConference().getId(), obj.getContribution().getId(), ret) 572 #elif isinstance(obj, conference.DeletedObject):573 #ret=obj.getId().replace(':','.')572 #elif isinstance(obj, conference.DeletedObject): 573 # ret=obj.getId().replace(':','.') 574 574 elif isinstance(obj, conference.Session): 575 575 ret="%s.s%s"%(obj.getConference().getId(), ret) -
indico/MaKaC/conference.py
r56f016 rd285dc 7577 7577 else: 7578 7578 parentId = None 7579 return "<Contribution %s:%s@%s>" % ( self.getId(), parentId, hex(id(self)))7579 return "<Contribution %s:%s@%s>" % (parentId, self.getId(), hex(id(self))) 7580 7580 7581 7581 def getTimezone( self ): … … 9760 9760 parentId = None 9761 9761 grandpaId = None 9762 return "<SubCont %s:%s:%s@%s>" % ( self.getId(), parentId, grandpaId, hex(id(self)))9762 return "<SubCont %s:%s:%s@%s>" % (grandpaId, parentId, self.getId(), hex(id(self))) 9763 9763 9764 9764 def isFullyPublic( self ): -
indico/MaKaC/export/oai2.py
ra25433 rd285dc 523 523 out = self._XMLGen 524 524 525 525 526 if deleted: 527 if type(obj) != str: 528 raise AttributeError("Expected int id, got '%s'" % obj) 529 526 530 out.openTag("record") 527 531 528 532 out.openTag("datafield",[["tag","970"],["ind1"," "],["ind2"," "]]) 529 out.writeTag("subfield","INDICO.%s" % self.getItemId(obj),[["code","a"]])533 out.writeTag("subfield","INDICO.%s" % obj,[["code","a"]]) 530 534 out.closeTag("datafield") 531 535 -
indico/ext/livesync/agent.py
r56f016 rd285dc 210 210 self._access = access 211 211 212 def _run(self, data, logger=None, monitor=None ):212 def _run(self, data, logger=None, monitor=None, dbi=None): 213 213 """ 214 214 Overloaded - will contain the specific agent code … … 231 231 """ 232 232 233 def run(self, currentTS, logger=None, monitor=None ):233 def run(self, currentTS, logger=None, monitor=None, dbi=None): 234 234 """ 235 235 Main method, called when agent needs to be run … … 256 256 records = self._generateRecords(data, till) 257 257 # run agent-specific cycle 258 result = self._run(records, logger=logger, monitor=monitor )258 result = self._run(records, logger=logger, monitor=monitor, dbi=dbi) 259 259 except: 260 260 if logger: … … 392 392 raise Exception("Unimplemented method!") 393 393 394 def iterateOver(self, iterator ):394 def iterateOver(self, iterator, dbi=None): 395 395 """ 396 396 Consumes an iterator, uploading the records that are returned 397 `dbi` can be passed, so that the cache is cleared once in a while 397 398 """ 398 399 … … 408 409 currentBatch.append(record) 409 410 411 if dbi: 412 dbi.abort() 413 410 414 if currentBatch: 411 415 self._uploadBatch(currentBatch) 412 416 413 417 return True 418 414 419 415 420 ################### -
indico/ext/livesync/base.py
r756437 rd285dc 46 46 """ 47 47 48 def __init__(self, timestamp, obj, actions ):48 def __init__(self, timestamp, obj, actions, objId): 49 49 self._timestamp = timestamp 50 50 self._obj = obj 51 self._objId = objId 51 52 self._actions = actions 52 53 53 54 def getObject(self): 54 55 return self._obj 56 57 def getObjectId(self): 58 return self._objId 55 59 56 60 def getActions(self): -
indico/ext/livesync/bistate.py
r56f016 rd285dc 114 114 115 115 for record, state in records.iteritems(): 116 yield record, state116 yield record, aw.getObjectId(), state 117 117 118 118 … … 147 147 return "{0:<40} {1}".format(obj, ' '.join(parts)) 148 148 149 def _getMetadata(self, records ):149 def _getMetadata(self, records, logger=None): 150 150 """ 151 151 Retrieves the MARCXML metadata for the record … … 160 160 xg.openTag("collection", [["xmlns", "http://www.loc.gov/MARC21/slim"]]) 161 161 162 for record, operation in records: 163 di.toMarc(record, overrideCache=True, 164 deleted=(operation & STATUS_DELETED)) 162 for record, recId, operation in records: 163 deleted = operation & STATUS_DELETED 164 try: 165 di.toMarc(recId if deleted else record, overrideCache=True, deleted=deleted) 166 # TODO: Replace with MetadataGenerationException or similar? 167 except AttributeError: 168 if logger: 169 logger.exception("Problem generating metadata for %s!" % record) 165 170 166 171 xg.closeTag("collection") -
indico/ext/livesync/cern_search/agent.py
ra5c240 rd285dc 50 50 self._password = password 51 51 52 def _run(self, records, logger=None, monitor=None ):52 def _run(self, records, logger=None, monitor=None, dbi=None): 53 53 54 54 self._v_logger = logger … … 63 63 64 64 # iterate over the returned records and upload them 65 return uploader.iterateOver(records )65 return uploader.iterateOver(records, dbi=dbi) 66 66 67 67 -
indico/ext/livesync/components.py
r94242c rd285dc 31 31 from indico.core.api.events import IAccessControlListener, IObjectLifeCycleListener, \ 32 32 IMetadataChangeListener 33 from indico.core.api.db import IDBUpdateListener, DBUpdateException34 33 from indico.core.api.rh import IServerRequestListener 35 34 from indico.util.date_time import int_timestamp, nowutc 35 from indico.util.event import uniqueId 36 36 37 37 # plugin imports 38 38 from indico.ext.livesync.base import ActionWrapper 39 from indico.ext.livesync.util import getPluginType40 39 from indico.ext.livesync.agent import SyncManager 41 40 … … 59 58 60 59 sm = SyncManager.getDBInstance() 61 track = sm.getTrack()62 60 cm = ContextManager.get('indico.ext.livesync:actions') 61 cm_ids = ContextManager.get('indico.ext.livesync:ids') 63 62 64 63 timestamp = int_timestamp(nowutc()) … … 71 70 # into the permanent one (MPT) 72 71 for obj, actions in cm.iteritems(): 72 objId = cm_ids[obj] 73 73 for action in actions: 74 Logger.get('ext.livesync').debug((obj , action))74 Logger.get('ext.livesync').debug((objId, action)) 75 75 # TODO: remove redundant items 76 76 sm.add(timestamp, 77 ActionWrapper(timestamp, obj, actions ))77 ActionWrapper(timestamp, obj, actions, objId)) 78 78 79 79 def requestRetry(self, obj, req, nretry): 80 80 # reset the context manager 81 81 ContextManager.set('indico.ext.livesync:actions', {}) 82 ContextManager.set('indico.ext.livesync:ids', {}) 82 83 83 84 def requestStarted(self, obj, req): 84 85 # reset the context manager 85 86 ContextManager.set('indico.ext.livesync:actions', {}) 87 ContextManager.set('indico.ext.livesync:ids', {}) 86 88 87 89 … … 105 107 obj, set([])) 106 108 109 107 110 # the context may not be initialized 108 111 if cm_set != None: 109 112 cm_set |= set(actions) 113 ContextManager.get('indico.ext.livesync:ids').setdefault( 114 obj, uniqueId(obj)) 110 115 111 116 def _protectionChanged(self, obj, oldValue, newValue): -
indico/ext/livesync/invenio/agent.py
rff6158 rd285dc 34 34 class InvenioBatchUploaderAgent(BistateBatchUploaderAgent): 35 35 36 def _run(self, records, logger=None, monitor=None ):36 def _run(self, records, logger=None, monitor=None, dbi=None): 37 37 38 38 self._v_logger = logger … … 48 48 49 49 # iterate over the returned records and upload them 50 return uploader.iterateOver(records )50 return uploader.iterateOver(records, dbi=None) 51 51 52 52 … … 71 71 72 72 self._logger.info('Generating metadata') 73 data = self._agent._getMetadata(batch )73 data = self._agent._getMetadata(batch, logger=self._logger) 74 74 self._logger.info('Metadata ready ') 75 75 -
indico/ext/livesync/tasks.py
r597fec rd285dc 18 18 ## along with CDS Indico; if not, write to the Free Software Foundation, Inc., 19 19 ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 20 21 # legacy imports 22 from MaKaC.common import DBMgr 20 23 21 24 # indico imports … … 47 50 logger.info("Starting agent '%s'" % agtName) 48 51 try: 52 dbi = DBMgr.getInstance() 49 53 # pass the current time and a logger 50 result = agent.run(int_timestamp(nowutc()), logger=logger )54 result = agent.run(int_timestamp(nowutc()), logger=logger, dbi=dbi) 51 55 except: 52 56 logger.exception("Problem running agent '%s'" % agtName)
Note: See TracChangeset
for help on using the changeset viewer.
