~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/database/sqlbase.py

  • Committer: Stuart Bishop
  • Date: 2012-01-04 08:32:16 UTC
  • mfrom: (8758.3.28 garbo)
  • mto: This revision was merged to the branch mainline in revision 14630.
  • Revision ID: stuart.bishop@canonical.com-20120104083216-u40lz91ftkpzsqqp
Merged garbo into garbo-bulk-pruner.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
from zope.interface import implements
57
57
from zope.security.proxy import removeSecurityProxy
58
58
 
59
 
from canonical.config import dbconfig
60
 
from canonical.database.interfaces import ISQLBase
 
59
from lp.services.config import dbconfig
 
60
from lp.services.database.interfaces import ISQLBase
61
61
from lp.services.propertycache import clear_property_cache
62
62
 
63
63
# Default we want for scripts, and the PostgreSQL default. Note psycopg1 will
112
112
    """Return the store used by the SQLObject compatibility layer."""
113
113
    # XXX: Stuart Bishop 20080725 bug=253542: The import is here to work
114
114
    # around a particularly convoluted circular import.
115
 
    from canonical.launchpad.webapp.interfaces import (
 
115
    from lp.services.webapp.interfaces import (
116
116
            IStoreSelector, MAIN_STORE, DEFAULT_FLAVOR)
117
117
    return getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
118
118
 
170
170
        We refetch any parameters from different stores from the
171
171
        correct master Store.
172
172
        """
173
 
        from canonical.launchpad.interfaces.lpstorm import IMasterStore
 
173
        from lp.services.database.lpstorm import IMasterStore
174
174
        # Make it simple to write dumb-invalidators - initialized
175
175
        # _cached_properties to a valid list rather than just-in-time
176
176
        # creation.
207
207
 
208
208
    @classmethod
209
209
    def _get_store(cls):
210
 
        from canonical.launchpad.interfaces.lpstorm import IStore
 
210
        from lp.services.database.lpstorm import IStore
211
211
        return IStore(cls)
212
212
 
213
213
    def __repr__(self):
217
217
        return '<%s at 0x%x>' % (self.__class__.__name__, id(self))
218
218
 
219
219
    def destroySelf(self):
220
 
        from canonical.launchpad.interfaces.lpstorm import IMasterObject
 
220
        from lp.services.database.lpstorm import IMasterObject
221
221
        my_master = IMasterObject(self)
222
222
        if self is my_master:
223
223
            super(SQLBase, self).destroySelf()
540
540
    """A decorator that blocks implicit flushes on the main store."""
541
541
 
542
542
    def block_implicit_flushes_decorator(*args, **kwargs):
543
 
        from canonical.launchpad.webapp.interfaces import DisallowedStore
 
543
        from lp.services.webapp.interfaces import DisallowedStore
544
544
        try:
545
545
            store = _get_sqlobject_store()
546
546
        except DisallowedStore:
590
590
    """
591
591
    # We must connect to the read-write DB here, so we use rw_main_master
592
592
    # directly.
593
 
    from canonical.database.postgresql import ConnectionString
 
593
    from lp.services.database.postgresql import ConnectionString
594
594
    con_str = ConnectionString(dbconfig.rw_main_master)
595
595
    if user is not None:
596
596
        con_str.user = user