~hudson-openstack/burrow/trunk

« back to all changes in this revision

Viewing changes to burrow/backend/sqlite.py

  • Committer: Tarmac
  • Author(s): Eric Day
  • Date: 2011-08-10 07:28:01 UTC
  • mfrom: (16.3.24 backend-unittests)
  • Revision ID: tarmac-20110810072801-32ue4p8boiepxhjg
Pushed wait functionality down into backend, removed frontend tests since this is replaced with HTTP backend test now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
211
211
            raise burrow.backend.NotFound()
212
212
        return rows[0][0]
213
213
 
 
214
    @burrow.backend.wait_without_attributes
214
215
    def delete_messages(self, account, queue, filters={}):
215
216
        account_rowid = self._get_account(account)
216
217
        queue_rowid = self._get_queue(account_rowid, queue)
257
258
            return dict(id=row[0], ttl=ttl, hide=hide, body=str(row[3]))
258
259
        return None
259
260
 
 
261
    @burrow.backend.wait_without_attributes
260
262
    def get_messages(self, account, queue, filters={}):
261
263
        account_rowid = self._get_account(account)
262
264
        queue_rowid = self._get_queue(account_rowid, queue)
304
306
            return rows[0]
305
307
        return rows[0][0]
306
308
 
 
309
    @burrow.backend.wait_with_attributes
307
310
    def update_messages(self, account, queue, attributes, filters={}):
308
311
        account_rowid = self._get_account(account)
309
312
        queue_rowid = self._get_queue(account_rowid, queue)
329
332
            if self._update_messages(ttl, hide, ids):
330
333
                notify = True
331
334
        if notify:
332
 
            self.notify(account, queue)
 
335
            self._notify(account, queue)
333
336
 
334
337
    def _update_messages(self, ttl, hide, ids):
335
338
        query = 'UPDATE messages SET '
372
375
            self.db.execute(query, (queue_rowid, message, ttl, hide, body))
373
376
            created = True
374
377
        if created or hide == 0:
375
 
            self.notify(account, queue)
 
378
            self._notify(account, queue)
376
379
        return created
377
380
 
378
381
    def delete_message(self, account, queue, message, filters={}):
396
399
        detail = self._get_message_detail(filters)
397
400
        ttl, hide = self._get_attributes(attributes)
398
401
        if self._update_messages(ttl, hide, [row[0]]):
399
 
            self.notify(account, queue)
 
402
            self._notify(account, queue)
400
403
        row = list(row)
401
404
        if ttl is not None:
402
405
            row[2] = ttl
444
447
                'ON queues.account=accounts.rowid ' \
445
448
                'WHERE queues.rowid=?'
446
449
            result = self.db.execute(query, (queue,)).fetchall()[0]
447
 
            self.notify(result[0], result[1])
 
450
            self._notify(result[0], result[1])