You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Thomas Rampelberg <py...@gmail.com> on 2011/01/14 22:54:22 UTC
require() from within views
Decided to give trunk a try so that I could play with require() from
within views today and I've ran into a couple issues.
- It appears that views are sandboxed to a very small section of the
design doc (views/lib/*). Why is this?
- For a reason that I've not been able to figure out, module.exports
doesn't work for functions. eg:
exports.foo = "asdf"
Produces {"foo": "asdf" } but:
exports.foo = function() {}
Produces { }
Any ideas?
Re: require() from within views
Posted by Thomas Rampelberg <py...@gmail.com>.
In the process of trying to get a user document to exhibit this
behavior, I've since discovered that my issue was purely the fact that
log() doesn't output functions.
Sorry for the false call!
On Fri, Jan 14, 2011 at 2:07 PM, Paul Davis <pa...@gmail.com> wrote:
> On Fri, Jan 14, 2011 at 4:54 PM, Thomas Rampelberg <py...@gmail.com> wrote:
>> Decided to give trunk a try so that I could play with require() from
>> within views today and I've ran into a couple issues.
>>
>> - It appears that views are sandboxed to a very small section of the
>> design doc (views/lib/*). Why is this?
>
> This is so that we can calculate a signature for each view to know
> when we have to rebuild a view from scratch due to a change in view
> code.
>
>> - For a reason that I've not been able to figure out, module.exports
>> doesn't work for functions. eg:
>>
>
> That sounds like a bug on the face of it. Can you work up a simple
> example design doc that exhibits the behaviour?
>
>> exports.foo = "asdf"
>>
>> Produces {"foo": "asdf" } but:
>>
>> exports.foo = function() {}
>>
>> Produces { }
>>
>> Any ideas?
>>
>
Re: require() from within views
Posted by Paul Davis <pa...@gmail.com>.
On Fri, Jan 14, 2011 at 4:54 PM, Thomas Rampelberg <py...@gmail.com> wrote:
> Decided to give trunk a try so that I could play with require() from
> within views today and I've ran into a couple issues.
>
> - It appears that views are sandboxed to a very small section of the
> design doc (views/lib/*). Why is this?
This is so that we can calculate a signature for each view to know
when we have to rebuild a view from scratch due to a change in view
code.
> - For a reason that I've not been able to figure out, module.exports
> doesn't work for functions. eg:
>
That sounds like a bug on the face of it. Can you work up a simple
example design doc that exhibits the behaviour?
> exports.foo = "asdf"
>
> Produces {"foo": "asdf" } but:
>
> exports.foo = function() {}
>
> Produces { }
>
> Any ideas?
>