[Cubicweb] A few questions regarding CubicWeb customization

Florent Cayré florent.cayre at gmail.com
Tue Sep 20 09:19:24 CEST 2011

Hi Fidel,

Le 20/09/2011 00:23, Fidel Viegas a écrit :
> Hi Florent,
> On 19/09/11 21:16, Florent Cayré wrote:
>> Hi Fidel,
>> Le 19/09/2011 20:51, Fidel Viegas a écrit :
>>> Hello everyone,
>>> I have just started playing with cubicweb, and I must say that it is 
>>> a really nice framework. I have a background in frameworks like Ruby 
>>> on Rails, Django and TurboGears. Therefore, it wasn't too difficult 
>>> to grasp the concepts found in CubicWeb.
>> Welcome on board!
> Thanks!
>> You can, of course. You have to :
>> * override the views you use to fit your html code (starting from the 
>> main one : TheMainTemplate, see 
>> http://docs.cubicweb.org/devweb/views/basetemplates.html)
>> * write your own css file in your cube's data directory (usually 
>> named cubes.YOUR_CUBE.css), reference it in a uiprops.py file located 
>> at the root directory of your cube with a line like 
>> "STYLESHEETS.append(data('cubes.YOUR_CUBE.css'))" or "STYLESHEETS = 
>> [data('cubes.YOUR_CUBE.css')]" if you do not want to keep CubicWeb 
>> default stylesheets
>> You have to understand that CubicWeb uses a *lot* of different views, 
>> but you usually do not need to override all of them as their HTML 
>> code is usually OK for your needs ; just override what you need, 
>> starting from the top-most views (namely templates, html header/ 
>> footer, and so on).
>> An interesting alternative is to keep two "versions" of the web ui : 
>> one for anonymous (and maybe "normal" authenticated users, if any), 
>> one for admins, using the match_user_groups('managers') selector 
>> (prefixed with ~, you promote your view to all users not in the 
>> managers group).
> That is one of the answers I was looking for. I want to create a view 
> for anonymous users and another one for authenticated users.
>>> Another question is regarding the inclusion of other cubes. Can I 
>>> overwrite any i18n files within my cube? Or do I have to create a 
>>> translation for each cube?
>> Not sure I understood your question, but I guess you want to override 
>> another cube's translation. You can, here's how : in a file you can 
>> call i18n_overload.py (in the root directory of your cube for 
>> example), list the words you want to customize so that gettext detect 
>> them. For example, if you want to override the translation of the 
>> word "Entity" (already present in CW i18n files of course), add 
>> _('Entity') on one line of your i18n_overload.py ("_" will be 
>> automatically added to the globals before importing, however you can 
>> add "_ = unicode" at the top of the file if you want to have a clean, 
>> importable python module), then, in a shell, issue a cubicweb-ctl 
>> i18ncube YOUR_CUBE command, and you get the new word in the i18n/*.po 
>> files of your cube. Translate it as you wish and issue a cubicweb-ctl 
>> i18ninstance YOUR_INSTANCE to see the new translation in your web 
>> instance.
> That is exactly the answer I was looking for. Thanks!!!!
> While reading the documentation and looking at a few cubes, another 
> question occurred to me. I was particularly looking at the expenses 
> cube, and the invoice came to my mind automatically. Usually an 
> invoice has a relationship with line items, where line items are 
> dependent on the invoice entity. If you delete the invoice entity, 
> automatically the line item is deleted because it does not make much 
> sense on its own. What I would like to know is if there is any way to 
> hide this entity and have it only shown in an invoice. So, when you 
> click on a new invoice, it automatically has the link to add line 
> items to its form (I figured how to do this, so that is resolved). I 
> just wanted to hide the line items entities and show them only in the 
> invoice entity form. Is this possible? All the example cubes I have 
> looked into have all the entities available.
where do you want to hide them? In the invoice entity (primary) view? On 
their dedicated page (/<line items>)?
> Thanks for the warm welcome.
> Look forward to hearing from you again.
> Best Regards,
> Fidel.
> PS: By the way, your framework is really nice. Had I discovered it 
> earlier, I would have solved quite a lot of problems I have 
> encountered when developing semantic web applications.
CubicWeb is a very nice framework indeed (not mine I am afraid, but 
Logilab's). You are very welcome to contribute, either telling what 
documentation to improve first or simply blogging about your application 
using CubicWeb, or with actual code like your own cubes or contribution 
to the core framework.

Do not forget to "reply all" to keep the mailing list in the copy 
section of your emails and get better support through all the CubicWeb 
experts around.

Also note that you can get even faster support on jabber (see 
https://jabber.logilab.org/ for example, but you can also use your usual 
jabber client).


More information about the Cubicweb mailing list