import sys, re, datetime, neo4j from bulbs.model import Node, Relationship from bulbs.property import String, Integer, DateTime from bulbs.utils import get_logger from bulbs.utils import current_datetime from bulbs.neo4jserver import Graph from bulbs.neo4jserver.batch import Neo4jBatchClient from bizold.input.file import StringReader, StringWriter log = get_logger(__name__) graph = Graph() class BizBase(object): @classmethod def new(cls, graph=graph, **kwargs): proxy = getattr(graph, cls.element_type) return proxy.create(**kwargs) def __repr__(self): result = [] for prop in self.__class__._get_initial_properties().values(): result.append([prop.name, getattr(self, prop.name)]) return '<{}-{}: {}>'.format( self.__class__.__name__, self.eid, ', '.join(['{}: {}'.format(*t) for t in result])) __str__ = __repr__ class Singleton(BizBase): """Class for umltiple inheritance. Together with a neo4j-Node ensures unique document:
import six # Python 3 import inspect import types from collections import Callable from bulbs.property import Property from bulbs.element import Element, Vertex, VertexProxy, Edge, EdgeProxy, \ coerce_vertices, build_data from bulbs.utils import initialize_element, get_logger # Model Modes NORMAL = 1 STRICT = 2 log = get_logger(__name__) class ModelMeta(type): """Metaclass used to set database Property definitions on Models.""" def __init__(cls, name, base, namespace): """Store Property instance definitions on the class as a dictionary.""" # Get inherited Properties cls._properties = cls._get_initial_properties() # Add new Properties cls._register_properties(namespace) def _get_initial_properties(cls):