本文整理汇总了Python中MaKaC.plugins.RoomBooking.default.factory.Factory.getDALManager方法的典型用法代码示例。如果您正苦于以下问题:Python Factory.getDALManager方法的具体用法?Python Factory.getDALManager怎么用?Python Factory.getDALManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.plugins.RoomBooking.default.factory.Factory
的用法示例。
在下文中一共展示了Factory.getDALManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: listResv4User
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
def listResv4User(user):
dbi = DBMgr.getInstance()
dbi.startRequest()
Factory.getDALManager().connect()
resvEx = ReservationBase()
resvEx.createdBy = user
allResv = CrossLocationQueries.getReservations( resvExample = resvEx)
print "User %s has %s resevations created by him/her"%(user, len(allResv))
Factory.getDALManager().disconnect()
dbi.endRequest()
示例2: tmp
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
def tmp():
from MaKaC.rb_factory import Factory
from MaKaC.rb_room import RoomBase
from indico.core.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()
示例3: setPossibleEquipment
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
def setPossibleEquipment( equipmentList, *args, **kwargs ):
from MaKaC.rb_location import Location
location = kwargs.get( 'location', Location.getDefaultLocation().friendlyName )
lst = EquipmentManager.getRoot()
lst[location] = equipmentList
Factory.getDALManager().getRoot()[_EQUIPMENT_LIST] = lst # Force update
示例4: removeEquipment
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
def removeEquipment( equipmentName, *args, **kwargs ):
from MaKaC.rb_location import Location
location = kwargs.get( 'location', Location.getDefaultLocation().friendlyName )
lst = EquipmentManager.getRoot()
lst[location].remove( equipmentName )
Factory.getDALManager().getRoot()[_EQUIPMENT_LIST] = lst
示例5: insertEquipment
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
def insertEquipment( equipmentName, *args, **kwargs ):
from MaKaC.rb_location import Location
location = kwargs.get( 'location', Location.getDefaultLocation().friendlyName )
lst = EquipmentManager.getRoot()
if lst.get( location ) == None:
lst[location] = []
lst[location].append( equipmentName )
Factory.getDALManager().getRoot()[_EQUIPMENT_LIST] = lst
示例6: getPossibleEquipment
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
def getPossibleEquipment( *args, **kwargs ):
from MaKaC.rb_location import Location
location = kwargs.get( 'location', Location.getDefaultLocation().friendlyName )
lst = EquipmentManager.getRoot()
if lst.get( location ) == None:
lst[location] = []
Factory.getDALManager().getRoot()[_EQUIPMENT_LIST] = lst
return lst[location]
示例7: setAttributes
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
def setAttributes( attsList, *args, **kwargs ):
location = kwargs.get( 'location', Location.getDefaultLocation().friendlyName )
for at in attsList:
errors = CustomAttributesManagerBase.checkAttribute( at )
if errors: raise str( errors )
dic = CustomAttributesManager.getRoot()
dic[location] = attsList
root = Factory.getDALManager().root
root[_CUSTOM_ATTRIBUTES_LIST] = dic
示例8: reservation
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
def reservation(self, locList):
Factory.getDALManager().connect()
resvEx = ReservationBase()
resvEx.startDT = self._fromDT
resvEx.endDT = self._toDT
locList = filter(lambda loc: Location.parse(loc) is not None, locList)
if self._fromDT or self._toDT:
daysParam = (day.date() for day in rrule.rrule(rrule.DAILY, dtstart=self._fromDT, until=self._toDT))
else:
# slow!
daysParam = None
for loc in sorted(locList):
resvs = CrossLocationQueries.getReservations(location=loc, resvExample=resvEx, days=daysParam)
for obj in self._process(resvs, filter=self._resvFilter):
yield obj
Factory.getDALManager().disconnect()
示例9: changeCreator
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
def changeCreator(oldUser, newUser):
dbi = DBMgr.getInstance()
dbi.startRequest()
Factory.getDALManager().connect()
# check if the users exist
if AvatarHolder().getById(oldUser) is None:
print "There is no user with id %s"%oldUser
return
if AvatarHolder().getById(newUser) is None:
print "There is no user with id %s"%newUser
return
resvEx = ReservationBase()
resvEx.createdBy = oldUser
allResv4OldUser = CrossLocationQueries.getReservations( resvExample = resvEx)
if allResv4OldUser == []:
print "No reservations for user %s"%oldUser
return
# resvs = ReservationBase.getReservations()
# allResv4OldUser = [x for x in allResv if x.createdBy == oldUser]
if type(allResv4OldUser) is not list:
allResv4OldUser = [allResv4OldUser]
# Modify reservations
for r in allResv4OldUser:
r.createdBy = newUser
#print r.createdBy, r.id
# Update index
userReservationsIndexBTree = Reservation.getUserReservationsIndexRoot()
newUserResvs = userReservationsIndexBTree.get( newUser )
if newUserResvs == None:
newUserResvs = [] # New list of reservations for this room
userReservationsIndexBTree.insert( newUser, newUserResvs )
newUserResvs.extend( allResv4OldUser )
userReservationsIndexBTree[newUser] = newUserResvs[:]
if userReservationsIndexBTree.has_key(oldUser):
userReservationsIndexBTree.pop(oldUser)
userReservationsIndexBTree._p_changed = 1
# close DB connection
Factory.getDALManager().commit()
Factory.getDALManager().disconnect()
dbi.endRequest()
print "%s reservations have moved from creator %s to creator %s" % (len(allResv4OldUser), oldUser, newUser)
示例10: search
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
def search(self, location, name):
Factory.getDALManager().connect()
rooms = CrossLocationQueries.getRooms(location=location)
def _search_rooms(name):
return (room for room in rooms if name in room.getFullName())
for obj in self._process(_search_rooms(name)):
yield obj
Factory.getDALManager().rollback()
Factory.getDALManager().disconnect()
示例11: room
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
def room(self, location, idlist):
Factory.getDALManager().connect()
rooms = CrossLocationQueries.getRooms(location=location)
def _iterate_rooms(objIds):
objIds = map(int, objIds)
return (room for room in rooms if room.id in objIds)
for obj in self._process(_iterate_rooms(idlist)):
yield obj
Factory.getDALManager().rollback()
Factory.getDALManager().disconnect()
示例12: getRoot
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
def getRoot():
return Factory.getDALManager().getRoot(_EQUIPMENT_LIST)
示例13: handler
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
def handler(prefix, path):
path = posixpath.join('/', prefix, path)
ContextManager.destroy()
clearCache() # init fossil cache
logger = Logger.get('httpapi')
if request.method == 'POST':
# Convert POST data to a query string
queryParams = dict((key, value.encode('utf-8')) for key, value in request.form.iteritems())
query = urllib.urlencode(queryParams)
else:
# Parse the actual query string
queryParams = dict((key, value.encode('utf-8')) for key, value in request.args.iteritems())
query = request.query_string
dbi = DBMgr.getInstance()
dbi.startRequest()
minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
if minfo.getRoomBookingModuleActive():
Factory.getDALManager().connect()
apiKey = get_query_parameter(queryParams, ['ak', 'apikey'], None)
cookieAuth = get_query_parameter(queryParams, ['ca', 'cookieauth'], 'no') == 'yes'
signature = get_query_parameter(queryParams, ['signature'])
timestamp = get_query_parameter(queryParams, ['timestamp'], 0, integer=True)
noCache = get_query_parameter(queryParams, ['nc', 'nocache'], 'no') == 'yes'
pretty = get_query_parameter(queryParams, ['p', 'pretty'], 'no') == 'yes'
onlyPublic = get_query_parameter(queryParams, ['op', 'onlypublic'], 'no') == 'yes'
onlyAuthed = get_query_parameter(queryParams, ['oa', 'onlyauthed'], 'no') == 'yes'
oauthToken = 'oauth_token' in queryParams
# Get our handler function and its argument and response type
hook, dformat = HTTPAPIHook.parseRequest(path, queryParams)
if hook is None or dformat is None:
raise NotFound
# Disable caching if we are not just retrieving data (or the hook requires it)
if request.method == 'POST' or hook.NO_CACHE:
noCache = True
ak = error = result = None
ts = int(time.time())
typeMap = {}
responseUtil = ResponseUtil()
try:
used_session = None
if cookieAuth:
used_session = session
if not used_session.user: # ignore guest sessions
used_session = None
if apiKey or oauthToken or not used_session:
if not oauthToken:
# Validate the API key (and its signature)
ak, enforceOnlyPublic = checkAK(apiKey, signature, timestamp, path, query)
if enforceOnlyPublic:
onlyPublic = True
# Create an access wrapper for the API key's user
aw = buildAW(ak, onlyPublic)
else: # Access Token (OAuth)
at = OAuthUtils.OAuthCheckAccessResource()
aw = buildAW(at, onlyPublic)
# Get rid of API key in cache key if we did not impersonate a user
if ak and aw.getUser() is None:
cacheKey = normalizeQuery(path, query,
remove=('_', 'ak', 'apiKey', 'signature', 'timestamp', 'nc', 'nocache',
'oa', 'onlyauthed'))
else:
cacheKey = normalizeQuery(path, query,
remove=('_', 'signature', 'timestamp', 'nc', 'nocache', 'oa', 'onlyauthed'))
if signature:
# in case the request was signed, store the result under a different key
cacheKey = 'signed_' + cacheKey
else:
# We authenticated using a session cookie.
if Config.getInstance().getCSRFLevel() >= 2:
token = request.headers.get('X-CSRF-Token', get_query_parameter(queryParams, ['csrftoken']))
if used_session.csrf_protected and used_session.csrf_token != token:
raise HTTPAPIError('Invalid CSRF token', 403)
aw = AccessWrapper()
if not onlyPublic:
aw.setUser(used_session.user)
userPrefix = 'user-' + used_session.user.getId() + '_'
cacheKey = userPrefix + normalizeQuery(path, query,
remove=('_', 'nc', 'nocache', 'ca', 'cookieauth', 'oa', 'onlyauthed',
'csrftoken'))
# Bail out if the user requires authentication but is not authenticated
if onlyAuthed and not aw.getUser():
raise HTTPAPIError('Not authenticated', 403)
addToCache = not hook.NO_CACHE
cache = GenericCache('HTTPAPI')
cacheKey = RE_REMOVE_EXTENSION.sub('', cacheKey)
if not noCache:
obj = cache.get(cacheKey)
if obj is not None:
result, extra, ts, complete, typeMap = obj
addToCache = False
if result is None:
# Perform the actual exporting
#.........这里部分代码省略.........
示例14: MapAspect
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Indico;if not, see <http://www.gnu.org/licenses/>.
from indico.core.db import DBMgr
from MaKaC.rb_location import Location, MapAspect
from MaKaC.plugins.RoomBooking.default.factory import Factory
aspects = [
{'id': 0, 'name':'Meyrin', 'centerLatitude': 46.23456689405093, 'centerLongitude': 6.046686172485352, 'topLeftLatitude': '46.225660710473136', 'topLeftLongitude': '6.030035018920898', 'bottomRightLatitude': '46.2434716324829', 'bottomRightLongitude': '6.063294410705566', 'zoomLevel':15, 'defaultOnStartup': True},
{'id': 1, 'name':'PREVESSIN', 'centerLatitude': 46.259051447415175, 'centerLongitude': 6.057773351931246, 'topLeftLatitude': '46.2501492379416', 'topLeftLongitude': '6.041107177734375', 'bottomRightLatitude': '46.26795221179669', 'bottomRightLongitude': '6.074366569519043', 'zoomLevel':15, 'defaultOnStartup': False},
{'id': 2, 'name':'POINT 1', 'centerLatitude': 46.23573201283012, 'centerLongitude': 6.054509639707248, 'topLeftLatitude': '46.23350564968721', 'topLeftLongitude': '6.050344705581665', 'bottomRightLatitude': '46.23795828565159', 'bottomRightLongitude': '6.058659553527832', 'zoomLevel':17, 'defaultOnStartup': False},
{'id': 3, 'name':'POINT 2', 'centerLatitude': 46.25115822762375, 'centerLongitude': 6.020456314054172, 'topLeftLatitude': '46.24893249040227', 'topLeftLongitude': '6.016291379928589', 'bottomRightLatitude': '46.253383874525866', 'bottomRightLongitude': '6.024606227874756', 'zoomLevel':17, 'defaultOnStartup': False},
{'id': 4, 'name':'POINT 5', 'centerLatitude': 46.30958858268458, 'centerLongitude': 6.077267646724067, 'topLeftLatitude': '46.30736521774798', 'topLeftLongitude': '6.073100566864014', 'bottomRightLatitude': '46.31181185731005', 'bottomRightLongitude': '6.081415414810181', 'zoomLevel':17, 'defaultOnStartup': False},
{'id': 5, 'name':'POINT 6', 'centerLatitude': 46.29345231426436, 'centerLongitude': 6.1115119456917455, 'topLeftLatitude': '46.29122829396059', 'topLeftLongitude': '6.107347011566162', 'bottomRightLatitude': '46.295676244254715', 'bottomRightLongitude': '6.115661859512329', 'zoomLevel':17, 'defaultOnStartup': False},
{'id': 6, 'name':'POINT 8', 'centerLatitude': 46.24158691675184, 'centerLongitude': 6.097038745847385, 'topLeftLatitude': '46.2393607911537', 'topLeftLongitude': '6.092873811721802', 'bottomRightLatitude': '46.24381295202931', 'bottomRightLongitude': '6.101188659667969', 'zoomLevel':17, 'defaultOnStartup': False},
]
DBMgr.getInstance().startRequest()
Factory.getDALManager().connect()
location = Location.parse('CERN')
for aspectData in aspects:
aspect = MapAspect()
aspect.updateFromDictionary(aspectData)
location.addAspect(aspect)
DBMgr.getInstance().endRequest()
示例15: getRoot
# 需要导入模块: from MaKaC.plugins.RoomBooking.default.factory import Factory [as 别名]
# 或者: from MaKaC.plugins.RoomBooking.default.factory.Factory import getDALManager [as 别名]
def getRoot():
return Factory.getDALManager().getRoot(_CUSTOM_ATTRIBUTES_LIST)