~romaia/bixo/trunk

« back to all changes in this revision

Viewing changes to bicho/interfaces.py

  • Committer: Ronaldo Maia
  • Date: 2009-08-26 13:34:56 UTC
  • mfrom: (191.1.12 drivers)
  • Revision ID: romaia@async.com.br-20090826133456-klj88o4l0obckpby
mergeĀ lp:~romaia/bixo/driversĀ changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import time
20
20
import urllib
21
21
 
 
22
from storm.locals import create_database, Store
 
23
 
22
24
from bicho.utils import debug
23
25
from bicho.progress import progress
24
26
 
48
50
    def want_bug(self, bug_id):
49
51
        pass
50
52
 
 
53
class DBBackend(Backend):
 
54
    setup_commands = None
 
55
 
 
56
    def done(self):
 
57
        self.store.commit()
 
58
 
 
59
    def check_configuration(self):
 
60
        valid = all([self.options.has_key(key) for key in
 
61
                        self.required_fields])
 
62
        if not valid:
 
63
            return False
 
64
 
 
65
        self.database = create_database(self.options['db_uri'])
 
66
        self.store = Store(self.database)
 
67
 
 
68
        # TODO: Add propper setup detection, and do not run this every time
 
69
        self.setup()
 
70
 
 
71
        return True
 
72
 
 
73
    def setup(self):
 
74
        driver = self.database.__class__.__name__
 
75
        commands = self.setup_commands[driver]
 
76
        [self.store.execute(c) for c in commands]
 
77
 
51
78
 
52
79
class Frontend(Interface):
53
80
    parser_class = None