X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=manifold%2Fmetadata.py;h=6f4c5ce622ab0c76814eb543c7d7cfc3ebe85c8c;hb=d0c1c4620fe021a2d54dec6c4519961dda867cce;hp=0924ded0bffb10a27bdce0d2a26a8fb059b0e050;hpb=7aa94c2c845b9b6c417293a2f3b92befbc57bdad;p=myslice.git diff --git a/manifold/metadata.py b/manifold/metadata.py index 0924ded0..6f4c5ce6 100644 --- a/manifold/metadata.py +++ b/manifold/metadata.py @@ -16,9 +16,6 @@ class MetaData: self.auth=auth self.hash_by_object={} - # XXX Retrieve all metadata the first time we instanciate the class - self.fetch() - def fetch (self): offline_filename="offline-metadata.json" if work_offline: @@ -29,24 +26,32 @@ class MetaData: except: print "metadata.work_offline: failed to decode %s"%offline_filename manifold_api = ManifoldAPI(self.auth) - fields = ['table', 'column.column', - 'column.description','column.header', 'column.title', - 'column.unit', 'column.info_type', - 'column.resource_type', 'column.value_type', - 'column.allowed_values', 'column.platforms.platform', - 'column.platforms.platform_url'] - rows_result = manifold_api.Get({ + fields = ['table', 'column.name', 'column.qualifier', 'column.type', 'column.is_array', 'column.description', 'column.default', 'key', 'capability'] + #fields = ['table', 'column.column', + # 'column.description','column.header', 'column.title', + # 'column.unit', 'column.info_type', + # 'column.resource_type', 'column.value_type', + # 'column.allowed_values', 'column.platforms.platform', + # 'column.platforms.platform_url'] + result = manifold_api.Get({ 'object': 'local:object', # proposed to replace metadata:table 'fields': fields }) -#old# rows_result = manifold_api.Get('metadata:table', [], [], fields) - rows = rows_result.ok_value() - if not rows: - print "Failed to retrieve metadata",rows_result.error() - rows=[] + + if result['code'] == 1: # warning + messages.warning(request, result['description']) + elif result['code'] == 2: + messages.error(request, result['description']) + # XXX FAIL HERE XXX + + rows = result.ok_value() +# API errors will be handled by the outer logic +# if not rows: +# print "Failed to retrieve metadata",rows_result.error() +# rows=[] self.hash_by_object = dict ( [ (row['table'], row) for row in rows ] ) # save for next time we use offline mode - if debug: + if debug and rows: with file(offline_filename,'w') as f: f.write(json.dumps(self.hash_by_object)) @@ -57,4 +62,8 @@ class MetaData: return self.hash_by_object[object] def sorted_fields_by_object (self, object): - return self.hash_by_object[object]['columns'].sort() + return self.hash_by_object[object]['column'].sort() + + def get_field_type(self, object, field): + print "Temp fix for metadata::get_field_type() -> consider moving to manifold.core.metadata soon" + return field