本文整理汇总了Python中papyrus.protocol.Protocol._filter_attrs方法的典型用法代码示例。如果您正苦于以下问题:Python Protocol._filter_attrs方法的具体用法?Python Protocol._filter_attrs怎么用?Python Protocol._filter_attrs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类papyrus.protocol.Protocol
的用法示例。
在下文中一共展示了Protocol._filter_attrs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test__filter_attrs
# 需要导入模块: from papyrus.protocol import Protocol [as 别名]
# 或者: from papyrus.protocol.Protocol import _filter_attrs [as 别名]
def test__filter_attrs(self):
from papyrus.protocol import Protocol, create_attr_filter
from geojson import Feature
engine = self._get_engine()
Session = self._get_session(engine)
MappedClass = self._get_mapped_class()
proto = Protocol(Session, MappedClass, "geom")
feature = Feature(properties={'foo': 'foo', 'bar': 'bar', 'foobar': 'foobar'})
request = testing.DummyRequest(params={'attrs': 'bar,foo'})
feature = proto._filter_attrs(feature, request)
self.assertEqual(feature.properties, {'foo': 'foo', 'bar': 'bar'})
示例2: test__filter_attrs_no_geom
# 需要导入模块: from papyrus.protocol import Protocol [as 别名]
# 或者: from papyrus.protocol.Protocol import _filter_attrs [as 别名]
def test__filter_attrs_no_geom(self):
from papyrus.protocol import Protocol
from geojson import Feature
from shapely.geometry import Point
engine = self._get_engine()
Session = self._get_session(engine)
Session.bind = engine
MappedClass = self._get_mapped_class()
proto = Protocol(Session, MappedClass, "geom")
feature = Feature(geometry=Point(1.0, 2.0))
request = testing.DummyRequest(params={'no_geom': 'true'})
feature = proto._filter_attrs(feature, request)
self.assertEqual(feature.geometry, None)