Changeset 9097
- Timestamp:
- 9 Aug 2012, 08:58:14 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/interfaces.py
r9003 r9097 19 19 import re 20 20 import codecs 21 import zc.async.interfaces 21 22 import zope.i18nmessageid 22 23 from datetime import datetime … … 29 30 from zope.component import getUtility 30 31 from zope.component.interfaces import IObjectEvent 31 from zope.container.interfaces import INameChooser 32 from zope.configuration.fields import Path 33 from zope.container.interfaces import INameChooser, IContainer 32 34 from zope.interface import Interface, Attribute 33 35 from zope.schema.interfaces import IObject … … 39 41 DELETION_MARKER = 'XXX' 40 42 IGNORE_MARKER = '<IGNORE>' 43 WAEUP_KEY = 'waeup.kofa' 44 VIRT_JOBS_CONTAINER_NAME = 'jobs' 41 45 42 46 CREATED = 'created' … … 49 53 REGISTERED = 'courses registered' 50 54 VALIDATED = 'courses validated' 55 56 #: A dict giving job status as tuple (<STRING>, <TRANSLATED_STRING>), 57 #: the latter for UI purposes. 58 JOB_STATUS_MAP = { 59 zc.async.interfaces.NEW: ('new', _('new')), 60 zc.async.interfaces.COMPLETED: ('completed', _('completed')), 61 zc.async.interfaces.PENDING: ('pending', _('pending')), 62 zc.async.interfaces.ACTIVE: ('active', _('active')), 63 zc.async.interfaces.ASSIGNED: ('assigned', _('assigned')), 64 zc.async.interfaces.CALLBACKS: ('callbacks', _('callbacks')), 65 } 51 66 52 67 #default_rest_frontpage = u'' + codecs.open(os.path.join( … … 1081 1096 """ 1082 1097 1083 from zope.configuration.fields import Path 1098 1084 1099 class IDataCenterConfig(Interface): 1085 1100 path = Path( … … 1090 1105 ) 1091 1106 1107 # 1108 # Asynchronous job handling and related 1109 # 1110 class IJobManager(IKofaObject): 1111 """A manager for asynchronous running jobs (tasks). 1112 """ 1113 def put(job, site=None): 1114 """Put a job into task queue. 1115 1116 If no `site` is given, queue job in context of current local 1117 site. 1118 1119 Returns a job_id to identify the put job. This job_id is 1120 needed for further references to the job. 1121 """ 1122 1123 def jobs(site=None): 1124 """Get an iterable of jobs stored. 1125 """ 1126 1127 def get(job_id, site=None): 1128 """Get the job with id `job_id`. 1129 1130 For the `site` parameter see :meth:`put`. 1131 """ 1132 1133 def remove(job_id, site=None): 1134 """Remove job with `job_id` from stored jobs. 1135 """ 1136 1137 def start_test_job(site=None): 1138 """Start a test job. 1139 """ 1140 1141 class IProgressable(Interface): 1142 """A component that can indicate its progress status. 1143 """ 1144 percent = schema.Float( 1145 title = u'Percent of job done already.', 1146 ) 1147 1148 class IJobContainer(IContainer): 1149 """A job container contains IJob objects. 1150 """ 1151 1152 class IExportJob(zc.async.interfaces.IJob): 1153 def __init__(site, exporter_name): 1154 pass 1155 1156 class IExportJobContainer(Interface): 1157 """A component that contains (maybe virtually) export jobs. 1158 """ 1159 def start_export_job(exporter_name, user_id): 1160 """Start asynchronous export job. 1161 1162 `exporter_name` is the name of an exporter utility to be used. 1163 1164 `user_id` is the ID of the user that triggers the export. 1165 1166 The job_id is stored along with exporter name and user id in a 1167 persistent list. 1168 1169 Returns the job ID of the job started. 1170 """ 1171 1172 def get_running_export_jobs(user_id=None): 1173 """Get export jobs for user with `user_id` as list of tuples. 1174 1175 Each tuples holds ``<job_id>, <exporter_name>, <user_id>`` in 1176 that order. The ``<exporter_name>`` is the utility name of the 1177 used exporter. 1178 1179 If `user_id` is ``None``, all running jobs are returned. 1180 """ 1181 1182 def get_export_jobs_status(user_id=None): 1183 """Get running/completed export jobs for `user_id` as list of tuples. 1184 1185 Each tuple holds ``<raw status>, <status translated>, 1186 <exporter title>`` in that order, where ``<status 1187 translated>`` and ``<exporter title>`` are translated strings 1188 representing the status of the job and the human readable 1189 title of the exporter used. 1190 """ 1191 1192 def delete_export_entry(entry): 1193 """Delete the export denoted by `entry`. 1194 1195 Removes `entry` from the local `running_exports` list and also 1196 removes the regarding job via the local job manager. 1197 1198 `entry` is a tuple ``(<job id>, <exporter name>, <user id>)`` 1199 as created by :meth:`start_export_job` or returned by 1200 :meth:`get_running_export_jobs`. 1201 """
Note: See TracChangeset for help on using the changeset viewer.