def makeRoot( self, rev=0, datemodified=None ): root = store.add(Code()) root.nation = self.nation root.depth = 0 root.rev = rev root.released = datemodified return root
def makeRoot( self ): r = store.add(Code()) r.nation = self.nation r.depth = 0 r.rev = 0 r.stored = datetime.now() return r
def findOrCreateAct( self, released, cid, rev ): acts = store.find(Code, Code.nation == self.nation, Code.released == released, Code.cid == cid) if not acts.is_empty(): return acts[0] act = store.add(Code()) act.nation = self.nation act.rev = rev act.cid = cid act.released=released return act
def findOrCreateSection( self, released, cid, act ): sections = store.find( Code, Code.released == released, Code.nation == self.nation, Code.cid == cid, Code.parent == act) if not sections.is_empty(): return sections[0] sec = store.add(Code()) sec.nation= self.nation sec.rev = act.rev sec.released = released sec.cid = cid sec.parent = act return sec
def findOrCreateCode( self, cid ): cid = utf8(cid) #log.debug("Looking for code identified as %s" % cid) c = store.find(Code, Code.rp == self.rp, Code.cid == cid) if c.is_empty(): c = store.add(Code()) c.nation = self.nation c.rp = self.rp c.cid = cid c.stored = datetime.now() else: c = c[0] return c
def getChild( self, id, parent, depth=None ): depth = depth if depth else parent.depth + 1 r = Code.find(Code.nation == self.nation, Code.depth == depth, Code.cid == id, Code.rev == parent.rev, Code.parent == parent) if r.count(): return r.one() else: c = store.add(Code()) c.depth = depth c.cid = id c.parent = parent c.rev = parent.rev c.nation = self.nation return c
def findOrCreateRoot( self ): root = store.find(Code, Code.depth==0, Code.rp==self.rp) if root.is_empty(): log.debug('No root object found for %s, creating...' % self.rp) root = store.add(Code()) root.nation = self.nation root.rp = self.rp root.path = root.cid = '/' root.depth = 0 root.stored = datetime.now() root.commit() else: root = root[0] log.debug('Found root:%i' % root.id) return root