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


Python rb_factory.Factory类代码示例

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


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

示例1: 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()
开发者ID:davidmorrison,项目名称:indico,代码行数:12,代码来源:initialize.py

示例2: getReservations

    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,代码行数:14,代码来源:rb_room.py

示例3: 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()
开发者ID:davidmorrison,项目名称:indico,代码行数:14,代码来源:reservation.py

示例4: disconnect

 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,代码行数:7,代码来源:rb_dalManager.py

示例5: connect

 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,代码行数:7,代码来源:rb_dalManager.py

示例6: getReservations2

    def getReservations2():
        from MaKaC.rb_room import RoomBase
        
        Test.dalManager.connect()
        
        resvEx = Factory.newReservation()
        resvEx.startDT = datetime( 2006, 12, 01, 10 )
        resvEx.endDT = datetime( 2006, 12, 14, 15 )
        resvEx.repeatability = 0 # Daily
        
        #ReservationBase.getReservations( \
        #    roomExample = roomEx, 
        #    resvExample = resvEx,
        #    available = True )

        resv = ReservationBase.getReservations( resvID = 363818 )
        print resv
        r = Reservation()
        r.room = resv.room
        r.startDT = datetime( 2006, 10, 13, 8, 30 )
        r.endDT = datetime( 2006, 10, 13, 17, 30 )
        col = r.getCollisions()
        print col

        Test.dalManager.disconnect()
开发者ID:davidmorrison,项目名称:indico,代码行数:25,代码来源:reservation.py

示例7: testIndexes

 def testIndexes(self):
     block = self._createTestBlocking()
     block2 = Factory.newRoomBlocking()()
     block2.startDate = date(2011, 1, 1)
     block2.endDate = date(2011, 1, 10)
     block2.createdByUser = self._avatar3
     block2.message = 'Testing 2'
     self._blockRoom(block2, self._room1)
     block2.insert()
     # Test if all indexes work properly
     self.assertEqual(frozenset(RoomBlockingBase.getAll()), frozenset((block, block2)))
     self.assertTrue(RoomBlockingBase.getById(0) is None)
     self.assertEqual(RoomBlockingBase.getById(1), block)
     self.assertEqual(RoomBlockingBase.getById(2), block2)
     self.assertTrue(not RoomBlockingBase.getByOwner(self._dummy))
     self.assertTrue(not RoomBlockingBase.getByOwner(self._avatar1))
     self.assertEqual(frozenset(RoomBlockingBase.getByOwner(self._avatar2)), frozenset((block,)))
     self.assertEqual(frozenset(RoomBlockingBase.getByOwner(self._avatar3)), frozenset((block2,)))
     self.assertTrue(not RoomBlockingBase.getByRoom(self._room5))
     self.assertEqual(frozenset(RoomBlockingBase.getByRoom(self._room1)),
                      frozenset((block.getBlockedRoom(self._room1), block2.getBlockedRoom(self._room1))))
     self.assertEqual(frozenset(RoomBlockingBase.getByRoom(self._room2)),
                      frozenset((block.getBlockedRoom(self._room2),)))
     self.assertTrue(block2.getBlockedRoom(self._room2) is None)
     self.assertEqual(frozenset(RoomBlockingBase.getByDate(date(2010, 12, 31))), frozenset((block,)))
     self.assertEqual(frozenset(RoomBlockingBase.getByDate(date(2011, 1, 1))), frozenset((block, block2)))
     self.assertEqual(frozenset(RoomBlockingBase.getByDate(date(2011, 1, 2))), frozenset((block2,)))
     self.assertEqual(frozenset(RoomBlockingBase.getByDateSpan(date(2011, 1, 1), date(2011, 1, 2))),
                      frozenset((block, block2)))
     self.assertEqual(frozenset(RoomBlockingBase.getByDateSpan(date(2011, 1, 2), date(2011, 2, 1))),
                      frozenset((block2,)))
     self.assertTrue(not RoomBlockingBase.getByDateSpan(date(2011, 2, 1), date(2012, 1, 1)))
     # Remove a block
     block.remove()
     self.assertEqual(len(RoomBlockingBase.getAll()), 1)
     self.assertTrue(RoomBlockingBase.getById(block.id) is None)
     self.assertTrue(not RoomBlockingBase.getByOwner(self._avatar2))
     self.assertEqual(frozenset(RoomBlockingBase.getByRoom(self._room1)),
                      frozenset((block2.getBlockedRoom(self._room1),)))
     self.assertTrue(not RoomBlockingBase.getByRoom(self._room2))
     self.assertTrue(not RoomBlockingBase.getByDate(date(2010, 12, 31)))
     self.assertEqual(frozenset(RoomBlockingBase.getByDate(date(2011, 1, 1))), frozenset((block2,)))
     self.assertEqual(frozenset(RoomBlockingBase.getByDate(date(2011, 1, 2))), frozenset((block2,)))
     # Add a blocked room
     br = self._blockRoom(block2, self._room2)
     block2.addBlockedRoom(br)
     # When adding a blocked room, update() may be (and is) required for it to beindexed
     block2.update()
     self.assertEqual(frozenset(RoomBlockingBase.getByRoom(self._room2)),
                      frozenset((block2.getBlockedRoom(self._room2),)))
     self.assertEqual(frozenset(RoomBlockingBase.getByRoom(self._room1)),
                      frozenset((block2.getBlockedRoom(self._room1),)))
     block2.delBlockedRoom(block2.getBlockedRoom(self._room1))
     # Deletion has to update indexes immediately as the object will no longer be reachable from its parent block
     self.assertTrue(not RoomBlockingBase.getByRoom(self._room1))
     block2.update()
     self.assertTrue(not RoomBlockingBase.getByRoom(self._room1))
开发者ID:iason-andr,项目名称:indico,代码行数:57,代码来源:roomblocking_test.py

示例8: getReservations

    def getReservations():
        from MaKaC.rb_room import RoomBase
        
        Test.dalManager.connect()

        roomEx = Factory.newRoom()
        roomEx.name = 'TH AMPHITHEATRE'
        
        resvEx = Factory.newReservation()
        resvEx.startDT = datetime( 2006, 12, 01, 10 )
        resvEx.endDT = datetime( 2006, 12, 14, 15 )
        #resvEx.bookedForName = 'Jean-Jacques Blais'
        resvs = ReservationBase.getReservations( resvExample = resvEx, rooms = [roomEx] )

        for resv in resvs:
            print "============================="
            print resv
        
        Test.dalManager.disconnect()
开发者ID:davidmorrison,项目名称:indico,代码行数:19,代码来源:reservation.py

示例9: _getAnswer

 def _getAnswer( self ):
     minfo = info.HelperMaKaCInfo.getMaKaCInfoInstance()
     result = {}
     if minfo.getRoomBookingModuleActive():
         locationNames = map(lambda l: l.friendlyName, Location.allLocations)
         for loc in locationNames:
             roomEx = Factory.newRoom()
             roomEx.isActive = self._isActive
             for room in CrossLocationQueries.getRooms( location = loc, roomExample=roomEx ):
                 result[str(room.guid)] = "%s: %s" % (loc, room.getFullName())
     return result
开发者ID:aninhalacerda,项目名称:indico,代码行数:11,代码来源:roomBooking.py

示例10: index

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,代码行数:21,代码来源:exportReservations.py

示例11: _createTestBlocking

 def _createTestBlocking(self):
     block = Factory.newRoomBlocking()()
     block.startDate = date(2010, 12, 31)
     block.endDate = date(2011, 1, 1)
     block.createdByUser = self._avatar2
     block.addAllowed(self._avatar4)
     block.message = 'Testing'
     self._blockRoom(block, self._room1)
     self._blockRoom(block, self._room2)
     self._blockRoom(block, self._room3)
     self._blockRoom(block, self._room4)
     self._blockRoom(block, self._room6)
     block.insert()
     return block
开发者ID:iason-andr,项目名称:indico,代码行数:14,代码来源:roomblocking_test.py

示例12: index

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,代码行数:24,代码来源:exportReservations.py

示例13: getLiveReservations

    def getLiveReservations(self, resvExample=None):
        """
        FINAL (not intented to be overriden)
        Returns valid, non archival reservations of this room,
        meeting specified criteria. Look ReservationBase.getReservations for details.
        """
        from MaKaC.rb_factory import Factory
        from MaKaC.rb_reservation import ReservationBase

        if resvExample is None:
            resvExample = Factory.newReservation()
        resvExample.isCancelled = False
        resvExample.isRejected = False

        return ReservationBase.getReservations(resvExample=resvExample, rooms=[self], archival=False)
开发者ID:arescope,项目名称:indico,代码行数:15,代码来源:rb_room.py

示例14: getAverageOccupation

    def getAverageOccupation( **kwargs ):
        """
        FINAL (not intented to be overriden)
        Returns float <0, 1> representing how often - on the avarage -
        the rooms are booked during the working hours. (1 == all the time, 0 == never).
        """

        name = kwargs.get( 'location', Location.getDefaultLocation().friendlyName )

        # Get active, publically reservable rooms
        from MaKaC.rb_factory import Factory
        roomEx = Factory.newRoom()
        roomEx.isActive = True
        roomEx.isReservable = True

        rooms = CrossLocationQueries.getRooms( roomExample = roomEx, location = name )

        # Find collisions with last month period
        from MaKaC.rb_reservation import ReservationBase, RepeatabilityEnum
        resvEx = ReservationBase()
        now = datetime.now()
        resvEx.endDT = datetime( now.year, now.month, now.day, 17, 30 )
        resvEx.startDT = resvEx.endDT - timedelta( 30, 9 * 3600 ) # - 30 days and 9 hours
        resvEx.repeatability = RepeatabilityEnum.daily
        collisions = resvEx.getCollisions( rooms = rooms )

        totalWorkingDays = 0
        weekends = 0
        for day in iterdays( resvEx.startDT, resvEx.endDT ):
            if day.weekday() in [5,6]: # Skip Saturday and Sunday
                weekends += 1
                continue
            # if c.startDT is CERN Holiday: continue
            totalWorkingDays += 1

        booked = timedelta( 0 )
        for c in collisions:
            if c.startDT.weekday() in [5,6]: # Skip Saturday and Sunday
                continue
            # if c.startDT is CERN Holiday: continue
            booked = booked + ( c.endDT - c.startDT )
        totalBookableTime = totalWorkingDays * 9 * len( rooms ) # Hours
        bookedTime = booked.days * 24 + 1.0 * booked.seconds / 3600 # Hours
        if totalBookableTime > 0:
            return bookedTime / totalBookableTime
        else:
            return 0 # Error (no rooms in db)
开发者ID:vstitches,项目名称:indico,代码行数:47,代码来源:rb_room.py

示例15: getAverageOccupation

    def getAverageOccupation(**kwargs):
        """
        FINAL (not intented to be overriden)
        Returns float <0, 1> representing how often - on the avarage -
        the rooms are booked during the working hours. (1 == all the time, 0 == never).
        """

        name = kwargs.get("location", Location.getDefaultLocation().friendlyName)

        # Get active, publically reservable rooms
        from MaKaC.rb_factory import Factory

        roomEx = Factory.newRoom()
        roomEx.isActive = True
        roomEx.isReservable = True

        rooms = CrossLocationQueries.getRooms(roomExample=roomEx, location=name)

        # Find collisions with last month period
        from MaKaC.rb_reservation import ReservationBase, RepeatabilityEnum

        resvEx = ReservationBase()
        resvEx.endDT = datetime.combine(date.today(), time(17, 30))
        resvEx.startDT = resvEx.endDT.replace(hour=8) - timedelta(days=30)
        resvEx.repeatability = RepeatabilityEnum.daily
        collisions = resvEx.getCollisions(rooms=rooms)

        totalWorkingDays = sum(1 for day in iterdays(resvEx.startDT, resvEx.endDT) if day.weekday() not in (5, 6))
        booked = timedelta()
        for c in collisions:
            if c.startDT.weekday() in (5, 6):  # skip Saturday and Sunday
                continue
            booked += c.endDT - c.startDT
        totalBookableTime = totalWorkingDays * 9 * len(rooms)  # Hours
        bookedTime = (booked.days * 86400 + booked.seconds) / 3600.0
        if totalBookableTime > 0:
            return bookedTime / totalBookableTime
        else:
            return 0
开发者ID:arescope,项目名称:indico,代码行数:39,代码来源:rb_room.py


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