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


Python Factory.getDALManager方法代码示例

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


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

示例1: main

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import getDALManager [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

示例2: tmp

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import getDALManager [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

示例3: disconnect

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import getDALManager [as 别名]
 def disconnect():
     """
     Closes database connection. This method is called by Indico engine 
     in the end of every HTTP request.
     """
     from MaKaC.rb_factory import Factory
     return Factory.getDALManager().disconnect()
开发者ID:VishrutMehta,项目名称:indico,代码行数:9,代码来源:rb_dalManager.py

示例4: connect

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import getDALManager [as 别名]
 def connect():
     """ 
     Opens database connection. This method is called by Indico engine
     in the beginning of every HTTP request.
     """
     from MaKaC.rb_factory import Factory
     return Factory.getDALManager().connect()
开发者ID:VishrutMehta,项目名称:indico,代码行数:9,代码来源:rb_dalManager.py

示例5: index

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import getDALManager [as 别名]
def index(req, **params):

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

    ################### checking protection ###################

    # check if it is a machine that belongs to the CERN domain
    cernDomain = DomainHolder().getById(0) # id 0 means CERN
    if not cernDomain.belongsTo(get_remote_ip(req)):
        return "Only CERN users can access to this export resource"

    ################### checking params ###################
    if not (params.has_key("sd") and params.has_key("ed") and params.has_key("r")):
        return """Missing parameters. The request should be like this: http://indico.cern.ch/exportReservations.py?sd=2010-09-24&ed=2010-09-25&r=1,18,114,42"""

    try:
        sd = parseDate(params.get("sd"), "%Y-%m-%d")
        ed = parseDate(params.get("ed"), "%Y-%m-%d")
    except ValueError, e:
        return """The format for the dates (sd and ed) must be like this: YYYY-MM-DD"""
开发者ID:vstitches,项目名称:indico,代码行数:23,代码来源:exportReservations.py

示例6: getReservations

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import getDALManager [as 别名]
    def getReservations():
        from MaKaC.rb_factory import Factory

        dalManager = Factory.getDALManager()
        dalManager.connect()

        amphitheatre = RoomBase.getRooms( roomName = 'IT AMPHITHEATRE' )
        print "All reservations for IT AMPHITHEATRE: %d" % len( amphitheatre.getReservations() )

        resvEx = Factory.newReservation()
        resvEx.startDT = datetime( 2006, 9, 23, 0 )
        resvEx.endDT = datetime( 2006, 9, 30, 23, 59 )

        dalManager.disconnect()
开发者ID:iason-andr,项目名称:indico,代码行数:16,代码来源:rb_room.py

示例7: index

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import getDALManager [as 别名]
def index(req, **params):

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

    ################### checking protection ###################

    def getHostIP(req):
        import socket

        host = str(req.get_remote_host(apache.REMOTE_NOLOOKUP))

        try:
            hostIP = socket.gethostbyname(host)
            minfo = HelperMaKaCInfo.getMaKaCInfoInstance()
            if minfo.useProxy():
                # if we're behind a proxy, use X-Forwarded-For
                xff = req.headers_in.get("X-Forwarded-For",hostIP).split(", ")[-1]
                return socket.gethostbyname(xff)
            else:
                return hostIP
        except socket.gaierror, e:
            # in case host resolution fails
            raise HostnameResolveError("Error resolving host '%s' : %s" % (host, e))
开发者ID:arturodr,项目名称:indico,代码行数:26,代码来源:exportReservations.py

示例8: getReservations

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import getDALManager [as 别名]
    def getReservations( *args, **kwargs ):
        """ Documentation in base class. """

        resvID = kwargs.get( 'resvID' )
        resvEx = kwargs.get( 'resvExample' )
        rooms = kwargs.get( 'rooms' )
        countOnly = kwargs.get( 'countOnly' )
        archival = kwargs.get( 'archival' )
        heavy = kwargs.get( 'heavy' )
        location = kwargs.get( 'location' )
        days = kwargs.get( 'days' )
        
        ret_lst = []
        counter = 0
        root = Factory.getDALManager().root
        
        if resvID != None:
            return root[_RESERVATIONS].get( resvID )
        
        resvCandidates = None

        alreadyRoomFiltered = False
        if rooms and len( rooms ) <= 10:
            # Use room => room reservations index
            resvCandidates = []
            for room in rooms:
                if location != None and room.locationName != location:
                    continue # Skip rooms from different locations
                roomResvs = Reservation.getRoomReservationsIndexRoot().get( room.id )
                if roomResvs != None:
                    resvCandidates += roomResvs
            alreadyRoomFiltered = True
        
        if resvCandidates == None and resvEx != None and resvEx.createdBy != None:
            resvCandidates = Reservation.getUserReservationsIndexRoot().get( resvEx.createdBy )
            if resvCandidates == None:
                resvCandidates = []

        if days:
            resvsInDays = {}
            for day in days:
                dayResvs = Reservation.getDayReservationsIndexRoot().get( day )
                if dayResvs:
                    for resv in dayResvs:
                        resvsInDays[resv] = None
            if resvCandidates == None:
                resvCandidates = resvsInDays.iterkeys()
            else:
                # Intersection
                new = []
                for resv in resvCandidates:
                    if resvsInDays.has_key( resv ):
                        new.append( resv )
                resvCandidates = new
    
        if resvCandidates == None:
            resvCandidates = Reservation.getReservationsRoot().itervalues()

        for resvCandidate in resvCandidates:
            # Apply all conditions 

            if archival != None:
                if resvCandidate.isArchival != archival:
                    continue
            
            if location != None:
                # If location is specified, use only rooms from this location
                if not resvCandidate.locationName == location:
                    continue

            if heavy != None:
                if resvCandidate.isHeavy != heavy:
                    continue
                
            # Does the reservation overlap on the specified period?
            if resvEx != None:
                if resvEx.startDT != None and resvEx.endDT != None:
                    if not resvCandidate.overlapsOn( resvEx.startDT, resvEx.endDT ):
                        continue

                if rooms != None and not alreadyRoomFiltered:
                    if resvCandidate.room not in rooms:
                        continue
                
                if resvEx.createdDT != None:
                    if resvEx.createdDT != resvCandidate.createdDT:
                        continue
                
                if resvEx.bookedForName != None:
                    if resvCandidate.bookedForName == None: 
                        continue
                    if not containsExactly_OR_containsAny( resvEx.bookedForName, resvCandidate.bookedForName ):
                        continue
    
                if resvEx.reason != None:
                    if resvCandidate.reason == None: 
                        continue
                    if not containsExactly_OR_containsAny( resvEx.reason, resvCandidate.reason ):
                        continue

#.........这里部分代码省略.........
开发者ID:davidmorrison,项目名称:indico,代码行数:103,代码来源:reservation.py

示例9: datetime

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import getDALManager [as 别名]
    resvEx.isRejected = False
    resvEx.startDT = datetime(sd.year, sd.month, sd.day, 0, 0)
    resvEx.endDT = datetime(ed.year, ed.month, ed.day, 23, 59)
    resvs = CrossLocationQueries.getReservations(location="CERN", resvExample=resvEx, rooms=rooms)
    collisions = []
    for resv in resvs:
        for p in resv.splitToPeriods(endDT=resvEx.endDT, startDT=resvEx.startDT):
            collisions.append(Collision( ( p.startDT, p.endDT ), resv ))

    of = params.get("of", "csv")
    if of == "xml":
        result = createXML(collisions, req)
    else:
        result = createCSV(collisions, req)

    Factory.getDALManager().disconnect()
    DBMgr.getInstance().endRequest()

    return result


def createXML(resvs, req):

    req.content_type="text/xml"

    xml = XMLGen()

    xml.openTag("bookings")

    for collision in resvs:
        resv = collision.withReservation
开发者ID:arturodr,项目名称:indico,代码行数:33,代码来源:exportReservations.py

示例10: rollback

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import getDALManager [as 别名]
 def rollback():
     """ Rolls back the transaction. """
     from MaKaC.rb_factory import Factory
     return Factory.getDALManager().rollback()
开发者ID:VishrutMehta,项目名称:indico,代码行数:6,代码来源:rb_dalManager.py

示例11: commit

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import getDALManager [as 别名]
 def commit():
     """ Commits the transaction. """
     from MaKaC.rb_factory import Factory
     return Factory.getDALManager().commit()
开发者ID:VishrutMehta,项目名称:indico,代码行数:6,代码来源:rb_dalManager.py

示例12: getReservations

# 需要导入模块: from MaKaC.rb_factory import Factory [as 别名]
# 或者: from MaKaC.rb_factory.Factory import getDALManager [as 别名]
    def getReservations( *args, **kwargs ):
        """ Documentation in base class. """

        resvID = kwargs.get( 'resvID' )
        resvEx = kwargs.get( 'resvExample' )
        rooms = kwargs.get( 'rooms' )
        countOnly = kwargs.get( 'countOnly' )
        archival = kwargs.get( 'archival' )
        heavy = kwargs.get( 'heavy' )
        location = kwargs.get( 'location' )
        days = kwargs.get( 'days' )

        ret_lst = []
        counter = 0
        root = Factory.getDALManager().getRoot()

        if resvID != None:
            return root[_RESERVATIONS].get( resvID )

        resvCandidates = None

        alreadyRoomFiltered = False
        # If we filter by room but not by day, we can use the RoomReservations index
        if rooms and not days and len(rooms) <= 10:
            # Use room => room reservations index
            resvCandidates = set()
            for room in rooms:
                if location != None and room.locationName != location:
                    continue # Skip rooms from different locations
                roomResvs = Reservation.getRoomReservationsIndexRoot().get( room.id )
                if roomResvs != None:
                    resvCandidates.update(roomResvs)
            alreadyRoomFiltered = True

        # If we don't have reservations yet but filter by creator, use the UserReservations index
        if resvCandidates == None and resvEx != None and resvEx.createdBy != None:
            resvCandidates = set(Reservation.getUserReservationsIndexRoot().get(resvEx.createdBy, []))

        # If we want to filter by day, we can choose indexes.
        dayFilteredResvs = None
        if days and rooms:
            # If there's a room filter, too - use the RoomDayReservations index
            dayFilteredResvs = set()
            for key in ((room.id, day) for day in days for room in rooms):
                dayRoomResvs = Reservation.getRoomDayReservationsIndexRoot().get(key, [])
                dayFilteredResvs.update(dayRoomResvs)
            alreadyRoomFiltered = True
        elif days:
            # If we only filter by days, use the DayReservations index
            dayFilteredResvs = set()
            for day in days:
                dayResvs = Reservation.getDayReservationsIndexRoot().get(day, [])
                dayFilteredResvs.update(dayResvs)

        # If we have some day-filtered reservations, use that list or restrict the existing one
        if dayFilteredResvs is not None:
            if resvCandidates is None:
                resvCandidates = dayFilteredResvs
            else:
                # Intersection
                resvCandidates = dayFilteredResvs & resvCandidates

        # If we still have nothing, get all reservations and filter them later in the loop (slow!)
        if resvCandidates is None:
            resvCandidates = Reservation.getReservationsRoot().itervalues()

        for resvCandidate in resvCandidates:
            # Apply all conditions

            if archival != None:
                if resvCandidate.isArchival != archival:
                    continue

            if location != None:
                # If location is specified, use only rooms from this location
                if not resvCandidate.locationName == location:
                    continue

            if heavy != None:
                if resvCandidate.isHeavy != heavy:
                    continue

            # Does the reservation overlap on the specified period?
            if resvEx != None:
                if resvEx.startDT != None and resvEx.endDT != None:
                    if not resvCandidate.overlapsOn( resvEx.startDT, resvEx.endDT ):
                        continue

                if rooms != None and not alreadyRoomFiltered:
                    if resvCandidate.room not in rooms:
                        continue

                if resvEx.createdDT != None:
                    if resvEx.createdDT != resvCandidate.createdDT:
                        continue

                if resvEx.bookedForName != None:
                    if resvCandidate.bookedForName == None:
                        continue
                    if not containsExactly_OR_containsAny( resvEx.bookedForName, resvCandidate.bookedForName ):
#.........这里部分代码省略.........
开发者ID:bubbas,项目名称:indico,代码行数:103,代码来源:reservation.py


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