本文整理汇总了Python中MaKaC.common.db.DBMgr类的典型用法代码示例。如果您正苦于以下问题:Python DBMgr类的具体用法?Python DBMgr怎么用?Python DBMgr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DBMgr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: rebuildRoomReservationsIndex
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()
示例2: countIndex
def countIndex(idxName):
DBMgr.getInstance().startRequest()
idx = IndexesHolder().getIndex(idxName)
print len(sum(idx._words.values(), []))
DBMgr.getInstance().endRequest()
示例3: checkLooseness
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"
示例4: _process
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())
示例5: setUp
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'
示例6: searchForId
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()
示例7: buildCategoryDateIndexLtd
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()
示例8: register
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()
示例9: main
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()
示例10: main
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()
示例11: tmp
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()
示例12: inverseCheckIndex
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()
示例13: findCamouflaged
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
示例14: __init__
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 = []
示例15: main
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()