예제 #1
0
파일: documents.py 프로젝트: neithere/tool
 def make_env(self, **databases):
     logger.debug('Confguring {0} with {1}...'.format(self, databases))
     assert databases
     assert DEFAULT_DB_NAME in databases, (
         'database "{0}" must be configured'.format(DEFAULT_DB_NAME))
     env = {}
     for name, settings in databases.iteritems():
         env[name] = get_db(settings)
     return env
예제 #2
0
 def setUp(self):
     self.db = get_db(backend='doqu.ext.shove_db')
예제 #3
0
TMP_DB_PATH = '_test_shaping.shelve'


class CatchAll(doqu.Document):
    pass


class Person(doqu.Document):
    def __unicode__(self):
        return u'{first_name} {last_name}'.format(
            first_name = self.get('first_name', '?'),
            last_name = self.get('last_name', '?'),
        )


db = doqu.get_db(backend='doqu.ext.shelve_db', path=TMP_DB_PATH)
db.clear()

raw_items = yaml.load(open('tests/people.yaml'))
for data in raw_items:
    Person(**data).save(db)

q = CatchAll.objects(db).order_by('birth_country')
people = Person.objects(db).order_by('birth_country')


__doc__ = """
>>> from dark.aggregates import Avg, Count, Max, Median
>>> from dark.shaping import cast_cons, stdev, summary

# note: function cast_cons() is a simple wrapper for cast(), prints a basic table