Skip to content
Snippets Groups Projects
Commit 9351279f authored by Nathaniel Kofalt's avatar Nathaniel Kofalt
Browse files

Add functionality

parent 9ccaad30
No related branches found
No related tags found
No related merge requests found
......@@ -89,6 +89,8 @@ def suggest_container(gear, cont_name, cid):
return root
def insert_gear(doc):
gear_tools.validate_manifest(doc['manifest'])
config.db.singletons.update(
{"_id" : "gears"},
{'$push': {'gear_list': doc} }
......@@ -118,5 +120,7 @@ def remove_gear(name):
)
def upsert_gear(doc):
gear_tools.validate_manifest(doc['manifest'])
remove_gear(doc['name'])
insert_gear(doc)
......@@ -74,7 +74,20 @@ class GearHandler(base.RequestHandler):
if _id != doc.get('name', ''):
self.abort(400, 'Name key must be present and match URL')
upsert_gear(self.request.json)
try:
upsert_gear(self.request.json)
except ValidationError as err:
key = None
if len(err.relative_path) > 0:
key = err.relative_path[0]
self.response.set_status(400)
return {
'reason': 'Gear manifest does not match schema',
'error': err.message.replace("u'", "'"),
'key': key
}
return { 'name': _id }
def delete(self, _id):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment