Changeset 12168
- Timestamp:
- Oct 15, 2012, 10:20:29 AM (11 years ago)
- Location:
- xmlrpcplugin/trunk/tracrpc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
xmlrpcplugin/trunk/tracrpc/tests/ticket.py
r11306 r12168 269 269 # Update with collision check 270 270 import datetime 271 from tracrpc.xml_rpc import from_xmlrpc_datetime, to_xmlrpc_datetime 271 from tracrpc.util import to_utimestamp 272 from tracrpc.xml_rpc import from_xmlrpc_datetime 272 273 tid = self.admin.ticket.create('test_update_time_changed', '...', {}) 273 274 tid, created, modified, attrs = self.admin.ticket.get(tid) … … 276 277 try: 277 278 self.admin.ticket.update(tid, "comment1", 278 {'_ts': to_xmlrpc_datetime(then)})279 {'_ts': str(to_utimestamp(then))}) 279 280 except Exception, e: 280 281 self.assertTrue("Ticket has been updated since last get" in str(e)) … … 282 283 try: 283 284 self.admin.ticket.update(tid, "comment1", 284 {'_ts': to_xmlrpc_datetime(then),285 {'_ts': str(to_utimestamp(then)), 285 286 'action': 'leave'}) 286 287 except Exception, e: … … 289 290 290 291 def test_update_time_same(self): 291 # Update with collision check292 import datetime293 from tracrpc.xml_rpc import from_xmlrpc_datetime, to_xmlrpc_datetime294 295 292 # Unrestricted old-style update (to be removed soon) 296 293 tid = self.admin.ticket.create('test_update_time_same', '...', {}) -
xmlrpcplugin/trunk/tracrpc/ticket.py
r12105 r12168 25 25 26 26 from tracrpc.api import IXMLRPCHandler, expose_rpc, Binary 27 from tracrpc.util import StringIO, to_utimestamp 27 from tracrpc.util import StringIO, to_utimestamp, from_utimestamp 28 28 29 29 __all__ = ['TicketRPC'] … … 149 149 t = model.Ticket(self.env, id) 150 150 req.perm(t.resource).require('TICKET_VIEW') 151 t['_ts'] = str(t .time_changed)151 t['_ts'] = str(to_utimestamp(t.time_changed)) 152 152 return (t.id, t.time_created, t.time_changed, t.values) 153 153 … … 209 209 req.perm(t.resource).require('TICKET_MODIFY') 210 210 time_changed = attributes.pop('_ts', None) 211 if time_changed and str(time_changed) != str(t.time_changed): 211 if time_changed and \ 212 str(time_changed) != str(to_utimestamp(t.time_changed)): 212 213 raise TracError("Ticket has been updated since last get().") 213 214 for k, v in attributes.iteritems(): … … 218 219 tm = TicketModule(self.env) 219 220 # TODO: Deprecate update without time_changed timestamp 220 time_changed = str(attributes.pop('_ts', t.time_changed)) 221 time_changed = attributes.pop('_ts', to_utimestamp(t.time_changed)) 222 try: 223 time_changed = int(time_changed) 224 except ValueError: 225 raise TracError("RPC ticket.update: Wrong '_ts' token " \ 226 "in attributes (%r)." % time_changed) 221 227 action = attributes.get('action') 222 228 avail_actions = ts.get_available_actions(req, t) … … 232 238 req.args.update(attributes) 233 239 req.args['comment'] = comment 234 req.args['ts'] = time_changed 240 # Collision detection: 0.11+0.12 timestamp 241 req.args['ts'] = str(from_utimestamp(time_changed)) 242 # Collision detection: 0.13/1.0+ timestamp 243 req.args['view_time'] = str(time_changed) 235 244 changes, problems = tm.get_ticket_changes(req, t, action) 236 245 for warning in problems:
Note: See TracChangeset
for help on using the changeset viewer.