equal
deleted
inserted
replaced
197 |
197 |
198 - a *selector*, which is a kind of filter telling how well a view suit to a |
198 - a *selector*, which is a kind of filter telling how well a view suit to a |
199 particular context. When looking for a particular view (e.g. given an |
199 particular context. When looking for a particular view (e.g. given an |
200 identifier), |cubicweb| computes for each available view with that identifier |
200 identifier), |cubicweb| computes for each available view with that identifier |
201 a score which is returned by the selector. Then the view with the highest |
201 a score which is returned by the selector. Then the view with the highest |
202 score is used. The standard library of selectors is in |
202 score is used. The standard library of predicates is in |
203 :mod:`cubicweb.selector`. |
203 :mod:`cubicweb.predicates`. |
204 |
204 |
205 A view has a set of methods inherited from the :class:`cubicweb.view.View` class, |
205 A view has a set of methods inherited from the :class:`cubicweb.view.View` class, |
206 though you usually don't derive directly from this class but from one of its more |
206 though you usually don't derive directly from this class but from one of its more |
207 specific child class. |
207 specific child class. |
208 |
208 |
308 |
308 |
309 So... Some code! That we'll put again in the module ``views`` of our cube. |
309 So... Some code! That we'll put again in the module ``views`` of our cube. |
310 |
310 |
311 .. sourcecode:: python |
311 .. sourcecode:: python |
312 |
312 |
313 from cubicweb.selectors import is_instance |
313 from cubicweb.predicates import is_instance |
314 from cubicweb.web.views import primary |
314 from cubicweb.web.views import primary |
315 |
315 |
316 class CommunityPrimaryView(primary.PrimaryView): |
316 class CommunityPrimaryView(primary.PrimaryView): |
317 __select__ = is_instance('Community') |
317 __select__ = is_instance('Community') |
318 |
318 |