doc/tutorials/advanced/part04_ui-base.rst
changeset 12407 d4e0af0b5ad7
parent 12406 57b29c6f8036
child 12408 bef45ece8ce6
equal deleted inserted replaced
12406:57b29c6f8036 12407:d4e0af0b5ad7
   167 attribute on which we want to sort, we'll get linked entities sorted on a common
   167 attribute on which we want to sort, we'll get linked entities sorted on a common
   168 attribute (usually `modification_date`).
   168 attribute (usually `modification_date`).
   169 
   169 
   170 To fix this, we've to help the ORM. We'll do this in the method from the `ITree`
   170 To fix this, we've to help the ORM. We'll do this in the method from the `ITree`
   171 folder's adapter, used in the folder's primary view to display the folder's
   171 folder's adapter, used in the folder's primary view to display the folder's
   172 content. Here's the code, that I've put in our cube's `entities.py` file, since
   172 content. Here's the code, that I've put in our cube's :file:`entities.py` file, since
   173 it's more logical stuff than view stuff:
   173 it's more logical stuff than view stuff:
   174 
   174 
   175 .. sourcecode:: python
   175 .. sourcecode:: python
   176 
   176 
   177     from cubes.folder import entities as folder
   177     from cubes.folder import entities as folder
   209 
   209 
   210 Now the easier parts. Let's start by adding some links on the file's primary view
   210 Now the easier parts. Let's start by adding some links on the file's primary view
   211 to see the previous / next image in the same folder. CubicWeb's provide a
   211 to see the previous / next image in the same folder. CubicWeb's provide a
   212 component that do exactly that. To make it appears, one have to be adaptable to
   212 component that do exactly that. To make it appears, one have to be adaptable to
   213 the `IPrevNext` interface. Here is the related code sample, extracted from our
   213 the `IPrevNext` interface. Here is the related code sample, extracted from our
   214 cube's `views.py` file:
   214 cube's :file:`views.py` file:
   215 
   215 
   216 .. sourcecode:: python
   216 .. sourcecode:: python
   217 
   217 
   218     from cubicweb.predicates import is_instance
   218     from cubicweb.predicates import is_instance
   219     from cubicweb.web.views import navigation
   219     from cubicweb.web.views import navigation
   336    in the two other, it refers to the **instance** (if you can't see the
   336    in the two other, it refers to the **instance** (if you can't see the
   337    difference, reread CubicWeb's concept chapter !).
   337    difference, reread CubicWeb's concept chapter !).
   338 
   338 
   339 
   339 
   340 Once I've checked it's ok, I simply have to bump the version number in the
   340 Once I've checked it's ok, I simply have to bump the version number in the
   341 `__pkginfo__` module to trigger a migration once I'll have updated the code on
   341 :file:`__pkginfo__` module to trigger a migration once I'll have updated the code on
   342 the production site. I can check then check the migration is also going fine, by
   342 the production site. I can check then check the migration is also going fine, by
   343 first restoring a dump from the production site, then upgrading my test instance.
   343 first restoring a dump from the production site, then upgrading my test instance.
   344 
   344 
   345 To generate a dump from the production site: ::
   345 To generate a dump from the production site: ::
   346 
   346 
   347   $ cubicweb-ctl db-dump sytweb
   347   $ cubicweb-ctl db-dump sytweb
   348   pg_dump -Fc --username=syt --no-owner --file /home/syt/etc/cubicweb.d/sytweb/backup/tmpYIN0YI/system sytweb
   348   pg_dump -Fc --username=syt --no-owner --file /home/syt/etc/cubicweb.d/sytweb/backup/tmpYIN0YI/system sytweb
   349   -> backup file /home/syt/etc/cubicweb.d/sytweb/backup/sytweb-2010-07-13_10-22-40.tar.gz
   349   -> backup file /home/syt/etc/cubicweb.d/sytweb/backup/sytweb-2010-07-13_10-22-40.tar.gz
   350 
   350 
   351 I can now get back the dump file ('sytweb-2010-07-13_10-22-40.tar.gz') to my test
   351 I can now get back the dump file (:file:`sytweb-2010-07-13_10-22-40.tar.gz`) to my test
   352 machine (using `scp` for instance) to restore it and start migration: ::
   352 machine (using `scp` for instance) to restore it and start migration: ::
   353 
   353 
   354   $ cubicweb-ctl db-restore sytweb sytweb-2010-07-13_10-22-40.tar.gz
   354   $ cubicweb-ctl db-restore sytweb sytweb-2010-07-13_10-22-40.tar.gz
   355   $ cubicweb-ctl upgrade sytweb
   355   $ cubicweb-ctl upgrade sytweb
   356 
   356