doc/tutorials/advanced/part03_bfss.rst
author Christophe de Vienne <christophe@unlish.com>
Thu, 08 Jan 2015 22:11:06 +0100
changeset 10491 c67bcee93248
parent 10376 doc/book/en/tutorials/advanced/part03_bfss.rst@b566c8081832
child 12209 3a3551fff787
permissions -rw-r--r--
[doc] Restructure the documentation * Create a new index file * Move the sphinx configuration files do the documentation root * Move book/README to dev/documenting.rst * Move book/mode_plan.py to tools/ * Move book/en/images to images * Move book/en/* to book/ * Move changelogs to changes/* * Adapt the Makefile * Add a title to the javascript api index Related to #4832808
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     1
Storing images on the file-system
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     2
---------------------------------
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     3
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     4
Step 1: configuring the BytesFileSystem storage
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     5
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     6
6923
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
     7
To avoid cluttering my database, and to ease file manipulation, I don't want them
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
     8
to be stored in the database. I want to be able create File entities for some
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
     9
files on the server file system, where those file will be accessed to get
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
    10
entities data. To do so I've to set a custom :class:`BytesFileSystemStorage`
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
    11
storage for the File 'data' attribute, which hold the actual file's content.
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    12
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    13
Since the function to register a custom storage needs to have a repository
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    14
instance as first argument, we've to call it in a server startup hook. So I added
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    15
in `cubes/sytweb/hooks.py` :
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    16
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    17
.. sourcecode:: python
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    18
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    19
    from os import makedirs
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    20
    from os.path import join, exists
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    21
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    22
    from cubicweb.server import hook
7145
8dd94fa7310a [doc] fix typo
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 7144
diff changeset
    23
    from cubicweb.server.sources import storages
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    24
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    25
    class ServerStartupHook(hook.Hook):
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    26
        __regid__ = 'sytweb.serverstartup'
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    27
        events = ('server_startup', 'server_maintenance')
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    28
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    29
        def __call__(self):
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    30
            bfssdir = join(self.repo.config.appdatahome, 'bfss')
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    31
            if not exists(bfssdir):
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    32
                makedirs(bfssdir)
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    33
                print 'created', bfssdir
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    34
            storage = storages.BytesFileSystemStorage(bfssdir)
7566
be2fe6fff734 [doc] fix NameError in bfss tutorial
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7145
diff changeset
    35
            storages.set_attribute_storage(self.repo, 'File', 'data', storage)
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    36
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    37
.. Note::
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    38
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    39
  * how we built the hook's registry identifier (`__regid__`): you can introduce
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    40
    'namespaces' by using there python module like naming identifiers. This is
7144
7c9bfd4f4933 [doc] fix typo
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 7082
diff changeset
    41
    especially important for hooks where you usually want a new custom hook, not
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    42
    overriding / specializing an existant one, but the concept may be applied to
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    43
    any application objects
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    44
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    45
  * we catch two events here: "server_startup" and "server_maintenance". The first
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    46
    is called on regular repository startup (eg, as a server), the other for
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    47
    maintenance task such as shell or upgrade. In both cases, we need to have
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    48
    the storage set, else we'll be in trouble...
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    49
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    50
  * the path given to the storage is the place where file added through the ui
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    51
    (or in the database before migration) will be located
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    52
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    53
  * beware that by doing this, you can't anymore write queries that will try to
6923
327443ec7120 [doc] update photo web site tutorial: we're starting from cw 3.10/file 1.9+
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6876
diff changeset
    54
    restrict on File `data` attribute. Hopefuly we don't do that usually
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    55
    on file's content or more generally on attributes for the Bytes type
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    56
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    57
Now, if you've already added some photos through the web ui, you'll have to
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    58
migrate existing data so file's content will be stored on the file-system instead
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    59
of the database. There is a migration command to do so, let's run it in the
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    60
cubicweb shell (in real life, you would have to put it in a migration script as we
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    61
have seen last time):
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    62
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    63
::
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    64
10376
b566c8081832 [doc] the instance is sytweb_instance and sytweb is the cube
Rabah Meradi <rabah.meradi@logilab.fr>
parents: 7566
diff changeset
    65
   $ cubicweb-ctl shell sytweb_instance
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    66
   entering the migration python shell
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    67
   just type migration commands or arbitrary python code and type ENTER to execute it
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    68
   type "exit" or Ctrl-D to quit the shell and resume operation
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    69
   >>> storage_changed('File', 'data')
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    70
   [........................]
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    71
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    72
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    73
That's it. Now, files added through the web ui will have their content stored on
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    74
the file-system, and you'll also be able to import files from the file-system as
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    75
explained in the next part.
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    76
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    77
Step 2: importing some data into the instance
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    78
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    79
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    80
Hey, we start to have some nice features, let us give a try to this new web
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    81
site. For instance if I have a 'photos/201005WePyrenees' containing pictures for
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    82
a particular event, I can import it to my web site by typing ::
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    83
10376
b566c8081832 [doc] the instance is sytweb_instance and sytweb is the cube
Rabah Meradi <rabah.meradi@logilab.fr>
parents: 7566
diff changeset
    84
  $ cubicweb-ctl fsimport -F sytweb_instance photos/201005WePyrenees/
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    85
  ** importing directory /home/syt/photos/201005WePyrenees
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    86
  importing IMG_8314.JPG
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    87
  importing IMG_8274.JPG
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    88
  importing IMG_8286.JPG
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    89
  importing IMG_8308.JPG
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    90
  importing IMG_8304.JPG
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    91
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    92
.. Note::
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    93
  The -F option means that folders should be mapped, hence my photos will be
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    94
  linked to a Folder entity corresponding to the file-system folder.
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    95
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    96
Let's take a look at the web ui:
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    97
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    98
.. image:: ../../images/tutos-photowebsite_ui1.png
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    99
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   100
Nothing different, I can't see the new folder... But remember our security model!
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   101
By default, files are only accessible to authenticated users, and I'm looking at
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   102
the site as anonymous, e.g. not authenticated. If I login, I can now see:
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   103
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   104
.. image:: ../../images/tutos-photowebsite_ui2.png
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   105
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
   106
Yeah, it's there! You will notice that I can see some entities as well as
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   107
folders and images the anonymous user can't. It just works **everywhere in the
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   108
ui** since it's handled at the repository level, thanks to our security model.
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   109
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
   110
Now if I click on the recently inserted folder, I can see
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   111
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   112
.. image:: ../../images/tutos-photowebsite_ui3.png
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   113
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   114
Great! There is even my pictures in the folder. I can know give to this folder a
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   115
nicer name (provided I don't intend to import from it anymore, else already
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   116
imported photos will be reimported), change permissions, title for some pictures,
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   117
etc... Having a good content is much more difficult than having a good web site
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   118
;)
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   119
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   120
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   121
Conclusion
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   122
~~~~~~~~~~
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   123
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   124
We started to see here an advanced feature of our repository: the ability
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   125
to store some parts of our data-model into a custom storage, outside the
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   126
database. There is currently only the :class:`BytesFileSystemStorage` available,
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
   127
but you can expect to see more coming in a near future (or write your own!).
6876
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   128
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   129
Also, we can know start to feed our web-site with some nice pictures!
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   130
The site isn't perfect (far from it actually) but it's usable, and we can
4b0b9d8207c5 [doc] backport part 3 & 4 of the sytweb's tutorial + to be published part 5
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   131
now start using it and improve it on the way. The Incremental Cubic Way :)