예제 #1
0
 def test_recordlist_create_load(self):
     t = RecordList.create(self.testcoll, "list1",
                           recordlist_create_values(list_id="list1"))
     td = RecordList.load(self.testcoll, "list1").get_values()
     v = recordlist_read_values(list_id="list1")
     self.assertKeysMatch(td, v)
     self.assertDictionaryMatch(td, v)
     return
예제 #2
0
 def lists(self):
     """
     Generator enumerates and returns record lists that may be stored
     """
     for f in self._children(RecordList):
         t = RecordList.load(self, f)
         if t:
             yield t
     return
예제 #3
0
    def get_list(self, list_id):
        """
        Retrieve identified list description

        list_id     local identifier for the list to retrieve.

        returns a RecordList object for the identified list, or None.
        """
        l = RecordList.load(self, list_id, altparent=self._parentsite)
        return l
예제 #4
0
    def get_list(self, list_id):
        """
        Retrieve identified list description

        list_id     local identifier for the list to retrieve.

        returns a RecordList object for the identified list, or None.
        """
        l = RecordList.load(self, list_id, altscope="all")
        return l
예제 #5
0
 def _check_list_view_values(self,
                             list_id,
                             list_uri=None,
                             update="RecordList",
                             num_fields=4):
     "Helper function checks content of record view entry with supplied list_id"
     self.assertTrue(RecordList.exists(self.testcoll, list_id))
     t = RecordList.load(self.testcoll, list_id)
     self.assertEqual(t.get_id(), list_id)
     self.assertEqual(t.get_view_url(),
                      TestHostUri + recordlist_url("testcoll", list_id))
     v = recordlist_values(list_id=list_id,
                           list_uri=list_uri,
                           update=update)
     if num_fields == 0:
         v['annal:list_fields'] = []
     # log.info("RecordList.load values: %r"%(t.get_values(),))
     self.assertDictionaryMatch(t.get_values(), v)
     return t
예제 #6
0
 def get_list_info(self, list_id):
     """
     Retrieve list definition to use for display
     """
     if not self.http_response:
         assert ((self.site and self.collection) is not None)
         assert list_id
         # log.debug(
         #     "DisplayInfo.get_list_info: collection.get_alt_entities %r"%
         #     [ c.get_id() for c in  self.collection.get_alt_entities(altscope="all") ]
         #     )
         if not RecordList.exists(self.collection, list_id, altscope="all"):
             log.warning(
                 "DisplayInfo.get_list_info: RecordList %s not found" %
                 list_id)
             self.http_response = self.view.error(
                 dict(self.view.error404values(),
                      message=message.RECORD_LIST_NOT_EXISTS %
                      ({
                          'id': list_id,
                          'coll_id': self.coll_id
                      })))
         else:
             self.list_id = list_id
             self.recordlist = RecordList.load(self.collection,
                                               list_id,
                                               altscope="all")
             if "@error" in self.recordlist:
                 self.http_response = self.view.error(
                     dict(self.view.error500values(),
                          message=message.RECORD_LIST_LOAD_ERROR %
                          ({
                              'id': list_id,
                              'file': self.recordlist["@error"],
                              'message': self.recordlist["@message"]
                          })))
             elif self.type_id is None and self.entitytypeinfo is None:
                 self.get_type_info(
                     extract_entity_id(
                         self.recordlist[ANNAL.CURIE.default_type]))
             # log.debug("DisplayInfo.get_list_info: %r"%(self.recordlist.get_values()))
     return self.http_response
예제 #7
0
 def test_recordlist_default_data(self):
     t = RecordList.load(self.testcoll,
                         "Default_list",
                         altparent=self.testsite)
     self.assertEqual(t.get_id(), "Default_list")
     self.assertIn("/c/testcoll/_annalist_collection/lists/Default_list",
                   t.get_url())
     self.assertEqual(t.get_type_id(), "_list")
     td = t.get_values()
     self.assertEqual(set(td.keys()),
                      set(recordlist_load_keys(list_uri=True)))
     v = recordlist_read_values(list_id="Default_list")
     v.update({
         '@id': "annal:display/Default_list",
         'rdfs:label': "List entities",
         'rdfs:comment': "Default list of entities of given type",
         'annal:uri': "annal:display/Default_list"
     })
     self.assertDictionaryMatch(td, v)
     return
예제 #8
0
 def get_list_info(self, list_id):
     """
     Retrieve list definition to use for display
     """
     if not self.http_response:
         assert ((self.site and self.collection) is not None)
         assert list_id
         # log.debug(
         #     "DisplayInfo.get_list_info: collection.get_alt_entities %r"%
         #     [ c.get_id() for c in  self.collection.get_alt_entities(altscope="all") ]
         #     )
         if not RecordList.exists(self.collection, list_id, altscope="all"):
             log.warning("DisplayInfo.get_list_info: RecordList %s not found"%list_id)
             self.http_response = self.view.error(
                 dict(self.view.error404values(),
                     message=message.RECORD_LIST_NOT_EXISTS%(
                         {'id': list_id, 'coll_id': self.coll_id})
                     )
                 )
         else:
             self.list_id    = list_id
             self.recordlist = RecordList.load(self.collection, list_id, altscope="all")
             if "@error" in self.recordlist:
                 self.http_response = self.view.error(
                     dict(self.view.error500values(),
                         message=message.RECORD_LIST_LOAD_ERROR%(
                             { 'id':       list_id
                             , 'file':     self.recordlist["@error"]
                             , 'message':  self.recordlist["@message"]
                             })
                         )
                     )
             elif self.type_id is None and self.entitytypeinfo is None:
                 self.get_type_info(
                     extract_entity_id(self.recordlist[ANNAL.CURIE.default_type])
                     )
             # log.debug("DisplayInfo.get_list_info: %r"%(self.recordlist.get_values()))
     return self.http_response
def coll_list(coll, list_id):
    """
    Return identified list in collection, or None
    """
    return RecordList.load(coll, list_id, altscope="all")
예제 #10
0
def coll_list(coll, list_id):
    """
    Return identified list in collection, or None
    """
    return RecordList.load(coll, list_id, altscope="all")