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


Python CrossLocationDB.disconnect方法代码示例

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


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

示例1: rebuildRoomReservationsIndex

# 需要导入模块: from MaKaC.rb_location import CrossLocationDB [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationDB import disconnect [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: _endRequestSpecific2RH

# 需要导入模块: from MaKaC.rb_location import CrossLocationDB [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationDB import disconnect [as 别名]
def _endRequestSpecific2RH( commit = True ):
    minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
    if minfo.getRoomBookingModuleActive():
        if commit:
            CrossLocationDB.commit()
        else:
            CrossLocationDB.rollback()
        CrossLocationDB.disconnect()
开发者ID:aninhalacerda,项目名称:indico,代码行数:10,代码来源:process.py

示例3: play

# 需要导入模块: from MaKaC.rb_location import CrossLocationDB [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationDB import disconnect [as 别名]
    def play():
        from MaKaC.rb_location import CrossLocationDB
        from MaKaC.rb_room import RoomBase
        from MaKaC.common.db import DBMgr

        DBMgr.getInstance().startRequest()
        CrossLocationDB.connect()

        roomEx = RoomBase()
        roomEx.isActive = False
        rooms = CrossLocationQueries.getRooms( roomExample = roomEx )
        for r in rooms:
            print r
            
        CrossLocationDB.commit()
        CrossLocationDB.disconnect()
        DBMgr.getInstance().endRequest()
开发者ID:davidmorrison,项目名称:indico,代码行数:19,代码来源:reservation.py

示例4: indexByDay

# 需要导入模块: from MaKaC.rb_location import CrossLocationDB [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationDB import disconnect [as 别名]
    def indexByDay():
        from MaKaC.rb_location import CrossLocationDB
        from MaKaC.rb_room import RoomBase
        from MaKaC.common.db import DBMgr

        DBMgr.getInstance().startRequest()
        CrossLocationDB.connect()

#        resvEx = ReservationBase()
#        resvEx.isConfirmed = None
#        resvs = CrossLocationQueries.getReservations( resvExample = resvEx )
#        print "There are " + str( len( resvs ) ) + " resvs to index..."
#        c = 0
#        for resv in resvs:
#            resv._addToDayReservationsIndex()
#            c += 1
#            if c % 100 == 0:
#                print c
        
        CrossLocationDB.commit()
        CrossLocationDB.disconnect()
        DBMgr.getInstance().endRequest()
开发者ID:davidmorrison,项目名称:indico,代码行数:24,代码来源:reservation.py

示例5: execute

# 需要导入模块: from MaKaC.rb_location import CrossLocationDB [as 别名]
# 或者: from MaKaC.rb_location.CrossLocationDB import disconnect [as 别名]

#.........这里部分代码省略.........

            minfo = HelperMaKaCInfo.getMaKaCInfoInstance()

            if minfo.getRoomBookingModuleActive():
                CrossLocationDB.connect()
            ###
            taskList = HelperTaskList().getTaskListInstance()
            tasks = taskList.getTasks()
            if len(tasks) == 0:
                self._printOutput("--->No tasks!")
            else:
                self._printOutput("Execute at %s\n"%datetime.now())
            taskids = [i.getId() for i in tasks]
            for id in taskids:
                ### check if another thread have already removed the task
                conn.sync()
                if not id in taskList.listTask.keys():
                    continue
                task = taskList.getTaskById(id)
                ###
                if task.isRunning():
                    self._printOutput("\t--->Task <%s> already running"%task.getId())
                else:
                    try:
                        self._printOutput("\t--->Running task <%s>"%task.getId())

                        if task.getStartDate() == None or task.getStartDate() < nowutc():
                            self._printOutput("\t (SINGLE RUN)")
                            # the task is started
                            if task.getInterval() == None or task.getLastDate() == None:
                                # the task is run once or never runned
                                task.setRunning(True)
                                conn.commit()
                                abort=task.prerun()
                                if abort:
                                    self._printOutput("\t<---Task <%s> was aborted."%task.getId())
                                    task.setRunning(False)
                                    conn.commit()
                                    continue
                                for obj in task.getObjList():
                                    self._printOutput("\t\tRunning object <%s> (start date: %s)"%(obj.getId(),task.getStartDate()))
                                    #task.setLastDate(datetime.now())

                                    self._runObj(obj)

                                    self._printOutput("\t\tEnd object")
                                task.setLastDate(nowutc())
                                task.setRunning(False)
                                if task.getInterval() == None:
                                    # if run once, delete the task from list
                                    taskList.removeTask(task)
                                    self._printOutput("\t\tTask was removed")
                                else:
                                    self._printOutput("\t\tTask is periodic (getInterval: %s)" % task.getInterval())
                            else:
                                self._printOutput("\t (PERIODIC TASK)")
                                # the task is to be run multiple times
                                if task.getLastDate() + task.getInterval() < nowutc():
                                    task.setRunning(True)
                                    conn.commit()
                                    abort=task.prerun()
                                    if abort:
                                        self._printOutput("\t<---Task <%s> was aborted."%task.getId())
                                        task.setRunning(False)
                                        conn.commit()
                                        continue
                                    # it's time to launch the task!!!
                                    for obj in task.getObjList():
                                        self._printOutput("\tRunning object %s (last date: %s)"%(obj.getId(),task.getLastDate()))
                                        #task.setLastDate(datetime.now())

                                        self._runObj(obj)

                                        self._printOutput("\t\tEnd object")
                                    if task.getLastDate() and task.getEndDate():
                                        if task.getLastDate() + task.getInterval() > task.getEndDate():
                                            # the task is finish, delete it from list
                                            taskList.removeTask(task)
                                            self._printOutput("\t\tTask was removed")
                                    task.setLastDate(nowutc())
                                    task.setRunning(False)
                        self._printOutput("\t<---end task <%s>\n"%task.getId())
                        conn.commit()
                    except Exception, e:
                        conn.sync()
                        task.setRunning(False)
                        conn.commit()
                        ty, ex, tb = sys.exc_info()
                        tracebackList = traceback.format_list( traceback.extract_tb( tb ) )
                        self._printOutput("*****---->[ERROR]:%s\nTraceback:%s"%(e,"\n".join(tracebackList)))
                        self._sendErrorEmail(e)

            if minfo.getRoomBookingModuleActive():
                CrossLocationDB.commit()
                CrossLocationDB.disconnect()

            conn.endRequest()

            self._printOutput("***end execute***\n\n")
            self._closeLog()
开发者ID:bubbas,项目名称:indico,代码行数:104,代码来源:timerExec.py


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