doc/tutorials/advanced/part03_bfss.rst
author Denis Laxalde <denis.laxalde@logilab.fr>
Fri, 05 Apr 2019 17:19:56 +0200
branch3.26
changeset 12563 4d6909de765a
parent 12468 3c66259723d9
child 12928 327b11ee0914
permissions -rw-r--r--
[pkg] Version 3.26.9
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
12459
dc793c6ebc48 [doc] always put file name for code example and uses :file:`path` syntax everywhere
Laurent Peuch <cortex@worlddomination.be>
parents: 12209
diff changeset
    15
in :file:`cubicweb_sytweb/hooks.py` :
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
    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
12468
3c66259723d9 [doc] pep8 and retab in tutorial code example
Laurent Peuch <cortex@worlddomination.be>
parents: 12460
diff changeset
    25
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
    26
    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
    27
        __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
    28
        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
    29
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    30
        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
    31
            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
    32
            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
    33
                makedirs(bfssdir)
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    34
                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
    35
            storage = storages.BytesFileSystemStorage(bfssdir)
7566
be2fe6fff734 [doc] fix NameError in bfss tutorial
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7145
diff changeset
    36
            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
    37
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
.. 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
    39
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    40
  * 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
    41
    '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
    42
    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
    43
    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
    44
    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
    45
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
  * 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
    47
    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
    48
    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
    49
    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
    50
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
  * 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
    52
    (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
    53
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    54
  * 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
    55
    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
    56
    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
    57
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
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
    59
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
    60
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
    61
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
    62
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
    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
::
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
    65
10376
b566c8081832 [doc] the instance is sytweb_instance and sytweb is the cube
Rabah Meradi <rabah.meradi@logilab.fr>
parents: 7566
diff changeset
    66
   $ 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
    67
   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
    68
   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
    69
   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
    70
   >>> storage_changed('File', 'data')
12460
0bb15614e756 [doc] command output style has changed
Laurent Peuch <cortex@worlddomination.be>
parents: 12459
diff changeset
    71
   [========================]
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
    72
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
    73
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    74
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
    75
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
    76
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
    77
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
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
    79
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
    80
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    81
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
    82
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
    83
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
    84
10376
b566c8081832 [doc] the instance is sytweb_instance and sytweb is the cube
Rabah Meradi <rabah.meradi@logilab.fr>
parents: 7566
diff changeset
    85
  $ 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
    86
  ** 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
    87
  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
    88
  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
    89
  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
    90
  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
    91
  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
    92
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
    93
.. Note::
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
    94
  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
    95
  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
    96
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
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
    98
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
.. 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
   100
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
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
   102
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
   103
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
   104
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
.. 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
   106
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
   107
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
   108
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
   109
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
   110
7082
1b07eb7180a2 [doc] fix indentation spelling and grammar of tutorials/advanced/part03_bfss
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 6923
diff changeset
   111
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
   112
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
.. 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
   114
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
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
   116
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
   117
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
   118
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
   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
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
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
   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
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
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
   126
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
   127
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
   128
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
   129
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
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
   131
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
   132
now start using it and improve it on the way. The Incremental Cubic Way :)