doc/book/en/D010-faq.en.txt
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 07 Jan 2009 14:42:43 +0100
changeset 345 31f88b2e3500
parent 344 e0d5879a613e
child 358 e7347a1e3659
permissions -rw-r--r--
more translation and complements

.. -*- 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 ?

  There are enough template languages out there. You can use your
  preferred template language if you want. [explain how to use a
  template language]

  `CubicWeb` does not define its own templating language as this was
  not our goal. Based on our experience, we realized that
  we could gain productivity by letting designers use design tools
  and developpers develop without the use of the templating language
  as an intermediary that could not be anyway efficient for both parties.
  Python is the templating language that we use in `CubicWeb`, but again,
  it does not prevent you from using a templating language.

  The reason template languages are not used in this book is that
  experience has proved us that using pure python was less cumbersome.

* Why do you think using pure python is better than using a template language ?

  Python is an Object Oriented Programming language and as such it
  already provides a consistent and strong architecture and syntax
  a templating language would not reach.

  When doing development, you need a real language and template
  languages are not real languages.

  Using Python enables developing applications for which code is
  easier to maintain with real functions/classes/contexts
  without the need of learning a new dialect. By using Python,
  we use standard OOP techniques and this is a key factor in a
  robust application.

* Why do you use the GPL license to prevent me from doing X ?

  GPL means that *if* you redistribute your application, you need to
  redistribute it *and* the changes you made *and* the code _linked_
  to it under the GPL licence.

  Publishing a web site has nothing to do with redistributing
  source code. A fair amount of companies use modified GPL code
  for internal use. And someone could publish a `CubicWeb` component
  under a BSD licence for others to plug into a GPL framework without
  any problem. The only thing we are trying to prevent here is someone
  taking the framework and packaging it as closed source to his own
  clients.


* CubicWeb looks pretty recent. Is it stable ?

  It is constantly evolving, piece by piece.  The framework has
  evolved over the past seven years and data has been migrated from
  one schema to the other ever since. There is a well-defined way to
  handle data and schema migration.

* Why is the RQL query language looking similar to X ?

  It may remind you of SQL but it is higher level than SQL, more like
  SPARQL. Except that SPARQL did not exist when we started the project.
  Having SPARQL has a query language has been in our backlog for years.

  That RQL language is what is going to make a difference with django-
  like frameworks for several reasons.

  1. accessing data is *much* easier with it. One can write complex
     queries with RQL that would be tedious to define and hard to maintain
     using an object/filter suite of method calls.

  2. it offers an abstraction layer allowing your applications to run
     on multiple back-ends. That means not only various SQL backends
     (postgresql, sqlite, mysql), but also multiple databases at the
     same time, and also non-SQL data stores like LDAP directories and
     subversion/mercurial repositories (see the `vcsfile`
     component). Google App Engine is yet another supported target for
     RQL.

[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?

  Hooks are executed around (actually before or after) events.  The
  most common events are data creation, update and deletion.  They
  permit additional constraint checking (those not expressible at the
  schema level), pre and post computations depending on data
  movements.

  As such, they are a vital part of the framework.

  Other kinds of hooks, called Operations, are available
  for execution just before commit.

* When should you define an HTML template rather than define a graphical component?

  An HTML template cannot contain code, hence it is only about static
  content.  A component is made of code and operations that apply on a
  well defined context (request, result set). It enables much more
  dynamic views.

* What is the difference between `AppRsetObject` and `AppObject` ?

  `AppRsetObject` instances are selected on a request and a result
  set. `AppObject` instances are directly selected by id.

HOW TO
======

[TO COMPLETE]


* How to update a database after a schema modification?

  It depends on what has been modified in the schema.

  * Update of a non final relation.

  * Update of a final relation.


* How to create an anonymous user?

  This allows to bypass authentication for your site. In the
  ``all-in-one.conf`` file of your instance, define the anonymous user
  as follows ::

    # 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

  You also must ensure that this `anon` user is a registered user of
  the DB backend. This could be the admin account (for development
  purposes, of course).


* 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()