[Cubicweb] A few questions regarding CubicWeb customization

Florent Cayré florent.cayre at gmail.com
Mon Sep 19 22:16:24 CEST 2011

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!
> I do understand that the UI using Python code, but from the examples I 
> have found in the documentation i seems like we can adapt to the 
> existing User Interface. However, I was wondering if it is possible to 
> create a UI from scratch and where in the manual I can find that.
You can, of course. You have to :
* override the views you use to fit your html code (starting from the 
main one : TheMainTemplate, see 
* 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).
> 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.
> I look forward to hearing from you.
> Best Regards,
> Fidel.
> _______________________________________________
> Cubicweb mailing list
> Cubicweb at lists.cubicweb.org
> http://lists.cubicweb.org/mailman/listinfo/cubicweb
See you,
Florent Cayré.

More information about the Cubicweb mailing list