예제 #1
0
    def findOrderIdsBetween(self, start=None, stop=None, completed=None):
        "find order ids that are between start and stop or have it open if either is None"
        container = self.getCompoundDocContainer()
        folder = container.restrictedTraverse(self.orderLocation, None)
        orderIds = list(cdocId for cdocId in folder.objectIds('CompoundDoc')
                        if cdocId.startswith('order'))

        startIndex = None
        stopIndex = None

        if start is not None:
            start = utility.cleanRegisteredId('order' + str(start.timeTime()))

        if stop is not None:
            stop = utility.cleanRegisteredId('order' + str(stop.timeTime()))

        if start is not None:
            startIndex = bisect.bisect(orderIds, start)

        if stop is not None:
            stopIndex = bisect.bisect(orderIds, stop)
        orderIds = orderIds[startIndex:stopIndex]
        if completed is not None:
            orderIds = self.filterCompleted(folder, orderIds, completed)
        return orderIds
예제 #2
0
 def updateRegisteredObject(self, name, classType, **kw):
     "Add this object if we don't already have one"
     name = utility.cleanRegisteredId(name)
     if classType != "" and name != "":
         if classType in self.classDict() and not name in self.__dict__:
             self.updateObject(name, self.createRegisteredObject(name, classType, **kw))
             self.afterAddRegisteredObject(name, classType)
예제 #3
0
 def addRegisteredObject(self, name, classType, **kw):
     "Add this object overwriting one we might already have"
     name = utility.cleanRegisteredId(name)
     if classType != "" and name != "" and classType in self.classDict():
         if name in self.__dict__:
             self.delObjects([name])
         item = self.createRegisteredObject(name, classType, **kw)
         self.setObject(name, item)
         self.afterAddRegisteredObject(name, classType)
예제 #4
0
 def syncFreightClasses(self, seq=None):
     "sync the FreightClass objects that we have with what is in the list"
     if seq is not None:
         cleanNames = [utility.cleanRegisteredId(name) for name in seq]
         self.delObjects([name for name in self.objectIds('FreightClass') if name not in cleanNames])
         for clean, name in zip(cleanNames, seq):
             if clean is not None and not self.hasObject(clean):
                 self.addRegisteredObject(clean, 'FreightClass')
                 getattr(self, clean).freightClass = name
예제 #5
0
 def syncFreightClasses(self, seq=None):
     "sync the FreightClass objects that we have with what is in the list"
     if seq is not None:
         cleanNames = [utility.cleanRegisteredId(name) for name in seq]
         self.delObjects([
             name for name in self.objectIds('FreightClass')
             if name not in cleanNames
         ])
         for clean, name in zip(cleanNames, seq):
             if clean is not None and not self.hasObject(clean):
                 self.addRegisteredObject(clean, 'FreightClass')
                 getattr(self, clean).freightClass = name
예제 #6
0
 def findOrderIdsBetween(self, start=None, stop=None, completed=None):
     "find order ids that are between start and stop or have it open if either is None"
     container = self.getCompoundDocContainer()
     folder = container.restrictedTraverse(self.orderLocation, None)
     orderIds = list(cdocId for cdocId in folder.objectIds('CompoundDoc') if cdocId.startswith('order'))
     
     startIndex = None
     stopIndex = None
     
     if start is not None:
         start = utility.cleanRegisteredId('order'+str(start.timeTime()))
     
     if stop is not None:
         stop = utility.cleanRegisteredId('order'+str(stop.timeTime()))
     
     if start is not None:
         startIndex = bisect.bisect(orderIds, start)
         
     if stop is not None:
         stopIndex = bisect.bisect(orderIds, stop)
     orderIds = orderIds[startIndex:stopIndex]
     if completed is not None:
         orderIds = self.filterCompleted(folder, orderIds, completed)
     return orderIds
예제 #7
0
    def observerUpdate(self, object=None):
        "Process what you were observing"
        freightCompanyCreator = self.getRemoteObject(self.freightCompanyCreatorPath, 'FreightCompanyCreator')
        if freightCompanyCreator is not None:
            containedObjects = freightCompanyCreator.getFreightCompanies()
            cleanNames = [utility.cleanRegisteredId(id) for id in containedObjects]
            for id in self.objectIds('FreightCompany'):
                if id not in cleanNames:
                    self.delObjects([id])
            for id,name in zip(cleanNames,containedObjects):
                if not self.hasObject(id):
                    self.addRegisteredObject(id, 'FreightCompany')
                    getattr(self, id).freightCompanyName = name

            freightClasses = freightCompanyCreator.getFreightClasses()
            for object in self.objectValues('FreightCompany'):
                object.syncFreightClasses(freightClasses)
            self.genFreightCompanyListings()
예제 #8
0
    def observerUpdate(self, object=None):
        "Process what you were observing"
        freightCompanyCreator = self.getRemoteObject(
            self.freightCompanyCreatorPath, 'FreightCompanyCreator')
        if freightCompanyCreator is not None:
            containedObjects = freightCompanyCreator.getFreightCompanies()
            cleanNames = [
                utility.cleanRegisteredId(id) for id in containedObjects
            ]
            for id in self.objectIds('FreightCompany'):
                if id not in cleanNames:
                    self.delObjects([id])
            for id, name in zip(cleanNames, containedObjects):
                if not self.hasObject(id):
                    self.addRegisteredObject(id, 'FreightCompany')
                    getattr(self, id).freightCompanyName = name

            freightClasses = freightCompanyCreator.getFreightClasses()
            for object in self.objectValues('FreightCompany'):
                object.syncFreightClasses(freightClasses)
            self.genFreightCompanyListings()
예제 #9
0
 def createNextItem(self):
     'create the next object we can use'
     name = utility.cleanRegisteredId(repr(time.time()).replace('.', '_'))
     self.updateRegisteredObject(name, self.getConfig('addType'))
     return aq_base(getattr(self,name))