equal
deleted
inserted
replaced
306 interface without trying to benefit from the default implementation (you should |
306 interface without trying to benefit from the default implementation (you should |
307 do that though if you're rewriting reusable cubes; everything is described in more |
307 do that though if you're rewriting reusable cubes; everything is described in more |
308 details in :ref:`primary_view`). |
308 details in :ref:`primary_view`). |
309 |
309 |
310 |
310 |
311 So... Some code! That we'll put again in the module ``views`` of our cube. |
311 So... Some code! That we'll put again in the module ``views`` (``myblog/views.py``) of our cube. |
312 |
312 |
313 .. sourcecode:: python |
313 .. sourcecode:: python |
314 |
314 |
315 from cubicweb.predicates import is_instance |
315 from cubicweb.predicates import is_instance |
316 from cubicweb.web.views import primary |
316 from cubicweb.web.views import primary |
381 - inherits from :class:`cubicweb.entities.AnyEntity` or any subclass |
381 - inherits from :class:`cubicweb.entities.AnyEntity` or any subclass |
382 |
382 |
383 - defines a :attr:`__regid__` linked to the corresponding data type of your schema |
383 - defines a :attr:`__regid__` linked to the corresponding data type of your schema |
384 |
384 |
385 You may then want to add your own methods, override default implementation of some |
385 You may then want to add your own methods, override default implementation of some |
386 method, etc... |
386 method, etc... To do so, write this code in ``myblog/entities.py``: |
387 |
387 |
388 .. sourcecode:: python |
388 .. sourcecode:: python |
389 |
389 |
390 from cubicweb.entities import AnyEntity, fetch_config |
390 from cubicweb.entities import AnyEntity, fetch_config |
391 |
391 |
517 the white frame, and this column is handled by the primary view we |
517 the white frame, and this column is handled by the primary view we |
518 hijacked. Let's change our view to make it more extensible, by keeping both our |
518 hijacked. Let's change our view to make it more extensible, by keeping both our |
519 custom rendering but also extension points provided by the default |
519 custom rendering but also extension points provided by the default |
520 implementation. |
520 implementation. |
521 |
521 |
|
522 In ``myblog/views.py``: |
|
523 |
522 |
524 |
523 .. sourcecode:: python |
525 .. sourcecode:: python |
524 |
526 |
525 class CommunityPrimaryView(primary.PrimaryView): |
527 class CommunityPrimaryView(primary.PrimaryView): |
526 __select__ = is_instance('Community') |
528 __select__ = is_instance('Community') |