Hi Benoît, It's a good idea I think. Good work. I have some comments regarding the patch:
1) Doing a regexp substitution of the view function's code string seems like a recipe for disaster to me. I think the safe and clean way to go here is to create another sandbox, with a different 'emit' function, and in Couch.compileFunction (utils.js) pass a third and optional argument which is the context in which the function is going to be executed. If omitted, it uses 'sandbox' as the context, otherwise use that other context. Then here: https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L0R34 You would so something like: fun = Couch.compileFunction(source, filter_sandbox); 2) Don't forget the indentation level for .js files is 2 spaces (I'm seeing a mix of 4 and 2 spaces in share/server/filter.js) 3) Avoid the unnecessary white-space only changes: https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R396 https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L2R477 https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R255 https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R60 https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R85 https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R247 https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L4R503 https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R191 4) This?LOG_INFO line is there for your debugging purposes I think (should be removed): https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad#L3R168 cheers On Mon, Nov 29, 2010 at 10:05 PM, Benoit Chesneau <[email protected]> wrote: > Hi all, > > Tonight i've written t quick patch that allows the user to use map > view function to filter changes. Here is the patch : > > https://github.com/benoitc/couchdb/commit/651e29e1bb767fb493bf75497623dae89bf9a5ad > > thoughts ? > > - benoît > -- Filipe David Manana, [email protected], [email protected] "Reasonable men adapt themselves to the world. Unreasonable men adapt the world to themselves. That's why all progress depends on unreasonable men."
