[doc] Integration of card http://intranet.logilab.fr/intra/card/eid/3355 to the book.
.. -*- coding: utf-8 -*-
Frequently Asked Questions
==========================
[XXX 'copy answer from forum' means reusing text from
http://groups.google.com/group/google-appengine/browse_frm/thread/c9476925f5f66ec6
and
http://groups.google.com/group/google-appengine/browse_frm/thread/d791ce17e2716147/eb078f8cfe8426e0
and
http://groups.google.com/group/google-appengine/browse_frm/thread/f48cf6099973aef5/c28cd6934dd72457
]
* Why does not CubicWeb have a template language ?
It does. Actually, you can use your preferred template language if you
want. [explain how to use a template language]
The reason template languages are not used in this book is that
experience has proved us that using pure python was more efficient.
* Why do you think using pure python is better than using a template language ?
[copy answer from forum]
code is easier to maintain, does not have to learn a new dialect
each time, real function/classes etc -> real development
* Why do you use the GPL license to prevent me from doing X ?
[copy answer from forum]
* CubicWeb looks pretty recent. Is it stable ?
[answer that framework has evolved over the past seven years and that
data migrated from one schema to the other ever since]
* Why is the RQL query language looking similar to X ?
[copy answer from forum, explain why similar to sparql and why better
than django and SQL]
* which ajax library
[we use jquery and things on top of that]
* `Error while publishing rest text ...`
While modifying the description of an entity, you get an error message in
the application `Error while publishing ...` for Rest text and plain text.
The server returns a traceback like as follows ::
2008-10-06 15:05:08 - (erudi.rest) ERROR: error while publishing ReST text
Traceback (most recent call last):
File "/home/sandrine/src/blogdemo/ginco/common/rest.py", line 217, in rest_publish
File "/usr/lib/python2.5/codecs.py", line 817, in open
file = __builtin__.open(filename, mode, buffering)
TypeError: __init__() takes at most 3 arguments (4 given)
This can be fixed by applying the patch described in :
http://code.google.com/p/googleappengine/issues/detail?id=48
* What are hooks used for?
Les crochets sont appeles lorsqu'une requete RQL est executee. Cela
permet d'executer des actions specifiques lors d'un acces a la base
de donnees, ce qui donne un controle de la base de donnees afin de
prevenir l'insertion de `mauvaises` entites dans la base.
* When should you define an HTML template rather than define a graphical component?
Un template HTML ne peut contenir de logique, il ne permettra donc
que de definir une vue statique. Un composant permet lui de gerer
plus de logique et d'operations sur le contexte dans lequel il
s'applique. Il faut donc bien reflechir avant de decider de l'un ou
de l'autre, mais vous avez la possibilite de choisir.
* What is the difference between `AppRsetObject` and `AppObject` ?
La différence entre la classe `AppRsetObject` et la classe `AppObject` est que
les instances de la premières sont séléctionnées pour une requête et un "result
set" et alors que les secondes ne sont séléctionnées qu'en fonction de leur
identifiant.
HOW TO
======
[TO COMPLETE]
* How to update a database after a schema modification?
Cela dépend de ce qui a été modifié dans le schéma.
* Modification d'une relation non finale
* Modification d'une relation finale
* How to create an anonymous user?
Cela vous permet d'acceder a votre site sans avoir besoin de vous authentifier.
Dans le fichier ``all-in-one.conf`` de votre instance, définir l'utilisateur
anonyme en initilisant les valeurs des variables suivantes ::
# login of the Erudi user account to use for anonymous user (if you want to
# allow anonymous)
anonymous-user=anon
# password of the Erudi user account matching login
anonymous-password=anon
Vous devez aussi vous assurer que cet utilisateur `anon` existe dans la base
de données, le plus simple étant de s'identifier sur votre application en
administrateur et de rajouter l'utilisateur `anon` via l'interface d'administration.
* How to change the application logo?
There are two ways of changing the logo.
1. The easiest way to use a different logo is to replace the existing
``logo.png`` in ``myapp/data`` by your prefered icon and refresh.
By default all application will look for a ``logo.png`` to be
rendered in the logo section.
.. image:: images/lax-book.06-main-template-logo.en.png
2. In your cube directory, you can specify which file to use for the logo.
This is configurable in ``mycube/data/external_resources``: ::
LOGO = DATADIR/path/to/mylogo.gif
where DATADIR is ``mycubes/data``.
* How to import LDAP users in `CubicWeb`?
Here is a very usefull script which enables you to import LDAP users
into your `CubicWeb` application by runing the following: ::
import os
import pwd
import sys
from logilab.common.db import get_connection
def getlogin():
"""avoid usinng os.getlogin() because of strange tty / stdin problems
(man 3 getlogin)
Another solution would be to use $LOGNAME, $USER or $USERNAME
"""
return pwd.getpwuid(os.getuid())[0]
try:
database = sys.argv[1]
except IndexError:
print 'USAGE: python ldap2system.py <database>'
sys.exit(1)
if raw_input('update %s db ? [y/n]: ' % database).strip().lower().startswith('y'):
cnx = get_connection(user=getlogin(), database=database)
cursor = cnx.cursor()
insert = ('INSERT INTO euser (creation_date, eid, modification_date, login, firstname, surname, last_login_time, upassword) '
"VALUES (%(mtime)s, %(eid)s, %(mtime)s, %(login)s, %(firstname)s, %(surname)s, %(mtime)s, './fqEz5LeZnT6');")
update = "UPDATE entities SET source='system' WHERE eid=%(eid)s;"
cursor.execute("SELECT eid,type,source,extid,mtime FROM entities WHERE source!='system'")
for eid, type, source, extid, mtime in cursor.fetchall():
if type != 'EUser':
print "don't know what to do with entity type", type
continue
if source != 'ldapuser':
print "don't know what to do with source type", source
continue
ldapinfos = dict(x.strip().split('=') for x in extid.split(','))
login = ldapinfos['uid']
firstname = ldapinfos['uid'][0].upper()
surname = ldapinfos['uid'][1:].capitalize()
if login != 'jcuissinat':
args = dict(eid=eid, type=type, source=source, login=login,
firstname=firstname, surname=surname, mtime=mtime)
print args
cursor.execute(insert, args)
cursor.execute(update, args)
cnx.commit()
cnx.close()