-
-
- def expose_js_metadata(self):
- request=self.request
- # xxx this code should probably not be called unconditionnally at page creation time
- # because we're not sure a user is logged in so we might have no session...
- if 'manifold' not in request.session:
- print "Page.expose_js_metadata: no 'manifold' in session... - skipping"
- return
- # use cached version if present
- if 'metadata' in request.session.keys():
- self._metadata = request.session['metadata']
- else:
- manifold_api_session_auth = request.session['manifold']['auth']
- manifold_api = ManifoldAPI(auth=manifold_api_session_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']
-
- results = manifold_api.Get('metadata:table', [], [], fields)
-
- for res in results:
- subject = res['table']
- self._metadata[subject] = res
-
- request.session['metadata'] = self._metadata
-
- javascript = "var MANIFOLD_METADATA =" + json.dumps(self._metadata) + ";"
- self.add_js_chunks(javascript)
-
- def metadata_get_fields(self, subject):
- return self._metadata[subject]['column'].sort()
-