Module Expr Str ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias Assign NameStore ListLoad Str Assign NameStore Str ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad Str NameLoad NameLoad kwarg body Expr Str If Call AttributeLoad NameLoad attr Str body Assign NameStore SubscriptLoad NameLoad Slice Num Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad If Call NameLoad NameLoad NameLoad body Assign NameStore Call NameLoad Call AttributeLoad Call NameLoad NameLoad attr Assign AttributeStore NameLoad attr Call NameLoad Call AttributeLoad NameLoad attr Str If Call NameLoad NameLoad NameLoad body Assign NameStore Call NameLoad Call AttributeLoad Call NameLoad NameLoad attr If NameLoad body Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults kwarg body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad NameLoad attr NameLoad Return Call AttributeLoad NameLoad attr Call AttributeLoad Str attr ListLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr keyword NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return BinOpMod Str TupleLoad AttributeLoad Call NameLoad NameLoad attr Call AttributeLoad Str attr ListLoad Str AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr BinOpMod Str AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call AttributeLoad Call NameLoad NameLoad attr NameLoad ListLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Assign NameStore ListLoad Assign NameStore Call NameLoad NameLoad keyword Call NameLoad Str For TupleStore NameStore NameStore Call NameLoad NameLoad keyword Call NameLoad Str body Assign NameStore BinOpMod Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Dict Str NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad Assign NameStore Call NameLoad Call AttributeLoad Call AttributeLoad NameLoad attr Str Dict attr For NameStore NameLoad body Assign NameStore Dict Str AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Assign SubscriptStore NameLoad Index Str AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Assign SubscriptStore NameLoad Index Str AttributeLoad NameLoad attr Assign SubscriptStore Call AttributeLoad NameLoad attr Str Dict Index AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr If CompareIn AttributeLoad NameLoad attr NameLoad body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr If BoolOpAnd NameLoad NameLoad body For NameStore NameLoad body Delete SubscriptDel SubscriptLoad NameLoad Index Str Index NameLoad orelse If BoolOpAnd NameLoad CompareIn Str NameLoad body Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index Str If CompareGt Call NameLoad NameLoad Num body Raise Call NameLoad Str Call NameLoad NameLoad Assign SubscriptStore NameLoad Index Str SubscriptLoad Call NameLoad NameLoad Index Num If CompareNotEq NameLoad NameLoad body If CompareIsNot NameLoad NameLoad body Expr Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Return Call AttributeLoad NameLoad attr NameLoad decorator_list NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore ListLoad Assign NameStore NameLoad For NameStore Call AttributeLoad NameLoad attr body If BoolOpAnd NameLoad UnaryOpNot Call AttributeLoad NameLoad attr body If Call AttributeLoad Call AttributeLoad NameLoad attr attr Str body Continue Assign NameStore NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Return Call AttributeLoad Str attr NameLoad decorator_list
N/A N/A Utility code for managing design documents. copy deepcopy inspect getsource itertools groupby operator attrgetter textwrap dedent types FunctionType N/A __all__ N/A ViewDefinition N/A __docformat__ restructuredtext en ViewDefinition N/A object N/A N/A Definition of a view stored in a specific design document.
    
    An instance of this class can be used to access the results of the view,
    as well as to keep the view definition in the design document up to date
    with the definition in the application code.
    
    >>> from couchdb import Server
    >>> server = Server()
    >>> db = server.create('python-tests')
    
    >>> view = ViewDefinition('tests', 'all', '''function(doc) {
    ...     emit(doc._id, null);
    ... }''')
    >>> view.get_doc(db)

    The view is not yet stored in the database, in fact, design doc doesn't
    even exist yet. That can be fixed using the `sync` method:

    >>> view.sync(db)                                       #doctest: +ELLIPSIS
    [(True, u'_design/tests', ...)]
    >>> design_doc = view.get_doc(db)
    >>> design_doc                                          #doctest: +ELLIPSIS
    <Document u'_design/tests'@u'...' {...}>
    >>> print(design_doc['views']['all']['map'])
    function(doc) {
        emit(doc._id, null);
    }

    If you use a Python view server, you can also use Python functions instead
    of code embedded in strings:
    
    >>> def my_map(doc):
    ...     yield doc['somekey'], doc['somevalue']
    >>> view = ViewDefinition('test2', 'somename', my_map, language='python')
    >>> view.sync(db)                                       #doctest: +ELLIPSIS
    [(True, u'_design/test2', ...)]
    >>> design_doc = view.get_doc(db)
    >>> design_doc                                          #doctest: +ELLIPSIS
    <Document u'_design/test2'@u'...' {...}>
    >>> print(design_doc['views']['somename']['map'])
    def my_map(doc):
        yield doc['somekey'], doc['somevalue']
    
    Use the static `sync_many()` method to create or update a collection of
    views in the database in an atomic and efficient manner, even across
    different design documents.

    >>> del server['python-tests']
     __init__ N/A N/A self design name map_fun reduce_fun language wrapper options N/A None javascript None None defaults N/A N/A Initialize the view definition.
        
        Note that the code in `map_fun` and `reduce_fun` is automatically
        dedented, that is, any common leading whitespace is removed from each
        line.
        
        :param design: the name of the design document
        :param name: the name of the view
        :param map_fun: the map function code
        :param reduce_fun: the reduce function code (optional)
        :param language: the name of the language used
        :param wrapper: an optional callable that should be used to wrap the
                        result rows
        :param options: view specific options (e.g. {'collation':'raw'})
         N/A N/A N/A design startswith _design/ N/A N/A design N/A design N/A 8 N/A N/A self design design N/A N/A self name name N/A N/A isinstance map_fun FunctionType N/A N/A map_fun N/A _strip_decorators N/A N/A N/A getsource map_fun rstrip N/A N/A self map_fun N/A dedent N/A N/A map_fun lstrip N/A N/A isinstance reduce_fun FunctionType N/A N/A reduce_fun N/A _strip_decorators N/A N/A N/A getsource reduce_fun rstrip N/A reduce_fun N/A N/A reduce_fun N/A dedent N/A N/A reduce_fun lstrip N/A N/A self reduce_fun reduce_fun N/A N/A self language language N/A N/A self wrapper wrapper N/A N/A self options options N/A N/A self defaults defaults N/A __call__ N/A N/A self db N/A options N/A N/A Execute the view in the given database.
        
        :param db: the `Database` instance
        :param options: optional query string parameters
        :return: the view results
        :rtype: `ViewResults`
         N/A wrapper N/A N/A options pop wrapper N/A self wrapper N/A merged_options N/A N/A N/A self defaults copy N/A N/A N/A merged_options update options N/A N/A N/A db view N/A N/A / join N/A N/A self design N/A self name wrapper wrapper merged_options N/A __repr__ N/A N/A self N/A N/A N/A N/A <%s %r> N/A N/A N/A type self __name__ N/A N/A / join N/A _design N/A self design _view N/A self name N/A get_doc N/A N/A self db N/A N/A N/A Retrieve and return the design document corresponding to this view
        definition from the given database.
        
        :param db: the `Database` instance
        :return: a `client.Document` instance, or `None` if the design document
                 does not exist in the database
        :rtype: `Document`
         N/A N/A N/A db get N/A _design/%s N/A self design N/A sync N/A N/A self db N/A N/A N/A Ensure that the view stored in the database matches the view defined
        by this instance.
        
        :param db: the `Database` instance
         N/A N/A N/A N/A type self sync_many db N/A self N/A sync_many N/A N/A db views remove_missing callback N/A False None N/A N/A Ensure that the views stored in the database that correspond to a
        given list of `ViewDefinition` instances match the code defined in
        those instances.
        
        This function might update more than one design document. This is done
        using the CouchDB bulk update feature to ensure atomicity of the
        operation.
        
        :param db: the `Database` instance
        :param views: a sequence of `ViewDefinition` instances
        :param remove_missing: whether views found in a design document that
                               are not found in the list of `ViewDefinition`
                               instances should be removed
        :param callback: a callback function that is invoked when a design
                         document gets updated; the callback gets passed the
                         design document as only parameter, before that doc
                         has actually been saved back to the database
         N/A docs N/A N/A views N/A sorted views key N/A attrgetter design N/A N/A design views N/A groupby views key N/A attrgetter design N/A N/A doc_id N/A _design/%s design N/A doc N/A N/A db get doc_id N/A _id doc_id N/A orig_doc N/A deepcopy doc N/A languages N/A set N/A missing N/A list N/A N/A N/A N/A doc get views N/A keys N/A view views N/A N/A funcs N/A map N/A view map_fun N/A N/A view reduce_fun N/A N/A N/A funcs N/A reduce N/A view reduce_fun N/A N/A view options N/A N/A N/A funcs N/A options N/A view options N/A N/A N/A N/A doc setdefault views N/A N/A N/A view name funcs N/A N/A N/A languages add N/A view language N/A N/A N/A view name missing N/A N/A N/A N/A missing remove N/A view name N/A N/A remove_missing missing N/A N/A name missing N/A N/A N/A N/A doc N/A views N/A name N/A N/A N/A missing N/A language doc N/A N/A N/A N/A languages add N/A doc N/A language N/A N/A N/A len languages 1 N/A N/A N/A ValueError Found different language views in one design document (%r) N/A list languages N/A N/A doc N/A language N/A N/A list languages N/A 0 N/A N/A doc orig_doc N/A N/A N/A callback None N/A N/A N/A callback doc N/A N/A N/A docs append doc N/A N/A N/A db update docs N/A staticmethod N/A _strip_decorators N/A N/A code N/A N/A N/A retval N/A N/A beginning True N/A line N/A N/A code splitlines N/A N/A N/A beginning N/A N/A N/A line isspace N/A N/A N/A N/A N/A N/A line lstrip startswith @ N/A N/A N/A beginning False N/A N/A N/A retval append line N/A N/A N/A join retval N/A