Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CC662D592 for ; Fri, 24 May 2013 08:35:46 +0000 (UTC) Received: (qmail 82280 invoked by uid 500); 24 May 2013 08:35:45 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 82210 invoked by uid 500); 24 May 2013 08:35:43 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Delivered-To: moderator for user@couchdb.apache.org Received: (qmail 8055 invoked by uid 99); 23 May 2013 21:12:42 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Message-ID: <519E8626.5070704@diewald.me> Date: Thu, 23 May 2013 16:12:06 -0500 From: Noah Diewald User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6 MIME-Version: 1.0 To: "user@couchdb.apache.org" Subject: Re: Problem with commonjs in view References: <519E70BD.4030503@diewald.me> <519E732A.7020109@diewald.me> In-Reply-To: <519E732A.7020109@diewald.me> X-Enigmail-Version: 1.5.1 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="----enig2USTLHUTMBHRQEVUMCPJD" X-Virus-Checked: Checked by ClamAV on apache.org ------enig2USTLHUTMBHRQEVUMCPJD Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable If anyone is curious about the "dumb" thing that I did, here it goes. I created a view that referred to the exported function using a relative = path. This didn't work. I decided to try and debug the problem using the tempor= ary view editor. This didn't work because I guess that temporary views are sp= ecial somehow. I had thought that I'd tried updating the view to match this exa= mple, without using a temporary view: >> views: { >> lib: { >> blue: "exports.ninenine =3D 99;" >> }, >> mymap: { >> map: "function (doc) {emit(require('views/lib/blue').ninenine);}" >> } >> } But I must not have done this because I tried it again and got it to work= =2E Moral of the story, temporary views are not a good place to debug commonjs prob= lems. On 05/23/2013 02:51 PM, Noah Diewald wrote: > Oh. I cut and pasted badly. The two errors are not the same. The first = should be > "mod is undefined". >=20 > On 05/23/2013 02:40 PM, Noah Diewald wrote: >> I have a design document where I'm trying to use commonjs in a view. A= t this >> point I've failed at trying to do the more complicated stuff that I in= tended to >> use this functionality for. I'm just trying to do something simple so = that I can >> figure out why things aren't working for me. I'm following this wiki p= age fairly >> closely: https://wiki.apache.org/couchdb/CommonJS_Modules >> >> I have a views property that looks like this: >> >> views: { >> lib: { >> blue: "exports.ninenine =3D 99;" >> }, >> mymap: { >> map: "function (doc) {emit(require('../lib/blue').ninenine);}" >> } >> } >> >> I get errors that look like the following for every document in the lo= g when >> attempting to run the view in the temporary view interface in futon: >> >> OS Process #Port<0.3115> Log :: function raised exception (new >> TypeError("mod.current is null", "/usr/share/couchdb/server/main.js", = 1125)) >> with doc._id cccb3bb779549b28b2e48eb628934107 >> >> So it looks like relative paths don't work but if I use the property p= ath as >> shown in the wiki: >> >> views: { >> lib: { >> blue: "exports.ninenine =3D 99;" >> }, >> mymap: { >> map: "function (doc) {emit(require('views/lib/blue').ninenine);}" >> } >> } >> >> I see this error in the log: >> >> OS Process #Port<0.3115> Log :: function raised exception (new >> TypeError("mod.current is null", "/usr/share/couchdb/server/main.js", = 1125)) >> with doc._id cccb3bb779549b28b2e48eb628934107 >> >> I haven't seen if the errors are any different when I don't try to get= the map >> function to run through futon but it isn't working either way. >> >> This looks to be particular to the views. I am using commonjs with bot= h updates >> and validate_doc_update in the same design document and they are worki= ng properly. >> >> I am using the Arch Linux package couchdb 1.2.2-3. I hope I'm just mak= ing some >> type of dumb mistake that someone can point out. Any help would be ver= y appreciated. >> >> Noah >> >> >=20 ------enig2USTLHUTMBHRQEVUMCPJD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJRnoYtAAoJEOwrrh4QClUJcOMIALI+EGpyj5ZvP5ttY/0wV2YL DmC9rO+CxPQ5RNyenOvlCl4bQBRljy4ZwKb6NwmdfwSIs88kjiQKJnlF7dUdyA/t tDnOZuXeqGMtFaf3Frq4iAWKWyDx/Kp12RspMKWwWVMjvdiTjlCdqRhFL3VmU2fG 62lOAUND+cKRuWIfF+/8fRXN0ATehZLjGSjOGzEbAJj8VJqdRClEMzN8mEKH/+Ag dVOnGmDjB2jBDeZK5s+dE3Tah2FKzYESLOtBaoD8QCXCY+j50WH6C3jqXbGqI7nB DUSK/SXX/0P8erRDmgMJhuZZ0p3PUfbim2nwWPVpN85K9O0zEems5PM6O34WSLI= =Gil2 -----END PGP SIGNATURE----- ------enig2USTLHUTMBHRQEVUMCPJD--