Created
December 11, 2009 02:45
-
-
Save Miuler/253934 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: UTF-8 -*- | |
# vim: ai ts=4 sts=4 et sw=4 | |
# Autor: Hector Miuler Malpica Gallegos | |
# Email: miuler@gmail.com | |
# 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) | |
_dict[name] = getattr(self, name) | |
return _dict | |
m = Miuler() | |
m.nombre = u'Miuler' | |
_dict = m.getDictionary() | |
print _dict |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment