A helper for setting the _proxy and slapping the store
    object for us.

    :return: A thread-local storage as a dictionary
359965
def create_store():
    
    new_storage = _proxy('store')
    _state.store = type('store', (object,), {})
    new_storage.store = dict()
    return new_storage.store
973324
def __init(self):
        
        params = {
            "f" : "json"
        }
        json_dict = self._get(url=self._currentURL,
                                 param_dict=params,
                                 securityHandler=self._securityHandler,
                                 proxy_url=self._proxy_url,
                                 proxy_port=self._proxy_port)
        self._json = json.dumps(json_dict)
        self._json_dict = json_dict
        attributes = [attr for attr in dir(self)
                    if not attr.startswith('__') and \
                    not attr.startswith('_')]
        for k,v in json_dict.items():
            if k.lower() == "extensions":
                self._extensions = []
                for ext in v:
                    self._extensions.append(Extension.fromJSON(ext))
                    del ext
            elif k in attributes:
                setattr(self, "_"+ k, json_dict[k])
            else:
                print( k, " - attribute not implemented in manageags.AGSService.")
            del k
            del v
534848
def make_store(name, min_length=4, **kwargs):
   
  
   if name not in stores:
      raise ValueError('valid stores are {0}'.format(', '.join(stores)))

   if name == 'memcache':
      store = MemcacheStore
   elif name == 'memory':
      store = MemoryStore
   elif name == 'redis':
      store = RedisStore

   return store(min_length=min_length, **kwargs)
124857
def hijack_local_run(context)
      (class << context; self; end).class_eval do
        alias_method :transactionless_local_run, :local_run
        def local_run(*args)
          ::ActiveRecord::Base.transaction do
            transactionless_local_run(*args)
            raise ::ActiveRecord::Rollback
          end
        end # local_run
      end # metaclass
    end
743004
def serialize(self, include_class=True, save_dynamic=False, **kwargs):
        
        json_dict = super(Singleton, self).serialize(
            include_class=include_class,
            save_dynamic=save_dynamic,
            **kwargs
        )
        json_dict['_singleton_id'] = self._singleton_id
        return json_dict
632383
def update_cache_key(cls, cache_key, item=None):
        
        contents = cls.__thread_id_cache.get(cache_key, None)
        if item is not None:
            cls.__thread_id_cache[cache_key] = item

        return contents
2411
def prepare(self, context):
		""""""
		if __debug__:
			log.debug("Assigning thread local request context.")
		
		self.local.context = context
52364
def snapshot(self):
        
        return dict((category, dict((name, metric.value())
                                    for name, metric in list(metrics.items())))
                    for category, metrics in
                    list(self._store.items()))
1346580
def proxy_servers(self):
        
        proxy_servers = {}
        if self._load_rc_func is None:
            return proxy_servers
        else:
            HTTP_PROXY = os.environ.get('HTTP_PROXY')
            HTTPS_PROXY = os.environ.get('HTTPS_PROXY')

            if HTTP_PROXY:
                proxy_servers['http'] = HTTP_PROXY

            if HTTPS_PROXY:
                proxy_servers['https'] = HTTPS_PROXY

            proxy_servers_conf = self._load_rc_func().get('proxy_servers', {})
            proxy_servers.update(proxy_servers_conf)

            return proxy_servers
253456
def __init(self):
        
        params = {
            "f" : "json",
        }
        json_dict = self._get(self._url, params,
                                 securityHandler=self._securityHandler,
                                 proxy_url=self._proxy_url,
                                 proxy_port=self._proxy_port)
        self._json_dict = json_dict
        self._json = json.dumps(self._json_dict)
        attributes = [attr for attr in dir(self)
                      if not attr.startswith('__') and \
                      not attr.startswith('_')]
        for k,v in json_dict.items():
            if k in attributes:
                if k == "versions" and json_dict[k]:
                    self._versions = []
                    for version in v:
                        self._versions.append(
                            Version(url=self._url + "/versions/%s" % version,
                                    securityHandler=self._securityHandler,
                                    proxy_url=self._proxy_url,
                                    proxy_port=self._proxy_port,
                                    initialize=False))
                elif k == "replicas" and json_dict[k]:
                    self._replicas = []
                    for version in v:
                        self._replicas.append(
                            Replica(url=self._url + "/replicas/%s" % version,
                                    securityHandler=self._securityHandler,
                                    proxy_url=self._proxy_url,
                                    proxy_port=self._proxy_port,
                                    initialize=False))
                else:
                    setattr(self, "_"+ k, v)
            else:
                print (k, " - attribute not implemented for GeoData Service")
1106716
def create_or_update_proxy(self, proxy):
        
        content = self._serialize.body(proxy, 'Proxy')
        response = self._send(http_method='PUT',
                              location_id='ec1f4311-f2b4-4c15-b2b8-8990b80d2908',
                              version='5.0-preview.2',
                              content=content)
        return self._deserialize('Proxy', response)
1077248
def as_dict(self, env=None, internal=False):
        
        ctx_mgr = suppress() if env is None else self.using_env(env)
        with ctx_mgr:
            data = self.store.copy()
            # if not internal remove internal settings
            if not internal:
                for name in dir(default_settings):
                    data.pop(name, None)
            return data
1153719
def to_dict(self):
        
        with self._lock:
            result = {}
            if self._gpayload:
                result.update(self._gpayload)
            if self._tpayload:
                result.update(getattr(self._tpayload, "context", {}))
            return result
531191
def update_global_variables_list_store(self):
        
        # logger.info("update")
        self.list_store_iterators = {}
        self.list_store.clear()
        keys = self.model.global_variable_manager.get_all_keys()
        keys.sort()
        for key in keys:
            iter = self.list_store.append([key,
                                           self.model.global_variable_manager.get_data_type(key).__name__,
                                           str(self.model.global_variable_manager.get_representation(key)),
                                           str(self.model.global_variable_manager.is_locked(key)),
                                           ])
            self.list_store_iterators[key] = iter
45464
def stored_bind(self, instance):
        

        if self.id is None:
            return self.bind(instance)

        store = self._bound_pangler_store.setdefault(instance, {})
        p = store.get(self.id)
        if p is None:
            p = store[self.id] = self.bind(instance)
        return p
337600
def get_connection(store_settings: dict={}) -> Connection:
    
    store = store_settings

    if not store_settings:
        store = make_config_from_env()

    os_options = {
        'tenant_id': store['TENANT_ID'],
        'region_name': store['REGION_NAME'],
        # 'endpoint_type': 'internalURL'
    }

    # when we are running in cloudvps we should use internal urls
    use_internal = os.getenv('OBJECTSTORE_LOCAL', '')
    if use_internal:
        os_options['endpoint_type'] = 'internalURL'

    connection = Connection(
        authurl=store['AUTHURL'],
        user=store['USER'],
        key=store['PASSWORD'],
        tenant_name=store['TENANT_NAME'],
        auth_version=store['VERSION'],
        os_options=os_options
    )

    return connection
306224
def get_store(logger: Logger=None) -> 'Store':
    """"""
    from trading_bots.conf import settings
    store_settings = settings.storage
    store = store_settings.get('name', 'json')
    if store == 'json':
        store = 'trading_bots.core.storage.JSONStore'
    elif store == 'redis':
        store = 'trading_bots.core.storage.RedisStore'
    store_cls = load_class_by_name(store)
    kwargs = store_cls.configure(store_settings)
    return store_cls(logger=logger, **kwargs)