예제 #1
0
    def bbox_data(self, data_input):
        node = colander.SchemaNode(
            colander.String(),
            name=data_input.identifier,
            title=data_input.title,
            validator=BBoxValidator(),
            widget=BBoxWidget()
        )

        # sometimes abstract is not set
        node.description = getattr(data_input, 'abstract') or 'No summary'
        # optional value?
        if data_input.minOccurs == 0:
            node.missing = colander.drop

        # sequence of nodes ...
        if data_input.maxOccurs > 1:
            node = colander.SchemaNode(
                colander.Sequence(),
                node,
                name=data_input.identifier,
                title=data_input.title,
                validator=colander.Length(max=data_input.maxOccurs)
            )

        return node
예제 #2
0
    def bbox_data(self, data_input):
        node = colander.SchemaNode(colander.String(),
                                   name=data_input.identifier,
                                   title=data_input.title,
                                   validator=BBoxValidator(),
                                   widget=BBoxWidget())

        # sometimes abstract is not set
        node.description = getattr(data_input, 'abstract') or 'No summary'
        # optional value?
        if data_input.minOccurs == 0:
            node.missing = colander.drop

        if (hasattr(data_input, 'defaultValue')
                and data_input.defaultValue is not None
                and len(data_input.defaultValue.split(',')) > 3):
            default = ",".join(data_input.defaultValue.split(',')[:4])
            node.default = default

        # sequence of nodes ...
        if data_input.maxOccurs > 1:
            node = colander.SchemaNode(
                colander.Sequence(),
                node,
                name=data_input.identifier,
                title=data_input.title,
                validator=colander.Length(max=data_input.maxOccurs))

        return node
예제 #3
0
 def test_maxy(self):
     validator = BBoxValidator()
     e = invalid_exc(validator, None, "0,-90,180,91")
     self.assertEqual(e.msg, 'MaxY out of range [-90, 90].')
예제 #4
0
 def test_maxx(self):
     validator = BBoxValidator()
     e = invalid_exc(validator, None, "0,-90,181,90")
     self.assertEqual(e.msg, 'MaxX out of range [-180, 180].')
예제 #5
0
 def test_default(self):
     validator = BBoxValidator()
     self.assertEqual(validator(None, "-180,-90,180,90"), None)