Example #1
0
 def output(self, key, obj):
     try:
         data = fields.to_marshallable_type(obj)
         entity = dbs.query(Entity).filter(Entity.id == data["id"]).filter(Entity.confirmed).first()
         if not entity:
             raise fields.MarshallingException()
         endpoint = entity.type
         o = urlparse(url_for(endpoint, _external=self.absolute, **data))
         if self.absolute:
             scheme = self.scheme if self.scheme is not None else o.scheme
             return urlunparse((scheme, o.netloc, o.path, "", "", ""))
         return urlunparse(("", "", o.path, "", "", ""))
     except TypeError as te:
         raise fields.MarshallingException(te)
Example #2
0
 def test_to_dict_custom_marshal(self):
     obj = {"hey": 3}
     self.assertEquals(obj, fields.to_marshallable_type(Bar()))
Example #3
0
 def test_to_dict_obj(self):
     obj = {"hey": 3}
     self.assertEquals(obj, fields.to_marshallable_type(Foo()))
Example #4
0
 def test_to_dict_custom_marshal(self):
     obj = {"hey": 3}
     self.assertEquals(obj, fields.to_marshallable_type(Bar()))
Example #5
0
 def test_to_dict_obj(self):
     obj = {"hey": 3}
     self.assertEquals(obj, fields.to_marshallable_type(Foo()))
Example #6
0
 def test_to_dict(self):
     obj = {"hey": 3}
     self.assertEqual(obj, fields.to_marshallable_type(obj))