Simpler Collections

posted 2015-05-31 by Herb

The collect module has been updated to make creating collections even simpler than before. With this change you now just have to give the collection a name, define the fields you want to use in your collection and define the model want the collection stored with. Then with one line of code you can create the collection.

Example:

file: app.py

from zoom import collect
from zoom.fields import *

class ItemsItem(Record): pass

Item = ItemsItem

item_fields = Fields(
    TextField('Name'),
    MemoField('Description'),
    NumberField('Price'),
    ImageField('Photo'),
    )

app = Collection('Item', item_fields, Item, url='/mynewapp')

That's it.