work in progress: loops site synchronization: record job execution
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3734 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
ab4c01e88d
commit
e0240b5e82
4 changed files with 43 additions and 5 deletions
|
@ -8,6 +8,15 @@
|
||||||
<!--<zope:adapter factory="loops.system.setup.SetupManager"
|
<!--<zope:adapter factory="loops.system.setup.SetupManager"
|
||||||
name="system" />-->
|
name="system" />-->
|
||||||
|
|
||||||
|
<zope:class class="loops.system.job.JobRecord">
|
||||||
|
<require permission="zope.View"
|
||||||
|
interface="loops.system.interfaces.IJobRecord" />
|
||||||
|
<require permission="zope.ManageContent"
|
||||||
|
set_schema="loops.system.interfaces.IJobRecord" />
|
||||||
|
</zope:class>
|
||||||
|
|
||||||
|
<!-- views -->
|
||||||
|
|
||||||
<browser:page
|
<browser:page
|
||||||
name="setup_jobrecords.html"
|
name="setup_jobrecords.html"
|
||||||
for="loops.interfaces.ILoops"
|
for="loops.interfaces.ILoops"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -32,7 +32,15 @@ from loops.util import _
|
||||||
|
|
||||||
class IJobRecords(Interface):
|
class IJobRecords(Interface):
|
||||||
|
|
||||||
pass
|
def recordExecution(job, state, transcript, data=None):
|
||||||
|
""" Record the execution of a job (which may be a query or some other
|
||||||
|
kind of concept).
|
||||||
|
"""
|
||||||
|
|
||||||
|
def getLastRecordFor(job):
|
||||||
|
""" Use this for finding out when the job given has been run
|
||||||
|
most recently.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class IJobRecord(ITrack):
|
class IJobRecord(ITrack):
|
||||||
|
|
|
@ -42,6 +42,19 @@ class JobRecords(BaseRecordManager):
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
self.context = context
|
self.context = context
|
||||||
|
|
||||||
|
def recordExecution(self, job, state, transcript, **kw):
|
||||||
|
taskId = util.getUidForObject(job)
|
||||||
|
kw['state'] = state
|
||||||
|
kw['transcript'] = transcript
|
||||||
|
self.storage.saveUserTrack(taskId, 0, self.personId, kw)
|
||||||
|
|
||||||
|
def getLastRecordFor(self, job):
|
||||||
|
taskId = util.getUidForObject(job)
|
||||||
|
recs = self.storage.query(taskId=taskId)
|
||||||
|
if recs:
|
||||||
|
return sorted(recs, key=lambda x: x.timeStamp)[-1]
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class JobRecord(Track):
|
class JobRecord(Track):
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ from loops.browser.common import BaseView
|
||||||
from loops.browser.concept import ConceptView
|
from loops.browser.concept import ConceptView
|
||||||
from loops.external.base import Extractor
|
from loops.external.base import Extractor
|
||||||
from loops.external.interfaces import IWriter
|
from loops.external.interfaces import IWriter
|
||||||
|
from loops.system.job import JobRecords
|
||||||
from loops import util
|
from loops import util
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,6 +67,10 @@ class SyncChanges(ConceptView):
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
def lastSyncTimeStamp(self):
|
def lastSyncTimeStamp(self):
|
||||||
|
jobs = JobRecords(self.view.loopsRoot)
|
||||||
|
rec = jobs.getLastRecordFor(self.nodeView.virtualTargetObject)
|
||||||
|
if rec is not None:
|
||||||
|
return rec.timeStamp
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,11 +131,13 @@ class ChangesSave(FormController):
|
||||||
|
|
||||||
class ChangesSync(ChangesSave):
|
class ChangesSync(ChangesSave):
|
||||||
|
|
||||||
|
state = 'ok'
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.export()
|
self.export()
|
||||||
self.transfer()
|
self.transfer()
|
||||||
self.triggerImport()
|
self.triggerImport()
|
||||||
#self.recordExecution()
|
self.recordExecution()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def transfer(self):
|
def transfer(self):
|
||||||
|
@ -148,8 +155,9 @@ class ChangesSync(ChangesSave):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def recordExecution(self):
|
def recordExecution(self):
|
||||||
jobs = self.view.loopsRoot.getRecordManager()['jobs']
|
jobs = JobRecords(self.view.loopsRoot)
|
||||||
jobs.saveUserTrack()
|
jobs.recordExecution(self.view.virtualTargetObject,
|
||||||
|
self.state, self.transcript.getvalue())
|
||||||
|
|
||||||
|
|
||||||
class SyncImport(BaseView):
|
class SyncImport(BaseView):
|
||||||
|
|
Loading…
Add table
Reference in a new issue