|
1 .. -*- coding: utf-8 -*- |
|
2 |
|
3 Frequently Asked Questions |
|
4 ========================== |
|
5 |
|
6 [XXX 'copy answer from forum' means reusing text from |
|
7 http://groups.google.com/group/google-appengine/browse_frm/thread/c9476925f5f66ec6 |
|
8 and |
|
9 http://groups.google.com/group/google-appengine/browse_frm/thread/d791ce17e2716147/eb078f8cfe8426e0 |
|
10 and |
|
11 http://groups.google.com/group/google-appengine/browse_frm/thread/f48cf6099973aef5/c28cd6934dd72457 |
|
12 ] |
|
13 |
|
14 * Why does not CubicWeb have a template language ? |
|
15 |
|
16 There are enough template languages out there. You can use your |
|
17 preferred template language if you want. [explain how to use a |
|
18 template language] |
|
19 |
|
20 `CubicWeb` does not define its own templating language as this was |
|
21 not our goal. Based on our experience, we realized that |
|
22 we could gain productivity by letting designers use design tools |
|
23 and developpers develop without the use of the templating language |
|
24 as an intermediary that could not be anyway efficient for both parties. |
|
25 Python is the templating language that we use in `CubicWeb`, but again, |
|
26 it does not prevent you from using a templating language. |
|
27 |
|
28 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 |
|
31 * Why do you think using pure python is better than using a template language ? |
|
32 |
|
33 Python is an Object Oriented Programming language and as such it |
|
34 already provides a consistent and strong architecture and syntax |
|
35 a templating language would not reach. |
|
36 |
|
37 When doing development, you need a real language and template |
|
38 languages are not real languages. |
|
39 |
|
40 Using Python enables developing applications for which code is |
|
41 easier to maintain with real functions/classes/contexts |
|
42 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 |
|
44 robust application. |
|
45 |
|
46 * Why do you use the GPL license to prevent me from doing X ? |
|
47 |
|
48 GPL means that *if* you redistribute your application, you need to |
|
49 redistribute it *and* the changes you made *and* the code _linked_ |
|
50 to it under the GPL licence. |
|
51 |
|
52 Publishing a web site has nothing to do with redistributing |
|
53 source code. A fair amount of companies use modified GPL code |
|
54 for internal use. And someone could publish a `CubicWeb` component |
|
55 under a BSD licence for others to plug into a GPL framework without |
|
56 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 |
|
58 clients. |
|
59 |
|
60 |
|
61 * CubicWeb looks pretty recent. Is it stable ? |
|
62 |
|
63 It is constantly evolving, piece by piece. The framework has |
|
64 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 |
|
66 handle data and schema migration. |
|
67 |
|
68 * Why is the RQL query language looking similar to X ? |
|
69 |
|
70 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. |
|
72 Having SPARQL has a query language has been in our backlog for years. |
|
73 |
|
74 That RQL language is what is going to make a difference with django- |
|
75 like frameworks for several reasons. |
|
76 |
|
77 1. accessing data is *much* easier with it. One can write complex |
|
78 queries with RQL that would be tedious to define and hard to maintain |
|
79 using an object/filter suite of method calls. |
|
80 |
|
81 2. it offers an abstraction layer allowing your applications to run |
|
82 on multiple back-ends. That means not only various SQL backends |
|
83 (postgresql, sqlite, mysql), but also multiple databases at the |
|
84 same time, and also non-SQL data stores like LDAP directories and |
|
85 subversion/mercurial repositories (see the `vcsfile` |
|
86 component). Google App Engine is yet another supported target for |
|
87 RQL. |
|
88 |
|
89 [copy answer from forum, explain why similar to sparql and why better |
|
90 than django and SQL] |
|
91 |
|
92 * which ajax library |
|
93 |
|
94 [we use jquery and things on top of that] |
|
95 |
|
96 * `Error while publishing rest text ...` |
|
97 |
|
98 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. |
|
100 The server returns a traceback like as follows :: |
|
101 |
|
102 2008-10-06 15:05:08 - (cubicweb.rest) ERROR: error while publishing ReST text |
|
103 Traceback (most recent call last): |
|
104 File "/home/user/src/blogdemo/cubicweb/common/rest.py", line 217, in rest_publish |
|
105 File "/usr/lib/python2.5/codecs.py", line 817, in open |
|
106 file = __builtin__.open(filename, mode, buffering) |
|
107 TypeError: __init__() takes at most 3 arguments (4 given) |
|
108 |
|
109 |
|
110 This can be fixed by applying the patch described in : |
|
111 http://code.google.com/p/googleappengine/issues/detail?id=48 |
|
112 |
|
113 * What are hooks used for? |
|
114 |
|
115 Hooks are executed around (actually before or after) events. The |
|
116 most common events are data creation, update and deletion. They |
|
117 permit additional constraint checking (those not expressible at the |
|
118 schema level), pre and post computations depending on data |
|
119 movements. |
|
120 |
|
121 As such, they are a vital part of the framework. |
|
122 |
|
123 Other kinds of hooks, called Operations, are available |
|
124 for execution just before commit. |
|
125 |
|
126 * When should you define an HTML template rather than define a graphical component? |
|
127 |
|
128 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 |
|
130 well defined context (request, result set). It enables much more |
|
131 dynamic views. |
|
132 |
|
133 * What is the difference between `AppRsetObject` and `AppObject` ? |
|
134 |
|
135 `AppRsetObject` instances are selected on a request and a result |
|
136 set. `AppObject` instances are directly selected by id. |
|
137 |
|
138 * How to update a database after a schema modification? |
|
139 |
|
140 It depends on what has been modified in the schema. |
|
141 |
|
142 * Update of an attribute permissions and properties: |
|
143 ``synchronize_eschema('MyEntity')``. |
|
144 |
|
145 * Update of a relation permissions and properties: |
|
146 ``synchronize_rschema('MyRelation')``. |
|
147 |
|
148 * Add an attribute: ``add_attribute('MyEntityType', 'myattr')``. |
|
149 |
|
150 * Add a relation: ``add_relation_definition('SubjRelation', 'MyRelation', 'ObjRelation')``. |
|
151 |
|
152 |
|
153 * How to create an anonymous user? |
|
154 |
|
155 This allows to bypass authentication for your site. In the |
|
156 ``all-in-one.conf`` file of your instance, define the anonymous user |
|
157 as follows :: |
|
158 |
|
159 # login of the CubicWeb user account to use for anonymous user (if you want to |
|
160 # allow anonymous) |
|
161 anonymous-user=anon |
|
162 |
|
163 # password of the CubicWeb user account matching login |
|
164 anonymous-password=anon |
|
165 |
|
166 You also must ensure that this `anon` user is a registered user of |
|
167 the DB backend. If not, you can create through the administation |
|
168 interface of your instance by adding a user with the role `guests`. |
|
169 This could be the admin account (for development |
|
170 purposes, of course). |
|
171 |
|
172 .. note:: |
|
173 While creating a new instance, you can decide to allow access |
|
174 to anonymous user, which will automatically execute what is |
|
175 decribed above. |
|
176 |
|
177 |
|
178 * How to change the application logo? |
|
179 |
|
180 There are two ways of changing the logo. |
|
181 |
|
182 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. |
|
184 By default all application will look for a ``logo.png`` to be |
|
185 rendered in the logo section. |
|
186 |
|
187 .. image:: ../images/lax-book.06-main-template-logo.en.png |
|
188 |
|
189 2. In your cube directory, you can specify which file to use for the logo. |
|
190 This is configurable in ``mycube/data/external_resources``: :: |
|
191 |
|
192 LOGO = DATADIR/path/to/mylogo.gif |
|
193 |
|
194 where DATADIR is ``mycubes/data``. |
|
195 |
|
196 * How to configure LDAP source? |
|
197 |
|
198 Your instance's sources are defined in ``/etc/cubicweb.d/myapp/sources``. |
|
199 Configuring an LDAP source is about declaring that source in your |
|
200 instance configuration file such as: :: |
|
201 |
|
202 [ldapuser] |
|
203 adapter=ldapuser |
|
204 # ldap host |
|
205 host=myhost |
|
206 # base DN to lookup for usres |
|
207 user-base-dn=ou=People,dc=mydomain,dc=fr |
|
208 # user search scope |
|
209 user-scope=ONELEVEL |
|
210 # classes of user |
|
211 user-classes=top,posixAccount |
|
212 # attribute used as login on authentication |
|
213 user-login-attr=uid |
|
214 # name of a group in which ldap users will be by default |
|
215 user-default-group=users |
|
216 # map from ldap user attributes to cubicweb attributes |
|
217 user-attrs-map=gecos:email,uid:login |
|
218 |
|
219 Any change applied to configuration file requires to restart your |
|
220 application. |
|
221 |
|
222 * I get NoSelectableObject exceptions: how do I debug selectors ? |
|
223 |
|
224 You just need to put the appropriate context manager around view/component |
|
225 selection: :: |
|
226 |
|
227 from cubicweb.common.selectors import traced_selection |
|
228 with traced_selection(): |
|
229 comp = self.vreg.select_object('contentnavigation', 'wfhistory', |
|
230 self.req, rset, context='navcontentbottom') |
|
231 |
|
232 This will yield additional WARNINGs, like this: :: |
|
233 |
|
234 2009-01-09 16:43:52 - (cubicweb.selectors) WARNING: selector one_line_rset returned 0 for <class 'cubicweb.web.views.basecomponents.WFHistoryVComponent'> |
|
235 |
|
236 * How to format an entity date attribute? |
|
237 |
|
238 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 |
|
240 the site configuration panel ``http://appurl/view?vid=systemepropertiesform`` |
|
241 and then set ``ui.date`` and/or ``ui.datetime``. |
|
242 Then in the view code, use:: |
|
243 |
|
244 self.format_date(entity.date_attribute) |