sanreikaj

Ejemplo

Jan 21st, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. class BaseCampos(object):
  2.     def __init__(self,Fname,prop):
  3.         self.dato=""
  4.         self.Fname=Fname
  5.         self.Ftype=prop['Ftype']
  6.         self.Fprop=prop['Fprop']
  7.         print "Inicio de la clase BaseCampos"
  8.         print self.Fname, self.Ftype, self.Fprop
  9.  
  10.     def __del__(self):
  11.         print "Fin de la clase BaseCampos"
  12.  
  13.     def setDato(self, dato):
  14.         self.dato = dato
  15.  
  16.     def getDato(self):
  17.         return self.dato
  18.  
  19.     def getType(self):
  20.         return self.Ftype
  21.  
  22.  
  23. class BaseTabla(object):
  24.     def __init__(self):
  25.         for attr_name in self.campos.keys():
  26.             setattr(self, attr_name,
  27.                 BaseCampos(attr_name, self.campos[attr_name]))
  28.  
  29.  
  30. class Contactos(BaseTabla):
  31.  
  32.     campos = {'nombre':{'Ftype':'INT()',
  33.                           'Fprop':'Not Null'}}
  34.  
  35.  
  36. c = Contactos()
  37. c.nombre.setDato('prueba de dato para el campo curso')
  38. print id(c.nombre)
  39. print c.nombre.getDato()
  40. print c.nombre.getType()
  41.  
  42. del(c)
Advertisement
Add Comment
Please, Sign In to add comment