Esempio n. 1
0
 def test_build_key_for_class(self):
     params = {
         "graph_uri": "graph",
         "class_uri": "Class"
     }
     computed = build_key_for_class(params)
     expected = "graph@@Class##class"
     self.assertEqual(computed, expected)
 def test_build_key_for_class(self):
     params = {
         "graph_uri": "graph",
         "class_uri": "Class"
     }
     computed = build_key_for_class(params)
     expected = "graph@@Class##class"
     self.assertEqual(computed, expected)
Esempio n. 3
0
 def purge(self, context_name, class_name):
     if settings.ENABLE_CACHE:
         with safe_params():
             self.query_params = ParamDict(self,
                                           context_name=context_name,
                                           class_name=class_name)
         path = cache.build_key_for_class(self.query_params)
         cache.purge_by_path(path, False)
     else:
         raise HTTPError(405, log_message=_("Cache is disabled (Brainaik's settings.ENABLE_CACHE is set to False)"))
Esempio n. 4
0
def get_cached_schema(query_params, include_meta=False):
    schema_key = build_key_for_class(query_params)
    class_object = memoize(query_params, get_schema, query_params, key=schema_key)
    if class_object is None or not class_object["body"]:
        msg = _(u"The class definition for {0} was not found in graph {1}")
        raise SchemaNotFound(msg.format(query_params['class_uri'], query_params['graph_uri']))
    if include_meta:
        return class_object
    else:
        return class_object['body']
Esempio n. 5
0
 def purge(self, context_name, class_name):
     if settings.ENABLE_CACHE:
         with safe_params():
             self.query_params = ParamDict(self,
                                           context_name=context_name,
                                           class_name=class_name)
         path = cache.build_key_for_class(self.query_params)
         cache.purge_by_path(path, False)
     else:
         raise HTTPError(405, log_message=_("Cache is disabled (Brainaik's settings.ENABLE_CACHE is set to False)"))
Esempio n. 6
0
def get_cached_schema(query_params, include_meta=False):
    schema_key = build_key_for_class(query_params)
    class_object = memoize(query_params,
                           get_schema,
                           query_params,
                           key=schema_key)
    if class_object is None or not class_object["body"]:
        msg = _(u"The class definition for {0} was not found in graph {1}")
        raise SchemaNotFound(
            msg.format(query_params['class_uri'], query_params['graph_uri']))
    if include_meta:
        return class_object
    else:
        return class_object['body']