~siunlite/+junk/doax

« back to all changes in this revision

Viewing changes to rootsystem/application/core/collector.py

  • Committer: Siunlee Eng
  • Date: 2019-04-10 18:29:42 UTC
  • Revision ID: siunlite@gmail.com-20190410182942-npehyrzba27kyln2
Importación inicial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#-*- coding: utf-8 -*-
 
2
from core.db import DBQuery
 
3
 
 
4
 
 
5
class CollectorObject(object):
 
6
    
 
7
    def __init__(self):
 
8
        self.collection = []
 
9
    
 
10
    def add_objeto(self, obj):
 
11
        self.collection.append(obj)
 
12
    
 
13
    def get(self, clase):
 
14
        tabla = clase.lower()
 
15
        sql = "SELECT {}_id FROM {}".format(tabla, tabla)
 
16
        registros = DBQuery().execute(sql)
 
17
 
 
18
        exec "from modules.{} import {}".format(tabla, clase)
 
19
 
 
20
        for tupla in registros:
 
21
            obj = locals()[clase]()
 
22
            exec "obj.{}_id = {}".format(tabla, tupla[0])
 
23
            obj.select()
 
24
            self.add_objeto(obj)
 
25
        
 
26
        return self.collection