示例#1
0
 def test_provides_resource(self):
     coll = create_collection()
     mb = next(iter(coll))
     self.assert_true(provides_member_resource(type(mb)))
     self.assert_true(provides_member_resource(mb))
     self.assert_false(provides_member_resource(coll))
     self.assert_true(provides_resource(type(mb)))
     self.assert_true(provides_resource(mb))
     self.assert_true(provides_collection_resource(type(coll)))
     self.assert_true(provides_collection_resource(coll))
     self.assert_false(provides_collection_resource(mb))
     self.assert_true(provides_resource(type(coll)))
     self.assert_true(provides_resource(coll))
     self.assert_false(provides_resource(mb.get_entity()))
 def test_provides_resource(self):
     coll = create_collection()
     mb = iter(coll).next()
     self.assert_true(provides_member_resource(type(mb)))
     self.assert_true(provides_member_resource(mb))
     self.assert_false(provides_member_resource(coll))
     self.assert_true(provides_resource(type(mb)))
     self.assert_true(provides_resource(mb))
     self.assert_true(provides_collection_resource(type(coll)))
     self.assert_true(provides_collection_resource(coll))
     self.assert_false(provides_collection_resource(mb))
     self.assert_true(provides_resource(type(coll)))
     self.assert_true(provides_resource(coll))
     self.assert_false(provides_resource(mb.get_entity()))
示例#3
0
 def create_from_resource(cls, resource):
     if provides_member_resource(resource):
         kind = ResourceKinds.MEMBER
     elif provides_collection_resource(resource):
         kind = ResourceKinds.COLLECTION
     else:
         raise ValueError('"%s" is not a resource.' % resource)
     return cls.create(resource_to_url(resource), kind,
                       relation=resource.relation,
                       title=resource.title)
示例#4
0
 def create_from_resource(cls, resource):
     if provides_member_resource(resource):
         kind = RESOURCE_KINDS.MEMBER
         opts = dict(id=resource.id)
     elif provides_collection_resource(resource):
         kind = RESOURCE_KINDS.COLLECTION
         opts = {}
     else:
         raise ValueError('"%s" is not a resource.' % resource)
     return cls.create(resource_to_url(resource), kind,
                       relation=resource.relation,
                       title=resource.title,
                       **opts)
示例#5
0
 def __init__(self, mapping_registry, mapped_class, data_element_class,
              configuration):
     """
     :param configuration: mapping configuration object.
     """
     self.__mp_reg = mapping_registry
     self.__mapped_cls = mapped_class
     self.__is_collection_mapping = \
                             provides_collection_resource(mapped_class)
     self.__de_cls = data_element_class
     self.__configuration = configuration
     #
     self.__mapped_attr_cache = {}
示例#6
0
 def __init__(self, mapping_registry, mapped_class, data_element_class,
              configuration):
     """
     :param configuration: mapping configuration object.
     """
     self.__mp_reg = mapping_registry
     self.__mapped_cls = mapped_class
     self.__is_collection_mapping = \
                             provides_collection_resource(mapped_class)
     self.__de_cls = data_element_class
     self.__configuration = configuration
     #
     self.__mapped_attr_cache = {}
示例#7
0
 def create_from_resource(cls, resource):
     if provides_member_resource(resource):
         kind = RESOURCE_KINDS.MEMBER
         opts = dict(id=resource.id)
     elif provides_collection_resource(resource):
         kind = RESOURCE_KINDS.COLLECTION
         opts = {}
     else:
         raise ValueError('"%s" is not a resource.' % resource)
     return cls.create(resource_to_url(resource),
                       kind,
                       relation=resource.relation,
                       title=resource.title,
                       **opts)
示例#8
0
文件: mapping.py 项目: b8va/everest
 def __init__(self, mapping_registry, mapped_class, data_element_class,
              configuration):
     """
     :param configuration: Mapping configuration object.
     """
     self.__mp_reg = mapping_registry
     self.__mapped_cls = mapped_class
     self.__is_collection_mapping = \
                             provides_collection_resource(mapped_class)
     self.__de_cls = data_element_class
     # List of configurations; the last one added is the active one.
     self.__configurations = [configuration]
     #
     self.__mapped_attr_cache = {}
示例#9
0
文件: mapping.py 项目: papagr/everest
 def __init__(self, mapping_registry, mapped_class, data_element_class,
              configuration):
     """
     :param configuration: Mapping configuration object.
     """
     self.__mp_reg = mapping_registry
     self.__mapped_cls = mapped_class
     self.__is_collection_mapping = \
                             provides_collection_resource(mapped_class)
     self.__de_cls = data_element_class
     # List of configurations; the last one added is the active one.
     self.__configurations = [configuration]
     #
     self.__mapped_attr_cache = {}