Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: UTF-8 -*-
- # vim: ai ts=4 sts=4 et sw=4
- # Autor: Hector Miuler Malpica Gallegos
- # Email: [email protected]
- # Rev: $Rev
- # -------------------------------------------------------------------
- """
- Este es un ejemplo de como agegar una método que genere
- un diccionario a partir de una tabla de storm, aquí se
- le pone el nombre getDictionary()
- """
- from storm.properties import SimpleProperty
- from storm.properties import Unicode
- from storm.properties import Int
- class Miuler(object):
- __storm_table__ = 'miuler'
- id = Int(primary=True)
- nombre = Unicode()
- edad = Int()
- def getDictionary(self):
- _dict = {}
- for name in self.__class__.__dict__:
- if isinstance(self.__class__.__dict__[name], SimpleProperty):
- print '-----------------------------------------'
- print name, ': ', self.__class__.__dict__[name]
- print name, ': ', getattr(self, name)
- print
- _dict[name] = getattr(self, name)
- return _dict
- m = Miuler()
- m.nombre = u'Miuler'
- _dict = m.getDictionary()
- print
- print _dict
Add Comment
Please, Sign In to add comment