Beispiel #1
0
    def _add_reverse(self, data, other):
        name = data.get('name', None)
        if name is None:
            raise InvalidModel("Unnamed reverse: %s" % other)

        prop = self.get(name)
        if prop is None:
            data.update({
                'type': registry.entity.name,
                'reverse': {
                    'name': other.name
                },
                'schema': other.schema.name,
                'stub': True
            })
            prop = Property(self, name, data)
            prop.generate()
        return prop
Beispiel #2
0
    def _add_reverse(self, data, other):
        name = data.pop('name', None)
        if name is None:
            raise InvalidModel("Unnamed reverse: %s" % other)

        prop = self.get(name)
        if prop is None:
            data.update({
                'type': 'entity',
                'reverse': {'name': other.name},
                'schema': other.schema.name
            })
            prop = Property(self, name, data, stub=True)
            prop.generate()
            self._own_properties.append(prop)
            self._flush_properties()
        assert prop.type == registry.entity, prop.type
        return prop
Beispiel #3
0
    def _add_reverse(self, data: ReverseSpec, other: Property) -> Property:
        name = data.get("name")
        if name is None:
            raise InvalidModel("Unnamed reverse: %s" % other)

        prop = self.get(name)
        if prop is None:
            spec: PropertySpec = {
                "label": data.get("label"),
                "type": registry.entity.name,
                "reverse": {"name": other.name},
                "range": other.schema.name,
                "hidden": data.get("hidden", other.hidden),
            }
            prop = Property(self, name, spec)
            prop.stub = True
            prop.generate()
            self.properties[name] = prop
        return prop
    def _add_reverse(self, data, other):
        name = data.get("name", None)
        if name is None:
            raise InvalidModel("Unnamed reverse: %s" % other)

        prop = self.get(name)
        if prop is None:
            data.update({
                "type": registry.entity.name,
                "reverse": {
                    "name": other.name
                },
                "range": other.schema.name,
                "stub": True,
            })
            data["hidden"] = data.get("hidden", other.hidden)
            prop = Property(self, name, data)
            prop.generate()
            self.properties[name] = prop
        return prop