X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=manifold%2Fmetadata.py;h=08fdf61dea73339adf7149723d754df0503c9fbc;hb=d1197c134b70bda643a752bdaf891190cb5a15e7;hp=4fbbc0668ef1fb63e43690f71494394e85383bd4;hpb=5f03119b3bc1f16e68dd805c4b5773ba1ee7148e;p=myslice.git diff --git a/manifold/metadata.py b/manifold/metadata.py index 4fbbc066..08fdf61d 100644 --- a/manifold/metadata.py +++ b/manifold/metadata.py @@ -4,6 +4,8 @@ import os.path from manifold.manifoldresult import ManifoldResult from manifold.manifoldapi import ManifoldAPI +from django.contrib import messages + debug=False debug=True @@ -17,7 +19,7 @@ class MetaData: self.auth=auth self.hash_by_object={} - def fetch (self): + def fetch (self, request): offline_filename="%s/../offline-metadata.json"%os.path.dirname(__file__) if work_offline: try: @@ -27,24 +29,29 @@ class MetaData: except: print "metadata.work_offline: failed to decode %s"%offline_filename manifold_api = ManifoldAPI(self.auth) - fields = ['table', 'column.name', 'column.qualifier', 'column.type', 'column.is_array', 'column.description', 'column.default', 'key', 'capability'] + 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.forward({ - 'action': 'get', - 'object': 'local:object', # proposed to replace metadata:table - 'fields': fields - }) + request={ 'action': 'get', + 'object': 'local:object', # proposed to replace metadata:table + 'fields': fields , + } + result = manifold_api.forward(request) + # xxx need a way to export error messages to the UI if result['code'] == 1: # warning - messages.warning(request, result['description']) + # messages.warning(request, result['description']) + print ("METADATA WARNING -",request,result['description']) elif result['code'] == 2: - messages.error(request, result['description']) + # messages.error(request, result['description']) + print ("METADATA ERROR -",request,result['description']) # XXX FAIL HERE XXX + return rows = result.ok_value() # API errors will be handled by the outer logic