doc/book/en/annexes/faq.rst
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 28 Jun 2011 17:59:31 +0200
changeset 7570 648bf83945a5
parent 7529 2fdc310be7cd
child 7813 89ab98c4aaab
permissions -rw-r--r--
[etwist] log missing file even in debug mode
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     1
.. -*- coding: utf-8 -*-
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     2
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
     3
Frequently Asked Questions (FAQ)
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
     4
================================
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
     5
310
cdd2b1247c50 [doc] add links to google-appengine forum
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 306
diff changeset
     6
[XXX 'copy answer from forum' means reusing text from
cdd2b1247c50 [doc] add links to google-appengine forum
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 306
diff changeset
     7
http://groups.google.com/group/google-appengine/browse_frm/thread/c9476925f5f66ec6
cdd2b1247c50 [doc] add links to google-appengine forum
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 306
diff changeset
     8
and
cdd2b1247c50 [doc] add links to google-appengine forum
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 306
diff changeset
     9
http://groups.google.com/group/google-appengine/browse_frm/thread/f48cf6099973aef5/c28cd6934dd72457
cdd2b1247c50 [doc] add links to google-appengine forum
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 306
diff changeset
    10
]
cdd2b1247c50 [doc] add links to google-appengine forum
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 306
diff changeset
    11
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    12
Generalities
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    13
````````````
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    14
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    15
Why do you use the LGPL license to prevent me from doing X ?
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    16
------------------------------------------------------------
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    17
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    18
LGPL means that *if* you redistribute your application, you need to
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    19
redistribute the changes you made to CubicWeb under the LGPL licence.
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    20
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    21
Publishing a web site has nothing to do with redistributing source
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    22
code according to the terms of the LGPL. A fair amount of companies
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    23
use modified LGPL code for internal use. And someone could publish a
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    24
*CubicWeb* component under a BSD licence for others to plug into a
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    25
LGPL framework without any problem. The only thing we are trying to
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    26
prevent here is someone taking the framework and packaging it as
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    27
closed source to his own clients.
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    28
1715
sylvain.thenault@logilab.fr
parents: 1599 1714
diff changeset
    29
Why does not CubicWeb have a template language ?
sylvain.thenault@logilab.fr
parents: 1599 1714
diff changeset
    30
------------------------------------------------
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
    31
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    32
There are enough template languages out there. You can use your
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    33
preferred template language if you want. [explain how to use a
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    34
template language]
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
    35
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    36
*CubicWeb* does not define its own templating language as this was
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    37
not our goal. Based on our experience, we realized that
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    38
we could gain productivity by letting designers use design tools
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    39
and developpers develop without the use of the templating language
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    40
as an intermediary that could not be anyway efficient for both parties.
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    41
Python is the templating language that we use in *CubicWeb*, but again,
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    42
it does not prevent you from using a templating language.
337
eb329d0db467 [doc] FAQ improvements based on posts in forums.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 335
diff changeset
    43
5156
0ec436cba1a6 [doc/book] add q/a on i18n customisation, misc tweaks
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4936
diff changeset
    44
Moreover, CubicWeb currently supports `simpletal`_ out of the box and
0ec436cba1a6 [doc/book] add q/a on i18n customisation, misc tweaks
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4936
diff changeset
    45
it is also possible to use the `cwtags`_ library to build html trees
0ec436cba1a6 [doc/book] add q/a on i18n customisation, misc tweaks
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4936
diff changeset
    46
using the `with statement`_ with more comfort than raw strings.
0ec436cba1a6 [doc/book] add q/a on i18n customisation, misc tweaks
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4936
diff changeset
    47
0ec436cba1a6 [doc/book] add q/a on i18n customisation, misc tweaks
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4936
diff changeset
    48
.. _`simpletal`: http://www.owlfish.com/software/simpleTAL/
0ec436cba1a6 [doc/book] add q/a on i18n customisation, misc tweaks
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4936
diff changeset
    49
.. _`cwtags`: http://www.cubicweb.org/project/cwtags
0ec436cba1a6 [doc/book] add q/a on i18n customisation, misc tweaks
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4936
diff changeset
    50
.. _`with statement`: http://www.python.org/dev/peps/pep-0343/
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
    51
1715
sylvain.thenault@logilab.fr
parents: 1599 1714
diff changeset
    52
Why do you think using pure python is better than using a template language ?
sylvain.thenault@logilab.fr
parents: 1599 1714
diff changeset
    53
-----------------------------------------------------------------------------
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
    54
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    55
Python is an Object Oriented Programming language and as such it
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    56
already provides a consistent and strong architecture and syntax
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    57
a templating language would not reach.
345
31f88b2e3500 more translation and complements
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 344
diff changeset
    58
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    59
Using Python instead of a template langage for describing the user interface
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    60
makes it to maintain with real functions/classes/contexts without the need of
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    61
learning a new dialect. By using Python, we use standard OOP techniques and
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    62
this is a key factor in a robust application.
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
    63
1715
sylvain.thenault@logilab.fr
parents: 1599 1714
diff changeset
    64
CubicWeb looks pretty recent. Is it stable ?
sylvain.thenault@logilab.fr
parents: 1599 1714
diff changeset
    65
--------------------------------------------
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
    66
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    67
It is constantly evolving, piece by piece.  The framework has evolved since
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    68
2001 and data has been migrated from one schema to the other ever since. There
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    69
is a well-defined way to handle data and schema migration.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    70
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    71
You can see the roadmap there:
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    72
http://www.cubicweb.org/project/cubicweb?tab=projectroadmap_tab.
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    73
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
    74
1715
sylvain.thenault@logilab.fr
parents: 1599 1714
diff changeset
    75
Why is the RQL query language looking similar to X ?
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
    76
----------------------------------------------------
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
    77
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    78
It may remind you of SQL but it is higher level than SQL, more like
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    79
SPARQL. Except that SPARQL did not exist when we started the project.
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    80
With version 3.4, CubicWeb has support for SPARQL.
337
eb329d0db467 [doc] FAQ improvements based on posts in forums.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 335
diff changeset
    81
5156
0ec436cba1a6 [doc/book] add q/a on i18n customisation, misc tweaks
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4936
diff changeset
    82
The RQL language is what is going to make a difference with django-
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    83
like frameworks for several reasons.
337
eb329d0db467 [doc] FAQ improvements based on posts in forums.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 335
diff changeset
    84
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    85
1. accessing data is *much* easier with it. One can write complex
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    86
   queries with RQL that would be tedious to define and hard to maintain
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    87
   using an object/filter suite of method calls.
337
eb329d0db467 [doc] FAQ improvements based on posts in forums.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 335
diff changeset
    88
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    89
2. it offers an abstraction layer allowing your applications to run
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    90
   on multiple back-ends. That means not only various SQL backends
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    91
   (postgresql, sqlite, mysql), but also multiple databases at the
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    92
   same time, and also non-SQL data stores like LDAP directories and
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    93
   subversion/mercurial repositories (see the `vcsfile`
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    94
   component). Google App Engine is yet another supported target for
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
    95
   RQL.
337
eb329d0db467 [doc] FAQ improvements based on posts in forums.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 335
diff changeset
    96
4748
135329e51713 [book/faq] cleanup & complete a bit
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2547
diff changeset
    97
Which ajax library is CubicWeb using ?
2173
7fae9300b9f9 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    98
--------------------------------------
7fae9300b9f9 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    99
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   100
CubicWeb uses jQuery_ and provides a few helpers on top of that. Additionally,
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   101
some jQuery plugins are provided (some are provided in specific cubes).
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   102
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   103
.. _jQuery: http://jquery.com
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   104
1678
67162cb05b4b [doc] Add FAQ entries based on answers from forum.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 1677
diff changeset
   105
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   106
Development
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   107
```````````
1678
67162cb05b4b [doc] Add FAQ entries based on answers from forum.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 1677
diff changeset
   108
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   109
How to change the instance logo ?
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   110
---------------------------------
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   111
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   112
There are two ways of changing the logo.
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   113
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   114
1. The easiest way to use a different logo is to replace the existing
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   115
   ``logo.png`` in ``myapp/data`` by your prefered icon and refresh.
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   116
   By default all instance will look for a ``logo.png`` to be
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   117
   rendered in the logo section.
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   118
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   119
   .. image:: ../images/lax-book_06-main-template-logo_en.png
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   120
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   121
2. In your cube directory, you can specify which file to use for the logo.
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   122
   This is configurable in ``mycube/uiprops.py``: ::
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   123
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   124
     LOGO = data('mylogo.gif')
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   125
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   126
   ``mylogo.gif`` is in ``mycube/data`` directory.
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   127
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   128
How to create an anonymous user ?
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   129
---------------------------------
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   130
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   131
This allows to browse the site without being authenticated. In the
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   132
``all-in-one.conf`` file of your instance, define the anonymous user
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   133
as follows ::
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   134
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   135
  # login of the CubicWeb user account to use for anonymous user (if you want to
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   136
  # allow anonymous)
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   137
  anonymous-user=anon
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   138
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   139
  # password of the CubicWeb user account matching login
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   140
  anonymous-password=anon
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   141
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   142
You also must ensure that this `anon` user is a registered user of
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   143
the DB backend. If not, you can create through the administation
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   144
interface of your instance by adding a user with in the group `guests`.
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   145
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   146
.. note::
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   147
    While creating a new instance, you can decide to allow access
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   148
    to anonymous user, which will automatically execute what is
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   149
    decribed above.
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   150
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   151
How to load data from a script ?
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   152
--------------------------------
4748
135329e51713 [book/faq] cleanup & complete a bit
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2547
diff changeset
   153
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   154
The following script aims at loading data within a script assuming pyro-nsd is
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   155
running and your instance is configured with ``pyro-server=yes``, otherwise
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   156
you would not be able to use dbapi.
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
   157
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
   158
.. sourcecode:: python
1678
67162cb05b4b [doc] Add FAQ entries based on answers from forum.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 1677
diff changeset
   159
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   160
    from cubicweb import dbapi
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   161
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   162
    cnx = dbapi.connect(database='instance-id', user='admin', password='admin')
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   163
    cur = cnx.cursor()
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   164
    for name in (u'Personal', u'Professional', u'Computers'):
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   165
        cur.execute('INSERT Tag T: T name %(n)s', {'n': name})
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   166
    cnx.commit()
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   167
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   168
Wether your instance as pyro activated or not, you can still acheive this by
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   169
using cubicweb-ctl shell scripts.
1678
67162cb05b4b [doc] Add FAQ entries based on answers from forum.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 1677
diff changeset
   170
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   171
How to format an entity date attribute ?
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   172
----------------------------------------
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
   173
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   174
If your schema has an attribute of type `Date` or `Datetime`, you usually want to
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   175
format it when displaying it. First, you should define your preferred format
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   176
using the site configuration panel
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   177
``http://appurl/view?vid=systempropertiesform`` and then set ``ui.date`` and/or
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   178
``ui.datetime``.  Then in the view code, use:
4748
135329e51713 [book/faq] cleanup & complete a bit
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2547
diff changeset
   179
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
   180
.. sourcecode:: python
1678
67162cb05b4b [doc] Add FAQ entries based on answers from forum.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 1677
diff changeset
   181
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   182
    entity.printable_value(date_attribute)
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   183
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   184
which will always return a string whatever the attribute's type (so it's
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   185
recommended also for other attribute types). By default it expects to generate
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   186
HTML, so it deals with rich text formating, xml escaping...
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   187
2173
7fae9300b9f9 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
   188
How to update a database after a schema modification ?
7fae9300b9f9 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
   189
------------------------------------------------------
345
31f88b2e3500 more translation and complements
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 344
diff changeset
   190
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
   191
It depends on what has been modified in the schema.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   192
5156
0ec436cba1a6 [doc/book] add q/a on i18n customisation, misc tweaks
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4936
diff changeset
   193
* update the permissions and properties of an entity or a relation:
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
   194
  ``sync_schema_props_perms('MyEntityOrRelation')``.
1350
31e4c8d30e5d [doc] Adds how to add attribute in DB.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 1348
diff changeset
   195
5156
0ec436cba1a6 [doc/book] add q/a on i18n customisation, misc tweaks
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4936
diff changeset
   196
* add an attribute: ``add_attribute('MyEntityType', 'myattr')``.
1350
31e4c8d30e5d [doc] Adds how to add attribute in DB.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 1348
diff changeset
   197
5156
0ec436cba1a6 [doc/book] add q/a on i18n customisation, misc tweaks
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4936
diff changeset
   198
* add a relation: ``add_relation_definition('SubjRelation', 'MyRelation', 'ObjRelation')``.
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   199
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   200
I get `NoSelectableObject` exceptions, how do I debug selectors ?
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   201
-----------------------------------------------------------------
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   202
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   203
You just need to put the appropriate context manager around view/component
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   204
selection. One standard place for components is in cubicweb/vregistry.py: 
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   205
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   206
.. sourcecode:: python
345
31f88b2e3500 more translation and complements
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 344
diff changeset
   207
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   208
    def possible_objects(self, *args, **kwargs):
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   209
        """return an iterator on possible objects in this registry for the given
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   210
        context
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   211
        """
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   212
        from cubicweb.selectors import traced_selection
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   213
        with traced_selection():
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   214
            for appobjects in self.itervalues():
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   215
                try:
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   216
                    yield self._select_best(appobjects, *args, **kwargs)
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   217
                except NoSelectableObject:
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   218
                    continue
345
31f88b2e3500 more translation and complements
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 344
diff changeset
   219
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   220
Don't forget the 'from __future__ import with_statement' at the module
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   221
top-level if you're using python 2.5.
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   222
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   223
This will yield additional WARNINGs, like this::
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   224
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   225
    2009-01-09 16:43:52 - (cubicweb.selectors) WARNING: selector one_line_rset returned 0 for <class 'cubicweb.web.views.basecomponents.WFHistoryVComponent'>
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   226
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   227
For views, you can put this context in `cubicweb/web/views/basecontrollers.py` in
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   228
the `ViewController`:
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   229
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   230
.. sourcecode:: python
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   231
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   232
    def _select_view_and_rset(self, rset):
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   233
        ...
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   234
        try:
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   235
            from cubicweb.selectors import traced_selection
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   236
            with traced_selection():
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   237
                view = self._cw.vreg['views'].select(vid, req, rset=rset)
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   238
        except ObjectNotFound:
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   239
            self.warning("the view %s could not be found", vid)
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   240
            req.set_message(req._("The view %s could not be found") % vid)
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   241
            vid = vid_from_rset(req, rset, self._cw.vreg.schema)
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   242
            view = self._cw.vreg['views'].select(vid, req, rset=rset)
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   243
        ...
93
9c919a47e140 [doc] total file reorganisation - phase 1 complete
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   244
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   245
I get "database is locked" when executing tests
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   246
-----------------------------------------------
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   247
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   248
If you have "database is locked" as error when you are executing security tests,
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   249
it is usually because commit or rollback are missing before login() calls.
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   250
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   251
You can also use a context manager, to avoid such errors, as described
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   252
here: :ref:`securitytest`.
1348
28bb9efe0cc8 [doc] Add information on anonymous user configuration.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 1191
diff changeset
   253
199
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   254
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   255
What are hooks used for ?
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   256
-------------------------
345
31f88b2e3500 more translation and complements
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 344
diff changeset
   257
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   258
Hooks are executed around (actually before or after) events.  The most common
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   259
events are data creation, update and deletion.  They permit additional constraint
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   260
checking (those not expressible at the schema level), pre and post computations
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   261
depending on data movements.
199
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   262
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   263
As such, they are a vital part of the framework.
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 113
diff changeset
   264
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   265
Other kinds of hooks, called Operations, are available
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   266
for execution just before commit.
345
31f88b2e3500 more translation and complements
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 344
diff changeset
   267
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   268
For more information, read :ref:`hooks` section.
199
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   269
c603087373cd [doc] Inserted content from LAX book about templates.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 127
diff changeset
   270
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   271
Configuration
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   272
`````````````
1808
aa09e20dd8c0 backport tls-sprint
sylvain.thenault@logilab.fr
parents: 1678 1715
diff changeset
   273
2173
7fae9300b9f9 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
   274
How to configure a LDAP source ?
7fae9300b9f9 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
   275
--------------------------------
335
643db91242b1 [doc] Integration of card http://intranet.logilab.fr/intra/card/eid/3355 to the book.
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 317
diff changeset
   276
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   277
See :ref:`LDAP`.
4748
135329e51713 [book/faq] cleanup & complete a bit
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 2547
diff changeset
   278
5393
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   279
How to import LDAP users in |cubicweb| ?
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   280
----------------------------------------
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   281
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   282
  Here is a useful script which enables you to import LDAP users
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   283
  into your *CubicWeb* instance by running the following:
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   284
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   285
.. sourcecode:: python
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   286
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   287
    import os
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   288
    import pwd
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   289
    import sys
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   290
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   291
    from logilab.database import get_connection
5393
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   292
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   293
    def getlogin():
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   294
        """avoid using os.getlogin() because of strange tty/stdin problems
5393
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   295
        (man 3 getlogin)
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   296
        Another solution would be to use $LOGNAME, $USER or $USERNAME
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   297
        """
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   298
        return pwd.getpwuid(os.getuid())[0]
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   299
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   300
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   301
    try:
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   302
        database = sys.argv[1]
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   303
    except IndexError:
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   304
        print 'USAGE: python ldap2system.py <database>'
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   305
        sys.exit(1)
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   306
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   307
    if raw_input('update %s db ? [y/n]: ' % database).strip().lower().startswith('y'):
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   308
        cnx = get_connection(user=getlogin(), database=database)
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   309
        cursor = cnx.cursor()
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   310
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   311
        insert = ('INSERT INTO euser (creation_date, eid, modification_date, login, '
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   312
                  ' firstname, surname, last_login_time, upassword) '
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   313
                  "VALUES (%(mtime)s, %(eid)s, %(mtime)s, %(login)s, %(firstname)s, "
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   314
                  "%(surname)s, %(mtime)s, './fqEz5LeZnT6');")
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   315
        update = "UPDATE entities SET source='system' WHERE eid=%(eid)s;"
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   316
        cursor.execute("SELECT eid,type,source,extid,mtime FROM entities WHERE source!='system'")
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   317
        for eid, type, source, extid, mtime in cursor.fetchall():
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   318
            if type != 'CWUser':
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   319
                print "don't know what to do with entity type", type
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   320
                continue
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   321
            if source != 'ldapuser':
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   322
                print "don't know what to do with source type", source
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   323
                continue
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   324
            ldapinfos = dict(x.strip().split('=') for x in extid.split(','))
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   325
            login = ldapinfos['uid']
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   326
            firstname = ldapinfos['uid'][0].upper()
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   327
            surname = ldapinfos['uid'][1:].capitalize()
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   328
            if login != 'jcuissinat':
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   329
                args = dict(eid=eid, type=type, source=source, login=login,
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   330
                            firstname=firstname, surname=surname, mtime=mtime)
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   331
                print args
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   332
                cursor.execute(insert, args)
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   333
                cursor.execute(update, args)
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   334
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   335
        cnx.commit()
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   336
        cnx.close()
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   337
875bdc0fe8ce [doc/book] hide most XXXs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5388
diff changeset
   338
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   339
Security
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   340
````````
1890
108f3b6584b7 [doc] add faq about reseting password for some user
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1808
diff changeset
   341
2173
7fae9300b9f9 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
   342
How to reset the password for user joe ?
7fae9300b9f9 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
   343
----------------------------------------
1890
108f3b6584b7 [doc] add faq about reseting password for some user
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1808
diff changeset
   344
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
   345
If you want to reset the admin password for ``myinstance``, do::
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
   346
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
   347
    $ cubicweb-ctl reset-admin-pwd myinstance
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
   348
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
   349
You need to generate a new encrypted password::
1890
108f3b6584b7 [doc] add faq about reseting password for some user
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1808
diff changeset
   350
108f3b6584b7 [doc] add faq about reseting password for some user
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1808
diff changeset
   351
    $ python
108f3b6584b7 [doc] add faq about reseting password for some user
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1808
diff changeset
   352
    >>> from cubicweb.server.utils import crypt_password
108f3b6584b7 [doc] add faq about reseting password for some user
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1808
diff changeset
   353
    >>> crypt_password('joepass')
108f3b6584b7 [doc] add faq about reseting password for some user
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1808
diff changeset
   354
    'qHO8282QN5Utg'
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2041
diff changeset
   355
    >>>
1890
108f3b6584b7 [doc] add faq about reseting password for some user
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1808
diff changeset
   356
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
   357
and paste it in the database::
1890
108f3b6584b7 [doc] add faq about reseting password for some user
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1808
diff changeset
   358
108f3b6584b7 [doc] add faq about reseting password for some user
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1808
diff changeset
   359
    $ psql mydb
108f3b6584b7 [doc] add faq about reseting password for some user
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1808
diff changeset
   360
    mydb=> update cw_cwuser set cw_upassword='qHO8282QN5Utg' where cw_login='joe';
2041
296e897ab8e1 be more precise & helpful
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1900
diff changeset
   361
    UPDATE 1
2316
234475d6ed7b added entry about bad user account
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 2175
diff changeset
   362
6350
74575fb32a4d [book] updated FAQ 'How to reset the password for user joe' with SQL Server syntax
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5924
diff changeset
   363
if you're running over SQL Server, you need to use the CONVERT
74575fb32a4d [book] updated FAQ 'How to reset the password for user joe' with SQL Server syntax
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5924
diff changeset
   364
function to convert the string to varbinary(255). The SQL query is
74575fb32a4d [book] updated FAQ 'How to reset the password for user joe' with SQL Server syntax
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5924
diff changeset
   365
therefore::
74575fb32a4d [book] updated FAQ 'How to reset the password for user joe' with SQL Server syntax
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5924
diff changeset
   366
74575fb32a4d [book] updated FAQ 'How to reset the password for user joe' with SQL Server syntax
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5924
diff changeset
   367
    update cw_cwuser set cw_upassword=CONVERT(varbinary(255), 'qHO8282QN5Utg') where cw_login='joe';
74575fb32a4d [book] updated FAQ 'How to reset the password for user joe' with SQL Server syntax
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5924
diff changeset
   368
6352
2259d834d757 [book] note about different encryption on Unix and Windows
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6350
diff changeset
   369
Be careful, the encryption algorithm is different on Windows and on
2259d834d757 [book] note about different encryption on Unix and Windows
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6350
diff changeset
   370
Unix. You cannot therefore use a hash generated on Unix to fill in a
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   371
Windows database, nor the other way round.
6352
2259d834d757 [book] note about different encryption on Unix and Windows
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6350
diff changeset
   372
2259d834d757 [book] note about different encryption on Unix and Windows
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 6350
diff changeset
   373
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   374
You can prefer use a migration script similar to this shell invocation instead::
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   375
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   376
    $ cubicweb-ctl shell <instance>
7250
fe27390bf2f8 [book] fix documentation + add chpasswd.py script
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6592
diff changeset
   377
    >>> from cubicweb import Binary
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   378
    >>> from cubicweb.server.utils import crypt_password
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   379
    >>> crypted = crypt_password('joepass')
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   380
    >>> rset = rql('Any U WHERE U is CWUser, U login "joe"')
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   381
    >>> joe = rset.get_entity(0,0)
7250
fe27390bf2f8 [book] fix documentation + add chpasswd.py script
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6592
diff changeset
   382
    >>> joe.set_attributes(upassword=Binary(crypted))
fe27390bf2f8 [book] fix documentation + add chpasswd.py script
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6592
diff changeset
   383
fe27390bf2f8 [book] fix documentation + add chpasswd.py script
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6592
diff changeset
   384
Please, refer to the script example is provided in the `misc/examples/chpasswd.py` file.
5924
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   385
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   386
The more experimented people would use RQL request directly::
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   387
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   388
    >>> rql('SET X upassword %(a)s WHERE X is CWUser, X login "joe"',
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   389
    ...     {'a': crypted})
b218df942dd4 [book] update rql documentation and some erroneous/deprecated examples
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5781
diff changeset
   390
2316
234475d6ed7b added entry about bad user account
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 2175
diff changeset
   391
I've just created a user in a group and it doesn't work !
234475d6ed7b added entry about bad user account
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 2175
diff changeset
   392
---------------------------------------------------------
234475d6ed7b added entry about bad user account
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 2175
diff changeset
   393
234475d6ed7b added entry about bad user account
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 2175
diff changeset
   394
You are probably getting errors such as ::
234475d6ed7b added entry about bad user account
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 2175
diff changeset
   395
2547
f32af375339d [doc] fix FAQ layout
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2535
diff changeset
   396
  remove {'PR': 'Project', 'C': 'CWUser'} from solutions since your_user has no read access to cost
2316
234475d6ed7b added entry about bad user account
Arthur Lutz <arthur.lutz@logilab.fr>
parents: 2175
diff changeset
   397
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   398
This is because you have to put your user in the "users" group. The user has to
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   399
be in both groups.
5156
0ec436cba1a6 [doc/book] add q/a on i18n customisation, misc tweaks
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4936
diff changeset
   400
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   401
How is security implemented ?
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   402
------------------------------
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   403
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   404
The basis for security is a mapping from operations to groups or
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   405
arbitrary RQL expressions. These mappings are scoped to entities and
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   406
relations.
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   407
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   408
This is an example for an Entity Type definition:
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   409
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   410
.. sourcecode:: python
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   411
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   412
    class Version(EntityType):
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   413
        """a version is defining the content of a particular project's
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   414
        release"""
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   415
        # definition of attributes is voluntarily missing
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   416
        __permissions__ = {'read': ('managers', 'users', 'guests',),
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   417
                           'update': ('managers', 'logilab', 'owners'),
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   418
                           'delete': ('managers',),
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   419
                           'add': ('managers', 'logilab',
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   420
                                   ERQLExpression('X version_of PROJ, U in_group G, '
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   421
                                                  'PROJ require_permission P, '
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   422
                                                  'P name "add_version", P require_group G'),)}
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   423
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   424
The above means that permission to read a Version is granted to any
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   425
user that is part of one of the groups 'managers', 'users', 'guests'.
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   426
The 'add' permission is granted to users in group 'managers' or
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   427
'logilab' or to users in group G, if G is linked by a permission
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   428
entity named "add_version" to the version's project.
5156
0ec436cba1a6 [doc/book] add q/a on i18n customisation, misc tweaks
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 4936
diff changeset
   429
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   430
An example for a Relation Definition (RelationType both defines a
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   431
relation type and implicitly one relation definition, on which the
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   432
permissions actually apply):
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   433
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   434
.. sourcecode:: python
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   435
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   436
    class version_of(RelationType):
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   437
        """link a version to its project. A version is necessarily linked
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   438
        to one and only one project. """
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   439
        # some lines voluntarily missing
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   440
        __permissions__ = {'read': ('managers', 'users', 'guests',),
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   441
                           'delete': ('managers', ),
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   442
                           'add': ('managers', 'logilab',
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   443
                                   RRQLExpression('O require_permission P, P name "add_version", '
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   444
                                                  'U in_group G, P require_group G'),) }
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   445
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   446
The main difference lies in the basic available operations (there is
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   447
no 'update' operation) and the usage of an RRQLExpression (rql
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   448
expression for a relation) instead of an ERQLExpression (rql
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   449
expression for an entity).
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   450
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   451
You can find additional information in the section :ref:`securitymodel`.
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   452
5781
a3e60e0fb0f3 [doc/book/faq] question on security
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5393
diff changeset
   453
Is it possible to bypass security from the UI (web front) part ?
a3e60e0fb0f3 [doc/book/faq] question on security
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5393
diff changeset
   454
----------------------------------------------------------------
a3e60e0fb0f3 [doc/book/faq] question on security
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5393
diff changeset
   455
6592
4dad0ec0a44f [book] FAQ: reorganize content, improve NoSelectableObject section, add database
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 6352
diff changeset
   456
No. Only Hooks/Operations can do that.
5781
a3e60e0fb0f3 [doc/book/faq] question on security
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5393
diff changeset
   457
5228
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   458
Can PostgreSQL and CubicWeb authentication work with kerberos ?
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   459
----------------------------------------------------------------
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   460
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   461
If you have PostgreSQL set up to accept kerberos authentication, you can set
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   462
the db-host, db-name and db-user parameters in the `sources` configuration
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   463
file while leaving the password blank. It should be enough for your
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   464
instance to connect to postgresql with a kerberos ticket.
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   465
369b8aff535b [doc/book] add sections to the FAQ, try to reorder stuff
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 5157
diff changeset
   466