<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Building my photos web site with CubicWeb (Part I) (CubicWeb&#39;s Forge) RSS Feed</title>
    <description></description>
    <link>http://www.cubicweb.org/blogentry/824642</link>
<item>
<guid isPermaLink="true">http://www.cubicweb.org/blogentry/824642</guid>
  <title>Building my photos web site with CubicWeb (Part I)</title>
  <link>http://www.cubicweb.org/blogentry/824642</link>
  <description>&lt;div class=&quot;section&quot; id=&quot;desired-features&quot;&gt;
&lt;h3&gt;&lt;a&gt;Desired features&lt;/a&gt;&lt;/h3&gt;
&lt;ul class=&quot;simple&quot;&gt;
&lt;li&gt;photo gallery;&lt;/li&gt;
&lt;li&gt;photo stored onto the fs and displayed through a web interface dynamically;&lt;/li&gt;
&lt;li&gt;navigation through folder (album), tags, geographical zone, people on the
picture... using facets;&lt;/li&gt;
&lt;li&gt;advanced security (eg not everyone can see everything). More on this later.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;let-s-go-then&quot;&gt;
&lt;h3&gt;&lt;a&gt;Let&#39;s go then&lt;/a&gt;&lt;/h3&gt;
&lt;div class=&quot;section&quot; id=&quot;step-1-creating-a-new-cube-for-my-web-site&quot;&gt;
&lt;h4&gt;&lt;a&gt;Step 1: creating a new cube for my web site&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;One note about my development environment: I wanted to use packaged version of
CubicWeb and cubes while keeping my cube in my user directory, let&#39;s say &lt;cite&gt;~src/cubes&lt;/cite&gt;.
It can be done by setting the following environment variables:&lt;/p&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
CW_CUBES_PATH=~/src/cubes
CW_MODE=user
&lt;/pre&gt;
&lt;p&gt;The new cube, holding custom code for this web site, can now be created using:&lt;/p&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
cubicweb-ctl newcube --directory=~/src/cubes sytweb
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;step-2-pick-building-blocks-into-existing-cubes&quot;&gt;
&lt;h4&gt;&lt;a&gt;Step 2: pick building blocks into existing cubes&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Almost everything I want to represent in my web-site is somewhat already modelized in
existing cubes that I&#39;ll extend for my needs:&lt;/p&gt;
&lt;ul class=&quot;simple&quot;&gt;
&lt;li&gt;&lt;cite&gt;folder&lt;/cite&gt;, containing &lt;cite&gt;Folder&lt;/cite&gt; entity type, which will be used as both &#39;album&#39; and
a way to map file system folders. Entities are added to a given folder using the
&lt;cite&gt;filed_under&lt;/cite&gt; relation.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;file&lt;/cite&gt;, containing &lt;cite&gt;File&lt;/cite&gt; and &lt;cite&gt;Image&lt;/cite&gt; entity type, gallery view, and a file system
import utility.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;zone&lt;/cite&gt;, containing the &lt;cite&gt;Zone&lt;/cite&gt; entity type for hierarchical geographical
zones. Entities (including sub-zones) are added to a given zone using the
&lt;cite&gt;situated_in&lt;/cite&gt; relation.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;person&lt;/cite&gt;, containing the &lt;cite&gt;Person&lt;/cite&gt; entity type plus some basic views.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;comment&lt;/cite&gt;, providing a full commenting system allowing one to comment entity types
supporting the &lt;cite&gt;comments&lt;/cite&gt; relation by adding a &lt;cite&gt;Comment&lt;/cite&gt; entity.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;tag&lt;/cite&gt;, providing a full tagging system as an easy and powerful way to classify
entities supporting the &lt;cite&gt;tags&lt;/cite&gt; relation by linking the to &lt;cite&gt;Tag&lt;/cite&gt; entities. This
will allow navigation into a large number of pictures.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ok, now I&#39;ll tell my cube requires all this by editing cubes/sytweb/__pkginfo__.py:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;n&quot;&gt;__depends_cubes__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;file&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;&amp;gt;= 1.2.0&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                     &lt;span class=&quot;s&quot;&gt;&amp;#39;folder&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;&amp;gt;= 1.1.0&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                     &lt;span class=&quot;s&quot;&gt;&amp;#39;person&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;&amp;gt;= 1.2.0&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                     &lt;span class=&quot;s&quot;&gt;&amp;#39;comment&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;&amp;gt;= 1.2.0&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                     &lt;span class=&quot;s&quot;&gt;&amp;#39;tag&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;&amp;gt;= 1.2.0&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                     &lt;span class=&quot;s&quot;&gt;&amp;#39;zone&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                     &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__depends__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;cubicweb&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;&amp;gt;= 3.5.10&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
               &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;__depends_cubes__&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;items&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;__depends__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;cubicweb-&amp;#39;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;__use__&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;tuple&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;__depends_cubes__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Notice that you can express minimal version of the cube that should be used, &lt;cite&gt;None&lt;/cite&gt; meaning whatever version available.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;step-3-glue-everything-together-in-my-cube-s-schema&quot;&gt;
&lt;h4&gt;&lt;a&gt;Step 3: glue everything together in my cube&#39;s schema&lt;/a&gt;&lt;/h4&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;yams.buildobjs&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RelationDefinition&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;comments&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RelationDefinition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;subject&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;Comment&amp;#39;&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;File&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;Image&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;cardinality&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;1*&amp;#39;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;composite&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;object&amp;#39;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;tags&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RelationDefinition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;subject&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;Tag&amp;#39;&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;File&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;Image&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;filed_under&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RelationDefinition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;subject&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;#39;File&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;Image&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;Folder&amp;#39;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;situated_in&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RelationDefinition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;subject&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;Image&amp;#39;&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;Zone&amp;#39;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;displayed_on&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;RelationDefinition&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;subject&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;Person&amp;#39;&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;object&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;#39;Image&amp;#39;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This schema:&lt;/p&gt;
&lt;ul class=&quot;simple&quot;&gt;
&lt;li&gt;allows to comment and tag &lt;cite&gt;File&lt;/cite&gt; and &lt;cite&gt;Image&lt;/cite&gt; entity types by adding the
&lt;cite&gt;comments&lt;/cite&gt; and &lt;cite&gt;tags&lt;/cite&gt; relations. This should be all we have to do for this
feature since the related cubes provide &#39;pluggable section&#39; which are
automatically displayed in the primary view of entity types supporting the
relation.&lt;/li&gt;
&lt;li&gt;adds a &lt;cite&gt;situated_in&lt;/cite&gt; relation definition so that image entities can be
geolocalized.&lt;/li&gt;
&lt;li&gt;add a new relation &lt;cite&gt;displayed_on&lt;/cite&gt; relation telling who can be seen on a
picture.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This schema will probably have to evolve as time goes (for security handling at
least), but since the possibility to change and update the schema evolving
is one of CubicWeb features (and goals), we won&#39;t worry and see that later when needed.&lt;/p&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;step-4-creating-the-instance&quot;&gt;
&lt;h4&gt;&lt;a&gt;Step 4: creating the instance&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Now that I have a schema, I want to create an instance of that new &#39;sytweb&#39;
cube, so I run:&lt;/p&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
cubicweb-ctl create sytweb sytweb_instance
&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;hint&lt;/em&gt;: if you get an error while the database is initialized, you can avoid having to reanswer to questions by running&lt;/p&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
cubicweb-ctl db-create sytweb_instance
&lt;/pre&gt;
&lt;p&gt;This will use your already configured instance and start directly from
the database creation step, thus skipping questions asked by the &#39;create&#39;
command.&lt;/p&gt;
&lt;p&gt;Once the instance and database are fully initialized, run&lt;/p&gt;
&lt;pre class=&quot;literal-block&quot;&gt;
cubicweb-ctl start sytweb_instance
&lt;/pre&gt;
&lt;p&gt;to start the instance, check you can connect on it, etc...&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;section&quot; id=&quot;next-times&quot;&gt;
&lt;h3&gt;&lt;a&gt;Next times&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;We will customize the index page, see security configuration, use the Bytes FileSystem Storage... Lots of cool stuff remaining :)&lt;/p&gt;
&lt;p&gt;&lt;a class=&quot;reference&quot; href=&quot;http://www.cubicweb.org/blogentry/867464&quot;&gt;Next post&lt;/a&gt; : security, testing and migration&lt;/p&gt;
&lt;/div&gt;
</description>
  <dc:date>2010-04-01T08:36-01:00</dc:date>
  <dc:creator>Sylvain Thenault</dc:creator>
</item>
  </channel>
</rss>