示例#1
0
 def getAllRulesAsTuples(self):
     try:
         # This LBYL may look odd but it is needed. Rendering OOPSes and
         # timeouts also looks up flags, but doing such a lookup can
         # will cause a doom if the db request is not executed or is
         # canceled by the DB - and then results in a failure in
         # zope.app.publication.ZopePublication.handleError when it
         # calls transaction.commit.
         # By Looking this up first, we avoid this and also permit
         # code using flags to work in timed out requests (by appearing to
         # have no rules).
         adapter.get_request_remaining_seconds()
     except adapter.RequestExpired:
         return
     store = getFeatureStore()
     rs = (store.find(FeatureFlag).order_by(FeatureFlag.flag,
                                            Desc(FeatureFlag.priority)))
     for r in rs:
         yield Rule(str(r.flag), str(r.scope), r.priority, r.value)
示例#2
0
 def getAllRulesAsTuples(self):
     try:
         # This LBYL may look odd but it is needed. Rendering OOPSes and
         # timeouts also looks up flags, but doing such a lookup can
         # will cause a doom if the db request is not executed or is
         # canceled by the DB - and then results in a failure in
         # zope.app.publication.ZopePublication.handleError when it
         # calls transaction.commit.
         # By Looking this up first, we avoid this and also permit
         # code using flags to work in timed out requests (by appearing to
         # have no rules).
         adapter.get_request_remaining_seconds()
     except adapter.RequestExpired:
         return
     store = getFeatureStore()
     rs = (store
             .find(FeatureFlag)
             .order_by(
                 FeatureFlag.flag,
                 Desc(FeatureFlag.priority)))
     for r in rs:
         yield Rule(str(r.flag), str(r.scope), r.priority, r.value)
示例#3
0
    def _getDiffTimeout(self):
        """Return the seconds allocated to get the diff from the librarian.

         the value will be Non for scripts, 2 for the webapp, or if thre is
         little request time left, the number will be smaller or equal to
         the remaining request time.
        """
        remaining = get_request_remaining_seconds()
        if remaining is None:
            return LIBRARIAN_SERVER_DEFAULT_TIMEOUT
        elif remaining > 2.0:
            # The maximum permitted time for webapp requests.
            return 2.0
        elif remaining > 0.01:
            # Shave off 1 hundreth of a second off so that the call site
            # has a chance to recover.
            return remaining - 0.01
        else:
            return remaining
示例#4
0
    def _getDiffTimeout(self):
        """Return the seconds allocated to get the diff from the librarian.

         the value will be Non for scripts, 2 for the webapp, or if thre is
         little request time left, the number will be smaller or equal to
         the remaining request time.
        """
        remaining = get_request_remaining_seconds()
        if remaining is None:
            return LIBRARIAN_SERVER_DEFAULT_TIMEOUT
        elif remaining > 2.0:
            # The maximum permitted time for webapp requests.
            return 2.0
        elif remaining > 0.01:
            # Shave off 1 hundreth of a second off so that the call site
            # has a chance to recover.
            return remaining - 0.01
        else:
            return remaining