doc/book/en/annexes/faq.rst
branchtls-sprint
changeset 1715 cba9f175da2d
parent 1599 38a1d0f190e2
parent 1714 a721966779be
child 1808 aa09e20dd8c0
equal deleted inserted replaced
1714:a721966779be 1715:cba9f175da2d
     9 http://groups.google.com/group/google-appengine/browse_frm/thread/d791ce17e2716147/eb078f8cfe8426e0
     9 http://groups.google.com/group/google-appengine/browse_frm/thread/d791ce17e2716147/eb078f8cfe8426e0
    10 and
    10 and
    11 http://groups.google.com/group/google-appengine/browse_frm/thread/f48cf6099973aef5/c28cd6934dd72457
    11 http://groups.google.com/group/google-appengine/browse_frm/thread/f48cf6099973aef5/c28cd6934dd72457
    12 ]
    12 ]
    13 
    13 
    14 * Why does not CubicWeb have a template language ?
    14 Why does not CubicWeb have a template language ?
       
    15 ------------------------------------------------
    15 
    16 
    16   There are enough template languages out there. You can use your
    17   There are enough template languages out there. You can use your
    17   preferred template language if you want. [explain how to use a
    18   preferred template language if you want. [explain how to use a
    18   template language]
    19   template language]
    19 
    20 
    26   it does not prevent you from using a templating language.
    27   it does not prevent you from using a templating language.
    27 
    28 
    28   The reason template languages are not used in this book is that
    29   The reason template languages are not used in this book is that
    29   experience has proved us that using pure python was less cumbersome.
    30   experience has proved us that using pure python was less cumbersome.
    30 
    31 
    31 * Why do you think using pure python is better than using a template language ?
    32 Why do you think using pure python is better than using a template language ?
       
    33 -----------------------------------------------------------------------------
    32 
    34 
    33   Python is an Object Oriented Programming language and as such it
    35   Python is an Object Oriented Programming language and as such it
    34   already provides a consistent and strong architecture and syntax
    36   already provides a consistent and strong architecture and syntax
    35   a templating language would not reach.
    37   a templating language would not reach.
    36 
    38 
    41   easier to maintain with real functions/classes/contexts
    43   easier to maintain with real functions/classes/contexts
    42   without the need of learning a new dialect. By using Python,
    44   without the need of learning a new dialect. By using Python,
    43   we use standard OOP techniques and this is a key factor in a
    45   we use standard OOP techniques and this is a key factor in a
    44   robust application.
    46   robust application.
    45 
    47 
    46 * Why do you use the GPL license to prevent me from doing X ?
    48 Why do you use the GPL license to prevent me from doing X ?
       
    49 -----------------------------------------------------------
    47 
    50 
    48   GPL means that *if* you redistribute your application, you need to
    51   GPL means that *if* you redistribute your application, you need to
    49   redistribute it *and* the changes you made *and* the code _linked_
    52   redistribute it *and* the changes you made *and* the code _linked_
    50   to it under the GPL licence.
    53   to it under the GPL licence.
    51 
    54 
    56   any problem. The only thing we are trying to prevent here is someone
    59   any problem. The only thing we are trying to prevent here is someone
    57   taking the framework and packaging it as closed source to his own
    60   taking the framework and packaging it as closed source to his own
    58   clients.
    61   clients.
    59 
    62 
    60 
    63 
    61 * CubicWeb looks pretty recent. Is it stable ?
    64 CubicWeb looks pretty recent. Is it stable ?
       
    65 --------------------------------------------
    62 
    66 
    63   It is constantly evolving, piece by piece.  The framework has
    67   It is constantly evolving, piece by piece.  The framework has
    64   evolved over the past seven years and data has been migrated from
    68   evolved over the past seven years and data has been migrated from
    65   one schema to the other ever since. There is a well-defined way to
    69   one schema to the other ever since. There is a well-defined way to
    66   handle data and schema migration.
    70   handle data and schema migration.
    67 
    71 
    68 * Why is the RQL query language looking similar to X ?
    72 Why is the RQL query language looking similar to X ?
       
    73 -----------------------------------------------------
    69 
    74 
    70   It may remind you of SQL but it is higher level than SQL, more like
    75   It may remind you of SQL but it is higher level than SQL, more like
    71   SPARQL. Except that SPARQL did not exist when we started the project.
    76   SPARQL. Except that SPARQL did not exist when we started the project.
    72   Having SPARQL has a query language has been in our backlog for years.
    77   Having SPARQL has a query language has been in our backlog for years.
    73 
    78 
    87      RQL.
    92      RQL.
    88 
    93 
    89 [copy answer from forum, explain why similar to sparql and why better
    94 [copy answer from forum, explain why similar to sparql and why better
    90   than django and SQL]
    95   than django and SQL]
    91 
    96 
    92 * which ajax library
    97 which ajax library
    93 
    98 ------------------
    94   [we use jquery and things on top of that]
    99   [we use jquery and things on top of that]
    95 
   100 
    96 * `Error while publishing rest text ...`
   101 `Error while publishing rest text ...`
    97 
   102 --------------------------------------
    98   While modifying the description of an entity, you get an error message in
   103   While modifying the description of an entity, you get an error message in
    99   the application `Error while publishing ...` for Rest text and plain text.
   104   the application `Error while publishing ...` for Rest text and plain text.
   100   The server returns a traceback like as follows ::
   105   The server returns a traceback like as follows ::
   101 
   106 
   102       2008-10-06 15:05:08 - (cubicweb.rest) ERROR: error while publishing ReST text
   107       2008-10-06 15:05:08 - (cubicweb.rest) ERROR: error while publishing ReST text
   108 
   113 
   109 
   114 
   110   This can be fixed by applying the patch described in :
   115   This can be fixed by applying the patch described in :
   111   http://code.google.com/p/googleappengine/issues/detail?id=48
   116   http://code.google.com/p/googleappengine/issues/detail?id=48
   112 
   117 
   113 * What are hooks used for?
   118 What are hooks used for?
       
   119 ------------------------
   114 
   120 
   115   Hooks are executed around (actually before or after) events.  The
   121   Hooks are executed around (actually before or after) events.  The
   116   most common events are data creation, update and deletion.  They
   122   most common events are data creation, update and deletion.  They
   117   permit additional constraint checking (those not expressible at the
   123   permit additional constraint checking (those not expressible at the
   118   schema level), pre and post computations depending on data
   124   schema level), pre and post computations depending on data
   121   As such, they are a vital part of the framework.
   127   As such, they are a vital part of the framework.
   122 
   128 
   123   Other kinds of hooks, called Operations, are available
   129   Other kinds of hooks, called Operations, are available
   124   for execution just before commit.
   130   for execution just before commit.
   125 
   131 
   126 * When should you define an HTML template rather than define a graphical component?
   132 When should you define an HTML template rather than define a graphical component?
       
   133 ---------------------------------------------------------------------------------
   127 
   134 
   128   An HTML template cannot contain code, hence it is only about static
   135   An HTML template cannot contain code, hence it is only about static
   129   content.  A component is made of code and operations that apply on a
   136   content.  A component is made of code and operations that apply on a
   130   well defined context (request, result set). It enables much more
   137   well defined context (request, result set). It enables much more
   131   dynamic views.
   138   dynamic views.
   132 
   139 
   133 * What is the difference between `AppRsetObject` and `AppObject` ?
   140 What is the difference between `AppRsetObject` and `AppObject` ?
       
   141 ----------------------------------------------------------------
   134 
   142 
   135   `AppRsetObject` instances are selected on a request and a result
   143   `AppRsetObject` instances are selected on a request and a result
   136   set. `AppObject` instances are directly selected by id.
   144   set. `AppObject` instances are directly selected by id.
   137 
   145 
   138 * How to update a database after a schema modification?
   146 How to update a database after a schema modification?
       
   147 -----------------------------------------------------
   139 
   148 
   140   It depends on what has been modified in the schema.
   149   It depends on what has been modified in the schema.
   141 
   150 
   142   * Update of an attribute permissions and properties: 
   151   * Update of an attribute permissions and properties: 
   143     ``synchronize_eschema('MyEntity')``.
   152     ``synchronize_eschema('MyEntity')``.
   148   * Add an attribute: ``add_attribute('MyEntityType', 'myattr')``.
   157   * Add an attribute: ``add_attribute('MyEntityType', 'myattr')``.
   149 
   158 
   150   * Add a relation: ``add_relation_definition('SubjRelation', 'MyRelation', 'ObjRelation')``.
   159   * Add a relation: ``add_relation_definition('SubjRelation', 'MyRelation', 'ObjRelation')``.
   151 
   160 
   152 
   161 
   153 * How to create an anonymous user?
   162 How to create an anonymous user?
       
   163 --------------------------------
   154 
   164 
   155   This allows to bypass authentication for your site. In the
   165   This allows to bypass authentication for your site. In the
   156   ``all-in-one.conf`` file of your instance, define the anonymous user
   166   ``all-in-one.conf`` file of your instance, define the anonymous user
   157   as follows ::
   167   as follows ::
   158 
   168 
   173     While creating a new instance, you can decide to allow access
   183     While creating a new instance, you can decide to allow access
   174     to anonymous user, which will automatically execute what is
   184     to anonymous user, which will automatically execute what is
   175     decribed above.
   185     decribed above.
   176 
   186 
   177 
   187 
   178 * How to change the application logo?
   188 How to change the application logo?
       
   189 -----------------------------------
   179 
   190 
   180   There are two ways of changing the logo.
   191   There are two ways of changing the logo.
   181 
   192 
   182   1. The easiest way to use a different logo is to replace the existing
   193   1. The easiest way to use a different logo is to replace the existing
   183      ``logo.png`` in ``myapp/data`` by your prefered icon and refresh.
   194      ``logo.png`` in ``myapp/data`` by your prefered icon and refresh.
   191 
   202 
   192        LOGO = DATADIR/path/to/mylogo.gif
   203        LOGO = DATADIR/path/to/mylogo.gif
   193 
   204 
   194      where DATADIR is ``mycubes/data``.
   205      where DATADIR is ``mycubes/data``.
   195 
   206 
   196 * How to configure LDAP source?
   207 How to configure LDAP source?
       
   208 -------------------------------
   197 
   209 
   198   Your instance's sources are defined in ``/etc/cubicweb.d/myapp/sources``.
   210   Your instance's sources are defined in ``/etc/cubicweb.d/myapp/sources``.
   199   Configuring an LDAP source is about declaring that source in your
   211   Configuring an LDAP source is about declaring that source in your
   200   instance configuration file such as: ::
   212   instance configuration file such as: ::
   201 
   213 
   217     user-attrs-map=gecos:email,uid:login
   229     user-attrs-map=gecos:email,uid:login
   218 
   230 
   219   Any change applied to configuration file requires to restart your
   231   Any change applied to configuration file requires to restart your
   220   application.
   232   application.
   221 
   233 
   222 * I get NoSelectableObject exceptions: how do I debug selectors ?
   234 I get NoSelectableObject exceptions: how do I debug selectors ?
       
   235 ---------------------------------------------------------------
   223 
   236 
   224   You just need to put the appropriate context manager around view/component
   237   You just need to put the appropriate context manager around view/component
   225   selection: ::
   238   selection: ::
   226 
   239 
   227     from cubicweb.common.selectors import traced_selection
   240     from cubicweb.common.selectors import traced_selection
   231 
   244 
   232   This will yield additional WARNINGs, like this: ::
   245   This will yield additional WARNINGs, like this: ::
   233 
   246 
   234     2009-01-09 16:43:52 - (cubicweb.selectors) WARNING: selector one_line_rset returned 0 for <class 'cubicweb.web.views.basecomponents.WFHistoryVComponent'>
   247     2009-01-09 16:43:52 - (cubicweb.selectors) WARNING: selector one_line_rset returned 0 for <class 'cubicweb.web.views.basecomponents.WFHistoryVComponent'>
   235 
   248 
   236 * How to format an entity date attribute?
   249 How to format an entity date attribute?
       
   250 ---------------------------------------
   237 
   251 
   238   If your schema has an attribute of type Date or Datetime, you might
   252   If your schema has an attribute of type Date or Datetime, you might
   239   want to format it. First, you should define your preferred format using
   253   want to format it. First, you should define your preferred format using
   240   the site configuration panel ``http://appurl/view?vid=systemepropertiesform``
   254   the site configuration panel ``http://appurl/view?vid=systemepropertiesform``
   241   and then set ``ui.date`` and/or ``ui.datetime``.
   255   and then set ``ui.date`` and/or ``ui.datetime``.
   242   Then in the view code, use::
   256   Then in the view code, use::
   243     
   257     
   244     self.format_date(entity.date_attribute)
   258     self.format_date(entity.date_attribute)
       
   259 
       
   260 Can PostgreSQL and CubicWeb authentication work with kerberos ?
       
   261 ----------------------------------------------------------------
       
   262 
       
   263   If you have postgresql set up to accept kerberos authentication, you can set
       
   264   the db-host, db-name and db-user parameters in the `sources` configuration
       
   265   file while leaving the password blank. It should be enough for your instance
       
   266   to connect to postgresql with a kerberos ticket.
       
   267 
       
   268   
       
   269 How to load data from a script?
       
   270 -------------------------------
       
   271 
       
   272   The following script aims at loading data within a script assuming pyro-nsd is
       
   273   running and your application is configured with ``pyro-server=yes``, otherwise
       
   274   you would not be able to use dbapi. ::
       
   275 
       
   276     from cubicweb import dbapi
       
   277 
       
   278     cnx = dbapi.connection(database='instance-id', user='admin', password='admin')
       
   279     cur = cnx.cursor()
       
   280     for name in ('Personal', 'Professional', 'Computers'):
       
   281         cur.execute('INSERT Blog B: B name %s', name)
       
   282     cnx.commit()
       
   283 
       
   284 What is the CubicWeb datatype corresponding to GAE datastore's UserProperty?
       
   285 ----------------------------------------------------------------------------
       
   286 
       
   287   If you take a look at your application schema and
       
   288   click on "display detailed view of metadata" you will see that there
       
   289   is a Euser entity in there. That's the one that is modeling users. The
       
   290   thing that corresponds to a UserProperty is a relationship between
       
   291   your entity and the Euser entity. As in ::
       
   292 
       
   293     class TodoItem(EntityType):
       
   294        text = String()
       
   295        todo_by = SubjectRelation('Euser')
       
   296 
       
   297   [XXX check that cw handle users better by
       
   298   mapping Google Accounts to local Euser entities automatically]
       
   299 
       
   300 
       
   301 How to implement security?
       
   302 --------------------------
       
   303 
       
   304   This is an example of how it works in our framework::
       
   305 
       
   306     class Version(EntityType):
       
   307     """a version is defining the content of a particular project's
       
   308     release"""
       
   309     # definition of attributes is voluntarily missing
       
   310     permissions = {'read': ('managers', 'users', 'guests',),
       
   311                    'update': ('managers', 'logilab', 'owners',),
       
   312                    'delete': ('managers', ),
       
   313                    'add': ('managers', 'logilab',
       
   314                         ERQLExpression('X version_of PROJ, U in_group G, PROJ
       
   315                         require_permission P, P name "add_version", P require_group G'),)}
       
   316 
       
   317   The above means that permission to read a Version is granted to any
       
   318   user that is part of one of the groups 'managers', 'users', 'guests'.
       
   319   The 'add' permission is granted to users in group 'managers' or
       
   320   'logilab' and to users in group G, if G is linked by a permission
       
   321   entity named "add_version" to the version's project.
       
   322   ::
       
   323 
       
   324     class version_of(RelationType):
       
   325         """link a version to its project. A version is necessarily linked
       
   326         to one and only one project. """
       
   327         # some lines voluntarily missing
       
   328         permissions = {'read': ('managers', 'users', 'guests',),
       
   329                        'delete': ('managers', ),
       
   330                        'add': ('managers', 'logilab',
       
   331                             RRQLExpression('O require_permission P, P name "add_version",
       
   332                             'U in_group G, P require_group G'),) }
       
   333 
       
   334   You can find additional information in the section :ref:`security`.
       
   335 
       
   336   [XXX what does the second example means in addition to the first one?]
       
   337