Esempio n. 1
0
    def __new__(mcs, name, bases, attributes):
        for attr_name, attr in list(attributes.items()):
            if isinstance(attr, Property):
                if attr.key is None:
                    attr.key = attr_name
            elif isinstance(attr, Label):
                if attr.name is None:
                    attr.name = label_case(attr_name)
            elif isinstance(attr, RelatedTo):
                if attr.relationship_type is None:
                    attr.relationship_type = relationship_case(attr_name)

        attributes.setdefault("__primarylabel__", name)

        primary_key = attributes.get("__primarykey__")
        if primary_key is None:
            for base in bases:
                if primary_key is None and hasattr(base, "__primarykey__"):
                    primary_key = getattr(base, "__primarykey__")
                    break
            else:
                primary_key = "__id__"
            attributes["__primarykey__"] = primary_key

        return super(GraphObjectType, mcs).__new__(mcs, name, bases, attributes)
Esempio n. 2
0
    def __new__(mcs, name, bases, attributes):
        for attr_name, attr in list(attributes.items()):
            if isinstance(attr, Property):
                if attr.key is None:
                    attr.key = attr_name
            elif isinstance(attr, Label):
                if attr.name is None:
                    attr.name = label_case(attr_name)
            elif isinstance(attr, RelatedTo):
                if attr.relationship_type is None:
                    attr.relationship_type = relationship_case(attr_name)

        attributes.setdefault("__primarylabel__", name)

        primary_key = attributes.get("__primarykey__")
        if primary_key is None:
            for base in bases:
                if primary_key is None and hasattr(base, "__primarykey__"):
                    primary_key = getattr(base, "__primarykey__")
                    break
            else:
                primary_key = "__id__"
            attributes["__primarykey__"] = primary_key

        return super(GraphObjectType, mcs).__new__(mcs, name, bases,
                                                   attributes)
Esempio n. 3
0
 def __new__(mcs, name, bases, attributes):
     for attr_name, attr in list(attributes.items()):
         if isinstance(attr, Property):
             if attr.key is None:
                 attr.key = attr_name
         elif isinstance(attr, Label):
             if attr.name is None:
                 attr.name = label_case(attr_name)
         elif isinstance(attr, RelatedTo):
             if attr.relationship_type is None:
                 attr.relationship_type = relationship_case(attr_name)
     attributes.setdefault("__primarylabel__", name)
     attributes.setdefault("__primarykey__", "__id__")
     return super(GraphObjectType, mcs).__new__(mcs, name, bases, attributes)
Esempio n. 4
0
 def default_type(cls):
     if cls is Relationship:
         return "TO"
     assert issubclass(cls, Relationship)
     return ustr(relationship_case(cls.__name__))
Esempio n. 5
0
 def default_type(cls):
     if cls is Relationship:
         return "TO"
     assert issubclass(cls, Relationship)
     return ustr(relationship_case(cls.__name__))