How to add a filter function in couchdb with python?
Question: I know i can use couchdb.ViewDefinition to create a view for a database.Is
there something similar to create a changes filter function or I can just
create a design document with the filters field?


Answer: Currently there is no such what unless you'll operate with design documents as
regular onces e.g. dumping python function to source code and assigning it to
ddoc filters field.

You may try to apply patch from [issue 186](http://code.google.com/p/couchdb-
python/issues/detail?id=186): it provides support of definition
show/list/update/filter/validate_doc_update functions in manner like views
currently does.

For instance:

    
    
    from couchdb import design, mapping
    
    class Post(mapping.Document):
    
       by_author = design.FilterFunction('posts', 'by_name', '''
    function(doc, req){
      if (req.query.author){
        return doc.author === req.query.author;
      }
      throw({'invalid_query': 'author name was not specified'});
    }
    ''')
    
    if __name__ == '__main__:
        design.sync_docs(db, [Post])
    

Feedback and bugs are welcomed (:

