Exemplo n.º 1
0
 def __get_fulltext_index__(cls):
     ''''''
     if cls.__fulltext_index__ is None:
         neo = get_graph()
         name = "NodeModel::" + cls.__name__ + "::fulltext"
         cls.__fulltext_index__ = neo.node_indices.get_or_create(name, fulltext=True)
     return cls.__fulltext_index__
Exemplo n.º 2
0
 def save(self, graph=None):
     '''graph will be ignored if this model is already attached to a node/relationship'''
     if graph is None:
         graph = get_graph()
     self._validate()
     if self._pc:
         pc = self._pc
     elif self._id:
         pc = self._get_target_by_id(graph, self._id)
     else:
         pc = self._create_new_target(graph)
         self._id = pc.id
         tnode = self.__get_typenode__(create=True)
         tnode.INSTANCE(pc)              ##TODO allow storage of create/modification time here?
     
     for def_, pmodel in self.__property_dict__.iteritems():
         if not pmodel.unsaved:
             continue
         
         idx = None
         if def_.indexed:
             if def_.indexed_fulltext:
                 print '==>fulltext'
                 idx = self.__get_fulltext_index__()
             else:
                 idx = self.__get_index__()
                 print "==>exact"
                 
         pmodel.save(pc, index=idx)
Exemplo n.º 3
0
 def __get_typenode__(cls, create=False):
     if cls.__typenode__ is None:
         neo = get_graph()
         for rel in neo.reference_node.MODEL_TYPE_NODE:
             if (rel['section'] == cls.__section_label__ and
                 rel['model'] == cls.__name__):
                 cls.__typenode__ = n = rel.end
                 return n
         else:
             if create:
                 cls.__typenode__ = n = neo.node()
                 neo.reference_node.MODEL_TYPE_NODE(n, section=cls.__section_label__, model=cls.__name__)
                 return n
     return cls.__typenode__
Exemplo n.º 4
0
 def __get_index__(cls):
     if cls.__index__ is None:
         neo = get_graph()
         name = "NodeModel::" + cls.__name__
         cls.__index__ = neo.node_indices.get_or_create(name)
     return cls.__index__