def _check_record_view_values( self, view_id, view_uri=None, update="RecordView", num_fields=4, update_dict=None, ): "Helper function checks content of record view entry with supplied view_id" self.assertTrue(RecordView.exists(self.testcoll, view_id)) t = RecordView.load(self.testcoll, view_id) self.assertEqual(t.get_id(), view_id) self.assertEqual(t.get_view_url(), TestHostUri + recordview_url("testcoll", view_id)) v = recordview_values( view_id=view_id, view_uri=view_uri, view_entity_type="annal:View", update=update, num_fields=num_fields, ) if update_dict: v.update(update_dict) for k in update_dict: if update_dict[k] is None: v.pop(k, None) # log.info("*** actual: %r"%(t.get_values(),)) # log.info("*** expect: %r"%(v,)) self.assertDictionaryMatch(t.get_values(), v) return t
def _check_record_view_values(self, view_id, view_values): "Helper function checks content of record view entry with supplied view_id" self.assertTrue(RecordView.exists(self.testcoll, view_id)) t = RecordView.load(self.testcoll, view_id) self.assertEqual(t.get_id(), view_id) self.assertDictionaryMatch(t.get_values(), view_values) return t
def _check_record_view_values( self, view_id, view_uri=None, update="RecordView", num_fields=4, update_dict=None, ): "Helper function checks content of record view entry with supplied view_id" self.assertTrue(RecordView.exists(self.testcoll, view_id)) t = RecordView.load(self.testcoll, view_id) self.assertEqual(t.get_id(), view_id) self.assertEqual(t.get_view_url(), TestHostUri + recordview_url("testcoll", view_id)) v = recordview_values( view_id=view_id, view_uri=view_uri, target_record_type="annal:View", update=update, num_fields=num_fields, ) if update_dict: v.update(update_dict) for k in update_dict: if update_dict[k] is None: v.pop(k, None) # log.info("*** actual: %r"%(t.get_values(),)) # log.info("*** expect: %r"%(v,)) self.assertDictionaryMatch(t.get_values(), v) return t
def get_view_info(self, view_id): """ Retrieve view definition to use for display """ if not self.http_response: assert ((self.site and self.collection) is not None) if not RecordView.exists(self.collection, view_id, altscope="all"): log.warning("DisplayInfo.get_view_info: RecordView %s not found"%view_id) log.warning("Collection: %r"%(self.collection)) log.warning("Collection._altparent: %r"%(self.collection._altparent)) # log.warning("\n".join(traceback.format_stack())) self.http_response = self.view.error( dict(self.view.error404values(), message=message.RECORD_VIEW_NOT_EXISTS%( {'id': view_id, 'coll_id': self.coll_id}) ) ) else: self.view_id = view_id self.recordview = RecordView.load(self.collection, view_id, altscope="all") if "@error" in self.recordview: self.http_response = self.view.error( dict(self.view.error500values(), message=message.RECORD_VIEW_LOAD_ERROR%( { 'id': list_id , 'file': self.recordview["@error"] , 'message': self.recordview["@message"] }) ) ) # log.debug("DisplayInfo.get_view_info: %r"%(self.recordview.get_values())) return self.http_response
def views(self): """ Generator enumerates and returns record views that may be stored """ for f in self._children(RecordView): t = RecordView.load(self, f) if t: yield t return
def get_view(self, view_id): """ Retrieve identified view description view_id local identifier for the view to retrieve. returns a RecordView object for the identified view, or None. """ v = RecordView.load(self, view_id, altparent=self._parentsite) return v
def get_view(self, view_id): """ Retrieve identified view description view_id local identifier for the view to retrieve. returns a RecordView object for the identified view, or None. """ v = RecordView.load(self, view_id, altscope="all") return v
def get_view_info(self, view_id): """ Retrieve view definition to use for display """ if not self.http_response: assert ((self.site and self.collection) is not None) if not RecordView.exists(self.collection, view_id, altscope="all"): log.warning( "DisplayInfo.get_view_info: RecordView %s not found" % view_id) log.warning("Collection: %r" % (self.collection)) log.warning("Collection._altparent: %r" % (self.collection._altparent)) # log.warning("\n".join(traceback.format_stack())) self.http_response = self.view.error( dict(self.view.error404values(), message=message.RECORD_VIEW_NOT_EXISTS % ({ 'id': view_id, 'coll_id': self.coll_id }))) else: self.view_id = view_id self.recordview = RecordView.load(self.collection, view_id, altscope="all") if "@error" in self.recordview: self.http_response = self.view.error( dict(self.view.error500values(), message=message.RECORD_VIEW_LOAD_ERROR % ({ 'id': list_id, 'file': self.recordview["@error"], 'message': self.recordview["@message"] }))) # log.debug("DisplayInfo.get_view_info: %r"%(self.recordview.get_values())) return self.http_response
def coll_view(coll, view_id): """ Return identified view in collection, or None """ return RecordView.load(coll, view_id, altscope="all")