Formalchemy extension

In the Django extension, I wrote the object `DocumentForm` that allows you to create a Django Form class based on a Document class or instance of a Document.

But you don’t need to use Django to have this facility in your web application. If you use Pylons you may already know FormAlchemy. FormAlchemy was originaly developped to map SQLAlchemy object in a form but it now contains an extension for Couchdbkit too.

How to use it?

Once again we have our Document `Greeting`

 from couchdbkit import *

class Greeting(Document): author = StringProperty() content = StringProperty(required=True) date = DateTimeProperty(default=datetime.utcnow)

The couchdbkit extension of FormAlchemy is in module `formalchemy.ext.couchdb`. To map our document to a FormAlchemy do :

 from formalchemy.ext.couchdb import FieldSet

fs = FieldSet(Greeting) greet = Greeting( author=“Benoit”, content=“Welcome to simplecouchdb world”, date=datetime.datetime.utcnow() ) fs = fs.bind(greet)

And that’s it.

For more information about FormAlchemy, please check its documentation .