Example #1
0
 def ht_moveHierarchical(self,
                         table=None,
                         pkey=None,
                         into_pkey=None,
                         parent_id=None,
                         into_parent_id=None,
                         modifiers=None):
     tblobj = self.db.table(table)
     if not modifiers:
         into_pkey = into_pkey or None
         tblobj.batchUpdate(dict(parent_id=into_pkey),
                            where='$id=:pkey',
                            pkey=pkey)
         self.db.commit()
     elif (modifiers == 'Shift' or modifiers == 'Shift,Meta') and (
             into_parent_id
             == parent_id) and tblobj.column('_row_count') is not None:
         where = '$parent_id=:p_id' if parent_id else '$parent_id IS NULL'
         f = tblobj.query(where=where,
                          p_id=parent_id,
                          for_update=True,
                          order_by='$_row_count',
                          addPkeyColumn=False).fetch()
         b = Bag([(r['id'], dict(r)) for r in f])
         pref = '>' if modifiers == 'Shift' else '<'
         b.setItem(pkey, b.pop(pkey), _position='%s%s' % (pref, into_pkey))
         for k, r in enumerate(b.values()):
             counter = k + 1
             if r['_row_count'] != counter:
                 old_rec = dict(r)
                 r['_row_count'] = counter
                 tblobj.update(r, old_rec)
         self.db.commit()
Example #2
0
    def rpc_generaValori(self, razza=None):
        tblrazza = self.db.table('warh.razza')
        record = tblrazza.record(pkey=razza).output('dict')
        risultato = Bag()
        tiro_fato = randint(1, 10)
        griglia_fato = Bag(record['pf_base'])
        for riga in griglia_fato.values():
            if tiro_fato >= riga['da'] and tiro_fato <= riga['a']:
                risultato['pf_base'] = riga['valore']

        for x in ('ac', 'ab', 'f', 'r', 'ag', 'int', 'vol', 'simp'):
            risultato[x] = record['%s_base' % x] + randint(1, 10) + randint(
                1, 10)

        tiro_ferite = randint(1, 10)
        griglia_ferite = Bag(record['fer_base'])
        for riga in griglia_ferite.values():
            da = long(riga['da'])
            a = long(riga['a'])
            if tiro_ferite >= da and tiro_ferite <= a:
                risultato['fer_base'] = riga['valore']
        risultato['b_forza_base'] = risultato['f'] / 10
        risultato['b_res_base'] = risultato['r'] / 10
        return risultato
Example #3
0
 def getInheritedDocRows(self,pkey=None,**kwargs):
     where="$%s=:p" %self.tblobj.pkey
     p = pkey
     columns='*,$docrows'
     hpkey = self.tblobj.readColumns(columns='$hierarchical_pkey' ,pkey=pkey)
     p = hpkey
     where =  " ( :p = $hierarchical_pkey ) OR ( :p ILIKE $hierarchical_pkey || :suffix) "
     order_by='$hlevel'
     result = []
     f = self.tblobj.query(where=where,p=p,suffix='/%%',order_by=order_by,columns=columns).fetch()
     result = Bag()
     for r in f:
         for v in Bag(r['docrows']).values():
             result.setItem(v['code'],v)
     return [v.asDict(ascii=True) for v in result.values()]          
Example #4
0
    def rpc_generaValori(self, razza=None):
        tblrazza = self.db.table('warh.razza')
        record = tblrazza.record(pkey=razza).output('dict')
        risultato = Bag()
        tiro_fato = randint(1, 10)
        griglia_fato = Bag(record['pf_base'])
        for riga in griglia_fato.values():
            if tiro_fato >= riga['da'] and tiro_fato <= riga['a']:
                risultato['pf_base'] = riga['valore']

        for x in ('ac', 'ab', 'f', 'r', 'ag', 'int', 'vol', 'simp'):
            risultato[x] = record['%s_base' % x] + randint(1, 10) + randint(1, 10)

        tiro_ferite = randint(1, 10)
        griglia_ferite = Bag(record['fer_base'])
        for riga in griglia_ferite.values():
            da = long(riga['da'])
            a = long(riga['a'])
            if tiro_ferite >= da and tiro_ferite <= a:
                risultato['fer_base'] = riga['valore']
        risultato['b_forza_base'] = risultato['f'] / 10
        risultato['b_res_base'] = risultato['r'] / 10
        return risultato
        
Example #5
0
 def ht_moveHierarchical(self,table=None,pkey=None,into_pkey=None,parent_id=None,into_parent_id=None,modifiers=None):
     tblobj = self.db.table(table)
     if not modifiers:
         into_pkey = into_pkey or None
         tblobj.batchUpdate(dict(parent_id=into_pkey),where='$id=:pkey',pkey=pkey)
         self.db.commit()
     elif (modifiers == 'Shift' or modifiers == 'Shift,Meta') and (into_parent_id==parent_id) and tblobj.column('_row_count') is not None:
         where='$parent_id=:p_id' if parent_id else '$parent_id IS NULL'
         f = tblobj.query(where=where,p_id=parent_id,for_update=True,order_by='$_row_count',addPkeyColumn=False).fetch()
         b = Bag([(r['id'],dict(r)) for r in f])
         pref = '>' if modifiers == 'Shift' else '<'
         b.setItem(pkey,b.pop(pkey),_position='%s%s' %(pref,into_pkey))
         for k,r in enumerate(b.values()):
             counter = k+1
             if r['_row_count'] != counter:
                 old_rec = dict(r)
                 r['_row_count'] = counter
                 tblobj.update(r,old_rec)
         self.db.commit()
Example #6
0
 def getInheritedDocRows(self, pkey=None, **kwargs):
     where = "$%s=:p" % self.tblobj.pkey
     p = pkey
     columns = '*,$docrows'
     hpkey = self.tblobj.readColumns(columns='$hierarchical_pkey',
                                     pkey=pkey)
     p = hpkey
     where = " ( :p = $hierarchical_pkey ) OR ( :p ILIKE $hierarchical_pkey || :suffix) "
     order_by = '$hlevel'
     result = []
     f = self.tblobj.query(where=where,
                           p=p,
                           suffix='/%%',
                           order_by=order_by,
                           columns=columns).fetch()
     result = Bag()
     for r in f:
         for v in Bag(r['docrows']).values():
             result.setItem(v['code'], v)
     return [v.asDict(ascii=True) for v in result.values()]