当前位置: 首页>>代码示例>>Python>>正文


Python DBMgr.getInstance方法代码示例

本文整理汇总了Python中MaKaC.common.db.DBMgr.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Python DBMgr.getInstance方法的具体用法?Python DBMgr.getInstance怎么用?Python DBMgr.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MaKaC.common.db.DBMgr的用法示例。


在下文中一共展示了DBMgr.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: rebuildRoomReservationsIndex

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
    def rebuildRoomReservationsIndex():
        from MaKaC.common.db import DBMgr
        from MaKaC.rb_location import CrossLocationDB
        from MaKaC.rb_room import RoomBase
        from MaKaC.plugins.RoomBooking.default.dalManager import DALManager
        from BTrees.OOBTree import OOBTree

        DBMgr.getInstance().startRequest()
        CrossLocationDB.connect()
        root = DALManager.root

        resvEx = ReservationBase()
        resvEx.isConfirmed = None
        allResvs = CrossLocationQueries.getReservations( resvExample = resvEx )
        print "There are " + str( len( allResvs ) ) + " resvs and pre-resvs to index..."
        c = 0
        
        root[_ROOM_RESERVATIONS_INDEX] = OOBTree()
        print "Room => Reservations Index branch created"
        
        for resv in allResvs:
            roomReservationsIndexBTree = root[_ROOM_RESERVATIONS_INDEX]
            resvs = roomReservationsIndexBTree.get( resv.room.id )
            if resvs == None:
                resvs = [] # New list of reservations for this room
                roomReservationsIndexBTree.insert( resv.room.id, resvs )
            resvs.append( resv )
            roomReservationsIndexBTree[resv.room.id] = resvs
            c += 1
            if c % 100 == 0:
                print c
        
        CrossLocationDB.commit()
        CrossLocationDB.disconnect()
        DBMgr.getInstance().endRequest()
开发者ID:davidmorrison,项目名称:indico,代码行数:37,代码来源:reservation.py

示例2: countIndex

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
def countIndex(idxName):
    DBMgr.getInstance().startRequest()
    idx = IndexesHolder().getIndex(idxName)

    print len(sum(idx._words.values(), []))

    DBMgr.getInstance().endRequest()
开发者ID:lukasnellen,项目名称:indico,代码行数:9,代码来源:oaiindexes.py

示例3: checkLooseness

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
    def checkLooseness(self, k, c, fix):
        orphan = False
        parent = getParent(c)
        if parent == None:
            print "[1st deg ORPHAN] %s\n" % prettyPrint(c)
            orphan = True
        elif hasattr(parent, "getOwnerList") and parent.getOwnerList() == []:
            print "[2nd deg ORPHAN] %s %s\n" % (prettyPrint(c), parent)
            orphan = True

        if orphan and fix:

            DBMgr.getInstance().sync()

            print "Fixing %s..." % prettyPrint(c),
            if orphan:
                words = self.idx._words
                l = words[k]
                pos = l.index(c)
                print "del val %s\n" % l[pos]
                del l[pos]
                words[k] = l
                self.idx.setIndex(words)

                ids = self.idx._ids
                l = ids[k]
                print "del key %s\n" % l[pos]
                del l[pos]
                ids[k] = l

            DBMgr.getInstance().commit()

            print "Done!\n"
开发者ID:lukasnellen,项目名称:indico,代码行数:35,代码来源:oaiindexes.py

示例4: _process

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
 def _process( self ):
     if not self._cancel:
         if not self._confirmed:
             p=RHMaintenancePack(self)
             return p.display()
         DBMgr.getInstance().pack()
     self._redirect(urlHandlers.UHMaintenance.getURL())
开发者ID:VishrutMehta,项目名称:indico,代码行数:9,代码来源:maintenance.py

示例5: setUp

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
 def setUp(self):
     DBMgr.getInstance().startRequest()
     self.oldIndex = IndexesHolder()._getIdx()["categoryDateLtd"]
     self.newIndex = IndexesHolder()._getIdx()["categoryDate"]
     self.startDate = datetime(2010,5,13, 10, 0, 0, tzinfo=timezone('UTC'))
     self.endDate = datetime(2010,5,14, 14, 0, 0, tzinfo=timezone('UTC'))
     self.ch = ConferenceHolder()
     self.categId = '0'
开发者ID:VishrutMehta,项目名称:indico,代码行数:10,代码来源:calendarDateIndex.py

示例6: searchForId

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
def searchForId(idxName, id):
    DBMgr.getInstance().startRequest()
    idx = IndexesHolder().getIndex(idxName)

    for k, l in idx._words.iteritems():
        for v in l[:]:
            if v.id == id:
                print "%s" % k
    DBMgr.getInstance().endRequest()
开发者ID:lukasnellen,项目名称:indico,代码行数:11,代码来源:oaiindexes.py

示例7: buildCategoryDateIndexLtd

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
def buildCategoryDateIndexLtd():
    """ Builds limited version of CategoryDateIndex.
        Can take a long time
    """
    DBMgr.getInstance().startRequest()
    idx = CategoryDateIndexLtd()
    idx.buildIndex()
    IndexesHolder()._getIdx()["categoryDateLtd"] = idx
    DBMgr.getInstance().endRequest()
开发者ID:VishrutMehta,项目名称:indico,代码行数:11,代码来源:calendarDateIndex.py

示例8: register

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
 def register(interval=15):
     from indico.modules.scheduler import Client
     from dateutil.rrule import MINUTELY
     from MaKaC.common import DBMgr
     DBMgr.getInstance().startRequest()
     task = OutlookUpdateCalendarNotificationTask(MINUTELY, interval=interval)
     client = Client()
     client.enqueue(task)
     DBMgr.getInstance().endRequest()
开发者ID:VishrutMehta,项目名称:indico,代码行数:11,代码来源:tasks.py

示例9: main

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
def main( **kwargs ):
    location = kwargs.get( 'location', 'Universe' )
    
    from MaKaC.rb_factory import Factory
    from MaKaC.common.db import DBMgr
    DBMgr.getInstance().startRequest()
    Factory.getDALManager().connect()

    initializeRoomBookingDB( location, force = True )

    Factory.getDALManager().disconnect()
    DBMgr.getInstance().endRequest()
开发者ID:davidmorrison,项目名称:indico,代码行数:14,代码来源:initialize.py

示例10: main

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
def main():
    DBMgr.getInstance().startRequest()
    print _("Is working day: ")
    print str( HolidaysHolder.isWorkingDay( date( 2007, 5, 1 ) ) )
    print str( HolidaysHolder.isWorkingDay( date( 2007, 5, 2 ) ) )
    print str( HolidaysHolder.isWorkingDay( date( 2007, 9, 5 ) ) )

    h = HolidaysHolder.getHolidays()
    for day in h:
        if day.year == 2007:
            print day

    DBMgr.getInstance().endRequest()
开发者ID:davidmorrison,项目名称:indico,代码行数:15,代码来源:utils.py

示例11: tmp

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
    def tmp():
        from MaKaC.rb_factory import Factory
        from MaKaC.rb_room import RoomBase
        from MaKaC.common.db import DBMgr
        from BTrees.OOBTree import OOBTree

        DBMgr.getInstance().startRequest()
        Factory.getDALManager().connect()

        dayReservationsIndexBTree = OOBTree()
        raise str( dir( dayReservationsIndexBTree ) )
        
        Factory.getDALManager().disconnect()
        DBMgr.getInstance().endRequest()
开发者ID:davidmorrison,项目名称:indico,代码行数:16,代码来源:reservation.py

示例12: inverseCheckIndex

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
def inverseCheckIndex(idxName):
    DBMgr.getInstance().startRequest()

    idx = IndexesHolder().getIndex(idxName)

    if idxName == "OAIConferenceModificationDate":
        OAIConferenceModificationDate(idx).inverseCheck()
    elif idxName == "OAIPrivateConferenceModificationDate":
        OAIPrivateConferenceModificationDate(idx).inverseCheck()
    else:
        print "No inverse checking procedures defined for %s" % idxName
        sys.exit(-1)

    DBMgr.getInstance().endRequest()
开发者ID:lukasnellen,项目名称:indico,代码行数:16,代码来源:oaiindexes.py

示例13: findCamouflaged

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
def findCamouflaged(fix=False,fromDate=None):

    table = {
        0: [Conference],
        1: [Contribution, AcceptedContribution],
        2: [SubContribution]
    }

    dbi = DBMgr.getInstance()
    dbi.startRequest()

    camouflaged = []
    doh = DeletedObjectHolder()

    for obj in doh.getList():
        types = table[obj.getId().count(":")]
        if not obj._objClass in types:
            camouflaged.append(obj)
            print "-- CAMOUFLAGED %s (%s) should be in %s" % (prettyPrint(obj),
                                                           obj._objClass,
                                                           types)

    if fix:
        for c in camouflaged:
            dbi.sync()
            doh.remove(c)
            dbi.commit()
            print "-- FIXED %s " % prettyPrint(c)

    dbi.endRequest()
    print "\n Total of %s camouflaged conferences found" % len(camouflaged)

    return camouflaged
开发者ID:davidmorrison,项目名称:indico,代码行数:35,代码来源:doh.py

示例14: __init__

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
    def __init__( self, rh ):
        config = Config.getInstance()
        db_connected = DBMgr.getInstance().isConnected()

        self._rh = rh
        self._locTZ = ""

        self._asset_env = Environment(config.getHtdocsDir(), '')

        if db_connected:
            debug = HelperMaKaCInfo.getMaKaCInfoInstance().isDebugActive()
        else:
            debug = False

        # This is done in order to avoid the problem sending the error report because the DB is not connected.
        if db_connected:
            info = HelperMaKaCInfo.getMaKaCInfoInstance()
            self._asset_env.debug = info.isDebugActive()

        self._dir = config.getTPLDir()
        self._asset_env.debug = debug

        if db_connected:
            css_file = config.getCssStylesheetName()
        else:
            css_file = 'Default.css'

        # register existing assets
        assets.register_all_js(self._asset_env)
        assets.register_all_css(self._asset_env, css_file)

        #store page specific CSS and JS
        self._extraCSS = []
        self._extraJS = []
开发者ID:VishrutMehta,项目名称:indico,代码行数:36,代码来源:base.py

示例15: main

# 需要导入模块: from MaKaC.common.db import DBMgr [as 别名]
# 或者: from MaKaC.common.db.DBMgr import getInstance [as 别名]
def main(argv):
    DBMgr.getInstance().startRequest()

    print "Req start at " + str(datetime.now())

    if "migrate" in argv:
        migrateCategoryDateIndex()
    if "switch" in argv:
        switchIndex()
    if "removeBackup" in argv:
        deleteBackup()
    if "display" in argv:
        displayIndexes()

    print "Req ends at " + str(datetime.now())
    DBMgr.getInstance().endRequest()
开发者ID:VishrutMehta,项目名称:indico,代码行数:18,代码来源:CategoryDate.py


注:本文中的MaKaC.common.db.DBMgr.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。