Exemplo n.º 1
0
 def DELETE(self, name):
     site = get_site(name)
     if site is None:
         raise common.NotFound(error="db_notfound", name=name)
     else:
         site.delete()
         return {"ok": True}
Exemplo n.º 2
0
 def GET(self, sitename):
     i = input("key", revision=None, expand=False)
     site = get_site(sitename)
     revision = i.revision and to_int(i.revision, "revision")
     json = site.get(i.key, revision=revision)
     if not json:
         raise common.NotFound(key=i.key)
     return JSON(json)
Exemplo n.º 3
0
    def process(self, query):
        p = SaveProcessor(self.store, self.author)
        
        for q in serialize(query):
            q = common.parse_query(q)
            
            if not isinstance(q, dict) or q.get('key') is None:
                continue

            key = q['key']                
            thing = get_thing(self.store, key)
            create = q.pop('create', None)
            
            if thing is None:
                if create:
                    q = self.remove_connects(q)
                else:
                    raise common.NotFound(key=key)
            else:
                q = self.connect_all(thing._data, q)
            
            yield p.process(key, q)
Exemplo n.º 4
0
 def GET(self, sitename, path):
     store = get_site(sitename).get_store()
     json = store.get_json(path)
     if not json:
         raise common.NotFound(error="notfound", key=path)
     return JSON(store.get_json(path))
Exemplo n.º 5
0
 def GET(self, name):
     site = get_site(name)
     if site is None:
         raise common.NotFound(error="db_notfound", name=name)
     else:
         return {"name": site.sitename}
Exemplo n.º 6
0
            if isinstance(value, dict):
                return self.process_data(value, property.expected_type, prefix=at['property'] + ".")
            else:
                raise common.TypeMismatch(expected_type, type_found, at=at, value=value)
        else:
            if type_found == '/type/string':
                value = common.Reference(value)
    
        type_found = common.find_type(value)
    
        if type_found == '/type/object':
            type_found = self.get_type(value)
            
            # type is not found only when the thing id not found.
            if type_found is None:
                raise common.NotFound(key=unicode(value), at=at)

        if expected_type != type_found:
            raise common.BadData(message='expected %s, found %s' % (property.expected_type.key, type_found), at=at, value=value)
        return value
        

class WriteQueryProcessor:
    def __init__(self, store, author):
        self.store = store
        self.author = author
        
    def process(self, query):
        p = SaveProcessor(self.store, self.author)
        
        for q in serialize(query):