~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/scripts/base.py

  • Committer: Jelmer Vernooij
  • Date: 2011-09-21 14:28:02 UTC
  • mfrom: (14006 devel)
  • mto: This revision was merged to the branch mainline in revision 14010.
  • Revision ID: jelmer@canonical.com-20110921142802-7ggkc204igsy532w
MergeĀ lp:launchpad

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    LockAlreadyAcquired,
31
31
    )
32
32
import pytz
 
33
import transaction
33
34
from zope.component import getUtility
34
35
 
35
 
from canonical.config import config
36
 
from canonical.database.sqlbase import ISOLATION_LEVEL_DEFAULT
 
36
from canonical.config import config, dbconfig
 
37
from canonical.database.postgresql import ConnectionString
 
38
from canonical.database.sqlbase import (
 
39
    ISOLATION_LEVEL_DEFAULT,
 
40
    ZopelessTransactionManager,
 
41
    )
37
42
from canonical.launchpad import scripts
38
43
from canonical.launchpad.scripts.logger import OopsHandler
39
44
from canonical.launchpad.webapp.errorlog import globalErrorUtility
41
46
    ANONYMOUS,
42
47
    setupInteractionByEmail,
43
48
    )
44
 
from canonical.lp import initZopeless
45
49
from lp.services.features import (
46
50
    get_relevant_feature_controller,
47
51
    install_feature_controller,
352
356
 
353
357
        Can be overriden for testing purpose.
354
358
        """
355
 
        self.txn = initZopeless(dbuser=self.dbuser, isolation=isolation)
 
359
        dbuser = self.dbuser
 
360
        if dbuser is None:
 
361
            connstr = ConnectionString(dbconfig.main_master)
 
362
            dbuser = connstr.user or dbconfig.dbuser
 
363
        ZopelessTransactionManager.initZopeless(
 
364
            dbuser=dbuser, isolation=isolation)
 
365
        self.txn = transaction
356
366
 
357
367
    def record_activity(self, date_started, date_completed):
358
368
        """Hook to record script activity."""