X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=manifold%2Fmetadata.py;h=90a09eab1401251c6d122abe9e84d732ea359019;hb=ed42b26f72f3b30653630b5e2302f724bb727dad;hp=1b0e270852496f1e0a190f8927aa2119c2975910;hpb=28994fa4ca7312850f9899adc67e71660a4a753d;p=myslice.git diff --git a/manifold/metadata.py b/manifold/metadata.py index 1b0e2708..90a09eab 100644 --- a/manifold/metadata.py +++ b/manifold/metadata.py @@ -1,4 +1,5 @@ import json +import os.path from manifold.manifoldresult import ManifoldResult from manifold.manifoldapi import ManifoldAPI @@ -17,7 +18,7 @@ class MetaData: self.hash_by_object={} def fetch (self): - offline_filename="offline-metadata.json" + offline_filename="%s/../offline-metadata.json"%os.path.dirname(__file__) if work_offline: try: with file(offline_metadata) as f: @@ -26,24 +27,31 @@ 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({ - 'object': 'local:object', # proposed to replace metadata:table - 'fields': fields - }) + 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'] + request={ 'action': 'get', + 'object': 'local:object', # proposed to replace metadata:table + 'fields': fields , + } + result = manifold_api.forward(request) - if row_results['code'] == 1: # warning - messages.warning(request, result['description']) - elif row_results['code'] == 2: - messages.error(request, result['description']) + # xxx need a way to export error messages to the UI + if result['code'] == 1: # warning + # messages.warning(request, result['description']) + print ("METADATA WARNING -",request,result['description']) + elif result['code'] == 2: + # messages.error(request, result['description']) + print ("METADATA ERROR -",request,result['description']) # XXX FAIL HERE XXX + return - rows = rows_result.ok_value() + rows = result.ok_value() # API errors will be handled by the outer logic # if not rows: # print "Failed to retrieve metadata",rows_result.error() @@ -62,3 +70,7 @@ class MetaData: def sorted_fields_by_object (self, object): 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