示例#1
0
    def __init__(self, db_instance = None):
        """
Constructor __init__(Instance)

:param db_instance: Encapsulated SQLAlchemy database instance

:since: v1.0.0
        """

        MutableMapping.__init__(self)

        self._db_context_sort_definition = { }
        """
Context specific sort definition instances
        """
        self._db_sort_definition = None
        """
Sort definition instance
        """
        self.local = local()
        """
thread-local instance
        """
        self._lock = ThreadLock()
        """
Thread safety lock
        """
        self._log_handler = NamedLoader.get_singleton("dNG.data.logging.LogHandler", False)
        """
The LogHandler is called whenever debug messages should be logged or errors
happened.
        """

        self.local.db_instance = db_instance
示例#2
0
    def __init__(self, flagdir=None, environ=None, lock=None, debug=None):
        ''' Initialise the `Flags` instance.

        Parameters:
        * `flagdir`: the directory holding flag state files;
          if omitted use the value from `cs.env.FLAGDIR(environ)`
        * `environ`: the environment mapping to use,
          default `os.environ`
        * `lock`: a `Lock`like mutex to control multithreaded access;
          if omitted no locking is down
        * `debug`: debug mode, default `False`
    '''
        MutableMapping.__init__(self)

        @contextmanager
        def mutex():
            ''' Mutex context manager.
      '''
            if lock:
                lock.acquire()
            try:
                yield
            finally:
                if lock:
                    lock.release()

        self._mutex = mutex
        if debug is None:
            debug = False
        self.debug = debug
        FlaggedMixin.__init__(self, flags=self)
        if flagdir is None:
            flagdir = FLAGDIR(environ=environ)
        self.dirpath = flagdir
        self._old_flags = {}
示例#3
0
    def __init__(self, init_registry=None):
        if init_registry:
            if isinstance(init_registry, dict):
                self._registry = copy.deepcopy(init_registry)
            else:
                raise InvalidJWSERegOperation('Unknown input type')
        else:
            self._registry = {}

        MutableMapping.__init__(self)
示例#4
0
    def __init__(self, *args, **kwargs):
        """
Constructor __init__(StackedDict)

:since: v1.0.1
        """

        MutableMapping.__init__(self)

        self._dict = dict(*args, **kwargs)
        """
Base of the stacked dict instance.
        """
        self.stacked_dicts = []
        """
示例#5
0
    def __init__(self, default):
        MutableMapping.__init__(self)
        self._back = {}

        for rtype in RatingType:
            self[rtype] = default
示例#6
0
文件: test2.py 项目: arbal/scratchbox
 def __init__(self, table, txn):
     MutableMapping.__init__(self)
     self._table = table
     self._txn = txn
示例#7
0
 def __init__(self, parent, deft_config, user_config):
     MutableMapping.__init__(self)
     self._parent = parent
     self._deft_config = deft_config
     self._user_config = user_config