Lists loaded from packages are not recognized (although they do upload to CouchDB)

41 views
Skip to first unread message

Radu Stanciu

unread,
Apr 4, 2013, 8:09:42 AM4/4/13
to ka...@googlegroups.com
Hello,

I am building a package for managing a set of products and I want to export certain view and lists, along with templates, to render the pages I need.

I have the package in /packages, the app.js is like this:

module.exports = {
    types: require('./types'),
    lists: require('./lists'),
    views: require('./views'),
    shows: require('./shows'),
    updates: require('./updates')
};

All those files exist in the package folder.

In the main kanso.json I have added "packages/products" to the modules list, and in the main app.js I have use require('products') to set everything up.

Now the tricky part is that the list objects I need are created in CouchDB (I can see it in Futon), but they don't work when I try to use the proper url, nor goes Kanso recognize them and throws Error: Unknown list function  in the console.

This happens for example on _list/orders/orders. I have both the list and view created (same name in this case), but I can only access the view. If I move the list to the main lists.js file, everything works fine.

Thank,
Radu Stanciu

Radu Stanciu

unread,
Apr 4, 2013, 10:10:11 AM4/4/13
to ka...@googlegroups.com
I have done some more research and it seems there might be some prefixing going on for lists, shows and updates inside packages, but I'm not really sure how that works. Has anyone had any experience with this?

Thanks
Radu

Milan Andric

unread,
Apr 4, 2013, 8:18:01 PM4/4/13
to ka...@googlegroups.com
Radu, can you post the problematic code somewhere?

If it's a package in packages/products then you want to add 'products' to the `dependencies` property in the top-level kanso.json.  Then add your lib with exports to `modules` property of kanso.json inside that directory… that will make your lib available on the design doc as well as compile it into modules.js.  Maybe this example helps  https://github.com/mandric/pages

Milan

--
You received this message because you are subscribed to the Google Groups "kanso" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kanso+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Radu Stanciu

unread,
Apr 5, 2013, 4:54:06 AM4/5/13
to ka...@googlegroups.com
Hi Milan,

Thank you for your reply. I did look at your pages sample application but I can't seem to find any connection there with my issues since no package there tries to use the load method from the properties package.

I am attaching a sample barebones application that I put together to demonstrate the issue. The packages folder has a products folder in there, and it seems all the kanso.json options are in order. However, this time I get a really ugly 

"error": "os_process_error",

from CouchDB, and it seems related to the products module. If I take it out, the main show works, otherwise nothing works. If I type in a different view name, I get the correct "missing shows function". If I try to use the view "my_test_from_products", I get the same OS error.

Any ideas? Can anyone replicate this behaviour?

Thank you,

Radu
my-sample.zip

Milan Andric

unread,
Apr 5, 2013, 10:31:13 AM4/5/13
to ka...@googlegroups.com
Hey Radu, I see what you're trying to do.  Couple things:

The `load` property needs to remain unique since that is used to create properties on the design doc.  So if you have "load": "lib/app" in your top level kanso.json you can't have it in your products module.  So I changed that to load: "products/app".  Then I noticed you had "products" as a dependency in the products package… no-no I think that is causing the os_process_error. See attached… this seems to build fine.  We should probably have a wiki page on how to build modules if we don't already, there are some namespace issues that you have to workaround.


my-sample.zip

Radu Stanciu

unread,
Apr 7, 2013, 6:35:58 AM4/7/13
to ka...@googlegroups.com
Hi Milan,

Thanks a lot for your help. I now understand how namespacing works as far as the "load" system goes... I think that was the issue that was causing things not to work the first time I tried this. Doing the trick with the additional /products folder makes the system recognize load "products/app" to reference the current folder structure.

Also thanks for pointing out the extra require for products in the package, it was a misuse due to copy/paste when building up the sample and surely the cause for the os error.

Thanks again for the help, it's much appreciated and I'm so excited I got this packaging to work with Kanso, I tried doing this with much less success back in the days with CakePHP 1.3... It's great to be able to make your own set of plugins/packages/whatever and build a new system from scratch just by putting them together with new styling. 

I will try to make some contributions to the wiki regarding this in the hope that it will help other people get around the issues I ran into.

Kind regards,
Radu
Reply all
Reply to author
Forward
0 new messages