<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
  <channel>
    <title>Blog entries (CubicWeb's Forge) RSS Feed</title>
    <description />
    <link>http://www.cubicweb.org/project?rql=Any%20X%2CT%2CCD%20ORDERBY%20CD%20DESC%20LIMIT%2020%20WHERE%20X%20is%20BlogEntry%2C%20X%20title%20T%2C%20X%20creation_date%20CD</link>
<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/cubicweborg" /><feedburner:info uri="cubicweborg" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/2356431</guid>
  <title>Thoughts on CubicWeb 4.0</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/TcdinjESViY/2356431</link>
  <description>&lt;div style="max-width:600px;font-size:110%"&gt;&lt;p&gt;This is a fairly technical post talking about the structural changes I would like to see in CubicWeb's near future. Let's call that CubicWeb 4.0! It also drafts ideas on how to go from here to there. Draft, really. But that will eventually turn into a nice roadmap hopefully.&lt;/p&gt;
&lt;div class="section" id="the-great-simplification"&gt;
&lt;h3&gt;&lt;a&gt;The great simplification&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Some parts of cubicweb are sometimes too hairy for different reasons (some good,
most bad). This participates in the difficulty to get started quickly. The goal of CubicWeb 4.0 should be to make things simpler :&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Fix some bad old design.&lt;/li&gt;
&lt;li&gt;Stop reinventing the wheel and use widely used libraries in the Python Web
World. This extends to benefitting from state of the art libraries to build nice
and flexible UI such as Bootstrap, on top of the JQuery foundations (which could
become as prominent as the Python standard library in CubicWeb, the development team should get
ready for it).&lt;/li&gt;
&lt;li&gt;If there is a best way to do something, just do it and refrain from providing configurability and options.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="on-the-road-to-bootstrap"&gt;
&lt;h3&gt;&lt;a&gt;On the road to Bootstrap&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;First, a few simple things could be done to simplify the UI code:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;drop xhtml support: always return text/html content type, stop bothering
with this stillborn stuff and use html5&lt;/li&gt;
&lt;li&gt;move away everything that should not be in the framework: calendar?, embedding,
igeocodable, isioc, massmailing, owl?, rdf?, timeline, timetable?, treeview?,
vcard, wdoc?, xbel, xmlrss?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Then we should probably move the default UI into some cubes (i.e. the content of
cw.web.views and cw.web.data). Besides making the move to Bootstrap easier, this
should also have the benefit of making clearer that this is the default way to
build an (automatic) UI in CubicWeb, but one may use other, more usual,
strategies (such as using a template language).&lt;/p&gt;
&lt;p&gt;At a first glance, we should start with the following core cubes:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;cite&gt;corelayout&lt;/cite&gt;, the default interface layout and generic components. Modules to
backport there: application (not an appobject yet), basetemplates, error,
boxes, basecomponents, facets, ibreadcrumbs, navigation, undohistory.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;coreviews&lt;/cite&gt;, the default generic views and forms. Modules to backport there:
actions, ajaxedit, baseviews, autoform, dotgraphview, editcontroller,
editforms, editviews, forms, formrenderers, primary, json, pyviews, tableview,
reledit, tabs.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;corebackoffice&lt;/cite&gt;, the concrete views for the default back-office that let you
handle users, sources, debugging, etc. through the web. Modules to backport
here: cwuser, debug, bookmark, cwproperties, cwsources, emailaddress,
management, schema, startup, workflow.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;coreservices&lt;/cite&gt;, the various services, not directly related to display of
something. Modules to backport here: ajaxcontroller, apacherewrite,
authentication, basecontrollers, csvexport, idownloadable, magicsearch,
sessions, sparql, sessions, staticcontrollers, urlpublishing, urlrewrite.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is a first draft that will need some adjustements. Some of the listed
modules should be split (e.g. actions, boxes,) and their content moved to
different core cubes. Also some modules in &lt;cite&gt;cubicweb.web&lt;/cite&gt; packages may be moved
to the relevant cube.&lt;/p&gt;
&lt;p&gt;Each cube should provide an interface so that one could replace it with another
one. For instance, move from the default &lt;cite&gt;coreviews&lt;/cite&gt; and &lt;cite&gt;corelayout&lt;/cite&gt; cube to
bootstrap based ones. This should allow a nice migration path from the current UI
to a Bootstrap based UI. Bootstrap should probably be introduced bottom-up: start
using it for tables, lists, etc. then go up until the layout defined in the main
template. The &lt;a class="reference" href="http://orbui.com/"&gt;Orbui&lt;/a&gt; experience should greatly help us by pointing at hot spots
that will have to be tackled, as well as by providing a nice code base from which
we should start.&lt;/p&gt;
&lt;p&gt;Regarding current implementation, we should take care that Contextual components
are a powerful way to build &amp;quot;pluggable&amp;quot; UI, but we should probably add an
intermediate layer that would make more obvious / explicit:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;what the available components are&lt;/li&gt;
&lt;li&gt;what the available slots are&lt;/li&gt;
&lt;li&gt;which component should go in which slot when possible&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Also at some point, we should take care to separate view's logic from HTML
generation: our experience with client works shows that a common need is to use
the logic but produce a different HTML. Though we should wait for more use of
Bootstrap and related HTML simplification to see if the CSS power doesn't
somewhat fulfill that need.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="on-the-road-to-wsgi-and-related"&gt;
&lt;h3&gt;&lt;a&gt;On the road to WSGI and related&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;For the record regarding WSGI:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;a class="reference" href="http://mongrel2.org/"&gt;http://mongrel2.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference" href="http://projects.unbit.it/uwsgi/"&gt;http://projects.unbit.it/uwsgi/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a class="reference" href="http://wiki.nginx.org/NgxWSGIModule"&gt;http://wiki.nginx.org/NgxWSGIModule&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;At some point, the whole &lt;cite&gt;cw.etwist&lt;/cite&gt; package should be dropped in favor of &lt;cite&gt;cw.wsgi&lt;/cite&gt;.&lt;/p&gt;
&lt;div class="section" id="werkzeug"&gt;
&lt;h4&gt;&lt;a&gt;Werkzeug&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;&lt;a class="reference" href="http://werkzeug.pocoo.org/"&gt;http://werkzeug.pocoo.org/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The Werkzeug framework sounds like a good candidate to use as a library that
would replace/simplify the request, httpcache, session, authentication (maybe
more) modules as well as the wsgi package. It sounds like the right candidate for
the following reasons:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;it's a non-intrusive WSGI library, not a web framework,&lt;/li&gt;
&lt;li&gt;it's used by fairly popular frameworks (&lt;a class="reference" href="http://www.openerp.com/community"&gt;openerp&lt;/a&gt;, &lt;a class="reference" href="http://flask.pocoo.org/"&gt;flask&lt;/a&gt;),&lt;/li&gt;
&lt;li&gt;I'm +1 on A. Ronacher idea of a common request implementation for python web
frameworks, let's experiment and promote this idea.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="route-url-handling"&gt;
&lt;h4&gt;&lt;a&gt;Route (URL handling)&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Investigate URL routing modules as a replacement for urlpublishing, urlrewrite and
apacherewrite.&lt;/p&gt;
&lt;p&gt;Candidates are :&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;cite&gt;werkzeug.routing&lt;/cite&gt;, which has noticable pros: celebrated by A. Martelli,
provided by an already-in-wishlist library, URL routing &lt;em&gt;AND&lt;/em&gt; generation.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;routes&lt;/cite&gt; (&lt;a class="reference" href="http://routes.readthedocs.org/en/latest/"&gt;http://routes.readthedocs.org/en/latest/&lt;/a&gt;), pros: used by pylons,
features conditional matching based on domain, cookies, HTTP method... and
sub-domain support.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;selector&lt;/cite&gt; (&lt;a class="reference" href="http://lukearno.com/projects/selector/"&gt;http://lukearno.com/projects/selector/&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I've to say I'm somewhat impatient to find some time to give a try to
&lt;cite&gt;werkzeug.routing&lt;/cite&gt;. IMO, used well, that may introduce a structural change that
would make things much easier to understand and configure properly.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="on-the-road-to-proper-tasks-management"&gt;
&lt;h3&gt;&lt;a&gt;On the road to proper tasks management&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The current looping task / repo thread mecanism is used for various sort of
things and has several problems:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;tasks don't behave similarly in a multi-instances configuration (some should
be executed in a single instance, some in a subset); the tasks system has been
originally written in a single instance context; as of today this is (sometimes)
handled using configuration options (that will have to be properly set in each
instance configuration file);&lt;/li&gt;
&lt;li&gt;tasks is a repository only api but we also need web-side tasks;&lt;/li&gt;
&lt;li&gt;there is probably some abuse of the system that may lead to unnecessary
resources usage.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Analyzing a sample &lt;a class="reference" href="http://www.logilab.org/"&gt;http://www.logilab.org/&lt;/a&gt; instance, below are the running looping
task by categories. Tasks that have to run on each web instance:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;cite&gt;clean_sessions&lt;/cite&gt;, automatically closes unused repository sessions. Notice
&lt;cite&gt;cw.etwist.server&lt;/cite&gt; also records a twisted task to clean web sessions. Some
changes are imminent on this, they will be addressed in the upcoming refactoring session  (that will
become more and more necessary to move on several points listed here).&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;regular_preview_dir_cleanup&lt;/cite&gt; (&lt;cite&gt;preview&lt;/cite&gt; cube), cleanup files in the
preview filesystem directory. Could be executed by a (some of the) web
instance(s) provided that the preview directory is shared.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Tasks that should run on a single instance:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;cite&gt;update_feeds&lt;/cite&gt;, update copy based sources (e.g. datafeed, ldapfeed). Controlled
by 'synchronize' source configuration (persistent source attribute that may be
overridden by instance using &lt;cite&gt;CWSourceHostConfig&lt;/cite&gt; entities)&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;expire_dataimports&lt;/cite&gt;, delete &lt;cite&gt;CWDataImport&lt;/cite&gt; entities older than an amount of
time specified in the 'logs-lifetime' configuration option. &lt;strong&gt;Not controlled
yet&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;cleanup_auth_cookies&lt;/cite&gt; (&lt;em&gt;rememberme&lt;/em&gt; cube), delete &lt;cite&gt;CWAuthCookie&lt;/cite&gt; entities
whose life-time is exhausted. &lt;strong&gt;Not controlled yet&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;cleaning_revocation_key&lt;/cite&gt; (&lt;em&gt;forgotpwd&lt;/em&gt; cube), delete &lt;cite&gt;Fpasswd&lt;/cite&gt; entities with
past &lt;cite&gt;revocation_date&lt;/cite&gt;. &lt;strong&gt;Not controlled yet&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;cleanup_plans&lt;/cite&gt; (&lt;em&gt;narval&lt;/em&gt; cube), delete &lt;cite&gt;Plan&lt;/cite&gt; entities instance older than an
amount of time specified in the configuration. If 'plan-cleanup-delay' is set
to an empty value, the task isn't started.&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;refresh_local_repo_caches&lt;/cite&gt; (&lt;em&gt;vcsfile&lt;/em&gt; cube), pull or clone vcs repositories
cache if the &lt;cite&gt;Repository&lt;/cite&gt; entity ask to import_revision_content (hence web
instance should have up to date cache to display files content) or if
'repository-import' configuration option is set to 'yes'; import vcs repository
content as entities if 'repository-import' configuration option and it is
coming from the system source.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Some deeper thinking is needed here so we can improve things. That includes
thinking about:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;the inter-instances messages bus based on zmq and introduced in 3.15,&lt;/li&gt;
&lt;li&gt;the Celery project (&lt;a class="reference" href="http://celeryproject.org/"&gt;http://celeryproject.org/&lt;/a&gt;), an asynchronous task queue,
widely used and written in Python,&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Remember the more cw independent the tasks are, the better it is. Though we still want an
'all-integrated' approach, e.g. not relying on external configuration of Unix
specific tools such as CRON. Also we should see if a hard-dependency on Celery or
a similar tool could be avoided, and if not if it should be considered as a
problem (for devops).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="on-the-road-to-an-easier-configuration"&gt;
&lt;h3&gt;&lt;a&gt;On the road to an easier configuration&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;First, we should drop the different behaviour according to presence of a '.hg' in
cubicweb's directory. It currently changes the location where cubicweb external
resources (js, css, images, gettext catalogs) are searched for. Speaking of
implementation:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;cite&gt;shared_dir&lt;/cite&gt; returns the &lt;cite&gt;cubicweb.web&lt;/cite&gt; package path instead of the path to the
&lt;cite&gt;shared&lt;/cite&gt; cube,&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;i18n_lib_dir&lt;/cite&gt; returns the &lt;cite&gt;cubicweb/i18n&lt;/cite&gt; directory path instead of the path to the
&lt;cite&gt;shared/i18n&lt;/cite&gt; cube,&lt;/li&gt;
&lt;li&gt;&lt;cite&gt;migration_scripts_dir&lt;/cite&gt; returns the &lt;cite&gt;cubicweb/misc/migration&lt;/cite&gt; directory path
instead of &lt;cite&gt;share/cubicweb/migration&lt;/cite&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Moving web related objects as proposed in the Bootstrap section would resolve the
problem for the content &lt;cite&gt;web/data&lt;/cite&gt; and most of &lt;cite&gt;i18n&lt;/cite&gt; (though some messages
will remain and additional efforts will be needed here). By going further this
way, we may also clean up some schema code by moving &lt;cite&gt;cubicweb/schemas&lt;/cite&gt; and
&lt;cite&gt;cubicweb/misc/migration&lt;/cite&gt; to a cube (though only a small benefit is to be expected
here).&lt;/p&gt;
&lt;p&gt;We should also have fewer environment variables... Let's see what we have today:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;CW_INSTANCES_DIR, where to look for instances configuration&lt;/li&gt;
&lt;li&gt;CW_INSTANCES_DATA_DIR, where to look for instances persistent data files&lt;/li&gt;
&lt;li&gt;CW_RUNTIME_DIR, where to look for instances run-time data files&lt;/li&gt;
&lt;li&gt;CW_MODE, set to 'system' or 'user' will predefine above environment variables differently&lt;/li&gt;
&lt;li&gt;CW_CUBES_PATH, additional directories where to look for cubes&lt;/li&gt;
&lt;li&gt;CW_CUBES_DIR, location of the system 'cubes' directory&lt;/li&gt;
&lt;li&gt;CW_INSTALL_PREFIX, installation prefix, from which we can compute path to 'etc', 'var', 'share', etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I would propose the following changes:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;CW_INSTANCES_DIR is turned into CW_INSTANCES_PATH, and defaults to
~/etc/cubicweb.d if it exists and /etc/cubicweb.d (on Unix platforms) otherwise;&lt;/li&gt;
&lt;li&gt;CW_INSTANCES_DATA_DIR and CW_RUNTIME_DIR are replaced by configuration file
options, with smart values generated at instance creation time;&lt;/li&gt;
&lt;li&gt;the above change should make CW_MODE useless;&lt;/li&gt;
&lt;li&gt;CW_CUBES_DIR is to be dropped, CW_CUBES_PATH should be enough;&lt;/li&gt;
&lt;li&gt;regarding CW_INSTALL_PREFIX, I'm lacking experience with non-hg-or-debian
installations and don't know if this can be avoided or not.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Last but not least (for the moment), the 'web' / 'repo' / 'all-in-one'
configurations, and the fact that the associated configuration file changes
stinks. Ideas to stop doing this:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;one configuration file per instance, with all options provided by installed
parts of the framework used by the application.&lt;/li&gt;
&lt;li&gt;activate 'services' (or not): web server, repository, zmq server, pyro
server. Default services to be started are stored in the configuration file.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There is probably more that can be done here (less configuration options?), but
that would already be a great step forward.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="on-the-road-to"&gt;
&lt;h3&gt;&lt;a&gt;On the road to...&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The following projects should be investigated to see if we could benefit from them:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Paste (&lt;a class="reference" href="http://pythonpaste.org/"&gt;http://pythonpaste.org/&lt;/a&gt;, Configuration and all)&lt;/li&gt;
&lt;li&gt;Beaker (&lt;a class="reference" href="http://beaker.readthedocs.org/en/latest/index.html"&gt;http://beaker.readthedocs.org/en/latest/index.html&lt;/a&gt;, More on Session / cache handling than what will be found in Werkzeug?)&lt;/li&gt;
&lt;li&gt;Pyramid's debug toolbar
(&lt;a class="reference" href="http://docs.pylonsproject.org/projects/pyramid_debugtoolbar/en/latest/"&gt;http://docs.pylonsproject.org/projects/pyramid_debugtoolbar/en/latest/&lt;/a&gt;). See
also &lt;a class="reference" href="http://firelogger.binaryage.com/#python"&gt;http://firelogger.binaryage.com/#python&lt;/a&gt;. Notice Werkzeug comes with an
integrated js console as well.&lt;/li&gt;
&lt;li&gt;zc.buildout (Deployment)&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="discussion"&gt;
&lt;h3&gt;&lt;a&gt;Discussion&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Remember the following goals: migration of legacy code should go smoothly. In a perfect world every application should be able to run with CubicWeb 4.0 until the backwards compatibility code is removed (and CubicWeb 4.0 will probably be released as 4.0 at that time).&lt;/p&gt;
&lt;p&gt;Please provide feedbacks:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;do you think choices proposed above are good/bad choices? Why?&lt;/li&gt;
&lt;li&gt;do you know some additional libraries that should be investigated?&lt;/li&gt;
&lt;li&gt;do you have other changes in mind that could/should be done in cw 4.0?&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;/div&gt;
</description>
  <dc:date>2012-05-21T15:04-01:00</dc:date>
  <dc:creator>Sylvain Thenault</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/2356431</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/2315258</guid>
  <title>Follow up of IRI conference about Museums and the Web #museoweb</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/BUbRAJ-8avw/2315258</link>
  <description>&lt;div style="max-width:600px;font-size:110%"&gt;&lt;p&gt;I attented the conference organised by &lt;a class="reference" href="http://www.iri.centrepompidou.fr/"&gt;IRI&lt;/a&gt; in a series of conferences about &amp;quot;&lt;a class="reference" href="http://www.iri.centrepompidou.fr/evenement/museologie-museographie-et-nouvelles-formes-dadresse-au-public/#tabsSeminaire-6"&gt;Muséologie, muséographie et nouvelles formes d’adresse au public&lt;/a&gt;&amp;quot; (hashtag &lt;a class="reference" href="https://twitter.com/#!/search/%23museoweb"&gt;#museoweb&lt;/a&gt;). This particular occurence was about &amp;quot;Le Web devient audiovisuel&amp;quot; (the web is also audio and video content). Here are a few notes and links we gathered. The event was organised by Alexandre Monnin &lt;a class="reference" href="http://twitter.com/aamonnz"&gt;&amp;#64;aamonnz&lt;/a&gt;.&lt;/p&gt;
&lt;img alt="http://polemictweet.com/2011-2012-museo-audiovisuel/images/slide4_museo_fr.png" src="http://polemictweet.com/2011-2012-museo-audiovisuel/images/slide4_museo_fr.png" /&gt;
&lt;div class="section" id="yves-raimond-from-the-bbc"&gt;
&lt;h3&gt;&lt;a&gt;Yves Raimond from the BBC&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Yves Raimond &lt;a class="reference" href="http://twitter.com/moustaki"&gt;&amp;#64;moustaki&lt;/a&gt; made a presentation about his work at the BBC around semantic web technologies and speech recognition over large quantities of digitized archives. Parts of the BCC web sites use semantic web data as the database and do mashups with external sources of data (musicbrainz, dbpedia, wikipedia). For example Tom Waits has an html web page : &lt;a class="reference" href="http://www.bbc.co.uk/music/artists/c3aeb863-7b26-4388-94e8-5a240f2be21b"&gt;http://www.bbc.co.uk/music/artists/c3aeb863-7b26-4388-94e8-5a240f2be21b&lt;/a&gt; add .rdf at the end of the URL &lt;a class="reference" href="http://www.bbc.co.uk/music/artists/c3aeb863-7b26-4388-94e8-5a240f2be21b.rdf"&gt;http://www.bbc.co.uk/music/artists/c3aeb863-7b26-4388-94e8-5a240f2be21b.rdf&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;He also made an introduction about the &lt;a class="reference" href="http://www.bbc.co.uk/rd/projects/abc_ip.shtml"&gt;ABC-IP The Automatic Broadcast Content Interlinking Project&lt;/a&gt; and the Kiwi-API project that uses &lt;a class="reference" href="http://cmusphinx.sourceforge.net/"&gt;CMU Sphinx&lt;/a&gt; on Amazon Web Services to process large quantities of archives. A screenshot of Kiwi-API is shown on the &lt;a class="reference" href="http://www.bbc.co.uk/blogs/researchanddevelopment/2012/02/prototyping-weeknotes-96.shtml"&gt;BBC R&amp;amp;D blog&lt;/a&gt;. The code should be open sourced soon and should appear on the &lt;a class="reference" href="https://github.com/bbcrd/"&gt;BBC R&amp;amp;D github page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Following his presentation, the question was asked if using Wikipedia content on an institutional web site would be possible in France, I pointed to the use of Wikipedia on &lt;a class="reference" href="http://data.bnf.fr"&gt;http://data.bnf.fr&lt;/a&gt; , for example at the bottom of the &lt;a class="reference" href="http://data.bnf.fr/11907966/victor_hugo/#other-ressources"&gt;Victor Hugo page&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="raphael-troncy-about-media-fragments"&gt;
&lt;h3&gt;&lt;a&gt;Raphaël Troncy about Media Fragments&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Raphaël Troncy &lt;a class="reference" href="http://twitter.com/rtroncy"&gt;&amp;#64;rtroncy&lt;/a&gt; made a presentation about &amp;quot;Media Fragments&amp;quot; which will enable sharing parts of a video on the web. Two major features : the sharing of specific extracts and the optimization of bandwith use when streaming the extract (usefull for mobile devices for example). It is a W3C working draft : &lt;a class="reference" href="http://www.w3.org/TR/media-frags-reqs/"&gt;http://www.w3.org/TR/media-frags-reqs/&lt;/a&gt;. Here are a few links of demos and players :&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Temporal Media Fragment Test Builds &lt;a class="reference" href="http://www.bluishcoder.co.nz/mediafrag/"&gt;http://www.bluishcoder.co.nz/mediafrag/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;NinSuna &lt;a class="reference" href="http://ninsuna.elis.ugent.be/"&gt;http://ninsuna.elis.ugent.be/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;yuma.min.js &lt;a class="reference" href="http://yuma-js.github.com/index.html"&gt;http://yuma-js.github.com/index.html&lt;/a&gt; a javascript framework to annotate videos on the web&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Part of the presentation was about the ACAV project done jointly with Dailymotion : &lt;a class="reference" href="http://www.capdigital.com/projet-acav/"&gt;http://www.capdigital.com/projet-acav/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The slides of his presentation are available here : &lt;a class="reference" href="http://www.slideshare.net/troncy/addressing-and-annotating-multimedia-fragments"&gt;http://www.slideshare.net/troncy/addressing-and-annotating-multimedia-fragments&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="iri-presentation"&gt;
&lt;h3&gt;&lt;a&gt;IRI presentation&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Vincent Puig &lt;a class="reference" href="http://twitter.com/vincentpuig"&gt;&amp;#64;vincentpuig&lt;/a&gt; and Raphaël Velt &lt;a class="reference" href="http://twitter.com/raphv"&gt;&amp;#64;raphv&lt;/a&gt; made a presentation of various projects led by &lt;a class="reference" href="http://www.iri.centrepompidou.fr/"&gt;IRI&lt;/a&gt; :&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;Lignes des temps : &lt;a class="reference" href="http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/"&gt;http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/&lt;/a&gt; (here is an example of a conference about opendata during which I tweeted : &lt;a class="reference" href="http://ldt.iri.centrepompidou.fr/ldtplatform/ldt/front/player/59c0026e-5a4d-11e0-a24f-00145ea49a02/"&gt;RSLN open data&lt;/a&gt; )&lt;/li&gt;
&lt;li&gt;PolemicTweet &lt;a class="reference" href="http://polemictweet.com/"&gt;http://polemictweet.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Bubble-T visualization of tweets about the french presidential elections : &lt;a class="reference" href="http://www.iri.centrepompidou.fr/experimentations/bubble-t/"&gt;http://www.iri.centrepompidou.fr/experimentations/bubble-t/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;HDA Labs &lt;a class="reference" href="http://hdalab.iri-research.org/hdalab/"&gt;http://hdalab.iri-research.org/hdalab/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt="http://www.iri.centrepompidou.fr/wp-content/themes/IRI-Theme/images/logo-iri-petit_fr_fr.png" src="http://www.iri.centrepompidou.fr/wp-content/themes/IRI-Theme/images/logo-iri-petit_fr_fr.png" /&gt;
&lt;/div&gt;
&lt;div class="section" id="final-words"&gt;
&lt;h3&gt;&lt;a&gt;Final words&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The technologies seen during this conference are often related to semantic web technologies or at least web standards. Some of the visualizations are quite impressive and could mean new uses of the Web and an inspiration for &lt;a class="reference" href="http://www.cubicweb.org"&gt;CubicWeb&lt;/a&gt; projects.&lt;/p&gt;
&lt;p&gt;A few of the people present at the conference will be attending or presenting talks at &lt;a class="reference" href="http://www.semweb.pro"&gt;SemWeb.Pro&lt;/a&gt; which will take place in Paris on the 2nd and 3rd of may 2012.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
</description>
  <dc:date>2012-04-12T14:47-01:00</dc:date>
  <dc:creator>Arthur Lutz</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/2315258</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/2223885</guid>
  <title>Undoing changes in CubicWeb</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/FIKRh_cBffc/2223885</link>
  <description>&lt;div style="max-width:600px;font-size:110%"&gt;&lt;p&gt;Many desktop applications offer the possibility for the user to
undo the recent changes : a similar &lt;em&gt;undo feature&lt;/em&gt; has now been
integrated into the CubicWeb framework.&lt;/p&gt;
&lt;p&gt;Because a semantic web application and a common desktop
application are not the same thing at all, especially as far as
undoing is concerned, we will first introduce &lt;em&gt;what&lt;/em&gt; is the &lt;em&gt;undo
feature&lt;/em&gt; for now.&lt;/p&gt;
&lt;div class="section" id="what-s-undoing-in-a-cubicweb-application"&gt;
&lt;h3&gt;&lt;a&gt;What's &lt;em&gt;undoing&lt;/em&gt; in a CubicWeb application&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A CubicWeb application acts upon an &lt;em&gt;Entity-Relationship&lt;/em&gt; model,
described by a schema. This ensures some data integrity
properties. It also implies that changes are made by group called &lt;em&gt;transaction&lt;/em&gt; : so as to insure the data integrity the transaction is completely applied &lt;em&gt;or&lt;/em&gt; none of it is applied.
What may appear as a simple atomic action to a user can actually consist in several actions for the framework. The end-user has no need to know the details of all actions in those transactions. Only the so-called &lt;em&gt;public&lt;/em&gt; actions will appear in the description of the an undoable transaction.&lt;/p&gt;
&lt;p&gt;Lets take a simple example: posting a &amp;quot;comment&amp;quot; for a blog entry will create the entity itself and the link to the blog entry.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="the-undo-feature-for-cubicweb-end-users"&gt;
&lt;h3&gt;&lt;a&gt;The &lt;em&gt;undo feature&lt;/em&gt; for CubicWeb end-users&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;For now there are two ways to access the &lt;em&gt;undo feature&lt;/em&gt; when
it has been activated in the instance configuration file with
the option &lt;em&gt;undo-support=yes&lt;/em&gt;. Immediately after having done something the undo** link appears in the &amp;quot;creation&amp;quot; message.&lt;/p&gt;
&lt;img alt="Screenshot of the undo link in the message" class="align-center" src="/file/2198577?vid=download" /&gt;
&lt;p&gt;Otherwise, one can access at any time the &lt;strong&gt;undo-history view&lt;/strong&gt;
accessible from the start-up page.&lt;/p&gt;
&lt;img alt="Screenshot of the undo link in the message" class="align-center" src="/file/2198579?vid=download" /&gt;
&lt;p&gt;This view shows the transactions, and each provides its own
&lt;strong&gt;undo&lt;/strong&gt; link. Only the transactions the user has permissions to
see and undo will be shown.&lt;/p&gt;
&lt;img alt="Screenshot of the **undo** link in the message" class="align-center" src="/file/2198582?vid=download" /&gt;
&lt;p&gt;If the user attempts to undo a transaction which can't be undone or whose undoing fails, then a message will explain the situation and
no partial undoing will be left behind.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="what-s-next"&gt;
&lt;h3&gt;&lt;a&gt;What's next&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The undo feature is functional but the interface and configuration
options are quite limited. One major, planned, improvement would be enable the user to filter which transactions or actions
he sees in the &lt;em&gt;undo-history view&lt;/em&gt;. Another critical
improvement would be to selectively enable the undo feature on  part of the entity-relationship schema to avoid storing too much
data and reduce the underlying overhead.&lt;/p&gt;
&lt;p&gt;Feedback on this undo feature for specific CubicWeb applications is welcome.
More detailed information regarding the &lt;em&gt;undo feature&lt;/em&gt; will be published in the &lt;a class="reference" href="http://docs.cubicweb.org"&gt;CubicWeb book&lt;/a&gt; when the patches make it through the review process.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
</description>
  <dc:date>2012-02-29T18:06-01:00</dc:date>
  <dc:creator>Anthony Truchet</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/2223885</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/2219569</guid>
  <title>CubicWeb Sprint report for the "ZMQ" team</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/Wc6g5vsfbsw/2219569</link>
  <description>&lt;div style="max-width:600px;font-size:110%"&gt;&lt;p&gt;There has been a growing interest in &lt;a class="reference" href="http://www.zeromq.org/"&gt;ZMQ&lt;/a&gt; in the past months, due to its ability to efficiently deal with message passing, while being light and robust.
We have worked on introducing &lt;a class="reference" href="http://www.zeromq.org/"&gt;ZMQ&lt;/a&gt; in the CubicWeb framework for various uses :&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;As a replacement/alternative to the &lt;a class="reference" href="http://irmen.home.xs4all.nl/pyro3/"&gt;Pyro&lt;/a&gt; source, that is used to connect to distant instances. &lt;a class="reference" href="http://www.zeromq.org/"&gt;ZMQ&lt;/a&gt; may be used as a lighter and more efficient alternative to Pyro. The main idea here is to use the &lt;cite&gt;send_pyobj&lt;/cite&gt;/&lt;cite&gt;recv_pyobj&lt;/cite&gt; API of &lt;a class="reference" href="http://www.zeromq.org/bindings:python"&gt;PyZMQ&lt;/a&gt; (python wrapper of ZMQ) to execute methods on the distant &lt;cite&gt;Repository&lt;/cite&gt; in a totally transparent way for CubicWeb.&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt="http://www.cubicweb.org/file/2219158?vid=download" src="http://www.cubicweb.org/file/2219158?vid=download" /&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;As a JSONServer. Indeed, &lt;a class="reference" href="http://www.zeromq.org/"&gt;ZMQ&lt;/a&gt; could be used to share data between a server and any requests done through &lt;a class="reference" href="http://www.zeromq.org/"&gt;ZMQ&lt;/a&gt;. The request is just a string of &lt;a class="reference" href="http://docs.cubicweb.org/annexes/rql/language.html#rql"&gt;RQL&lt;/a&gt;, and the response is the result set formatted in Json.&lt;/li&gt;
&lt;li&gt;As the building block for a simple notification (publish/subscribe) system between CubicWeb instances.  A component can register its interest in a particular topic, and receive a callback whenever a corresponding message is received.  At this point, this mechanism is used in CubicWeb to notify other instances that they should invalidate their caches when an entity is deleted.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</description>
  <dc:date>2012-02-27T17:54-01:00</dc:date>
  <dc:creator>Julien Cristau</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/2219569</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/2198051</guid>
  <title>CubicWeb Sprint report for the "WSGI" team</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/GwZ8rEUIzI4/2198051</link>
  <description>&lt;div style="max-width:600px;font-size:110%"&gt;&lt;p&gt;Cubicweb has had WSGI support for several years, but this support was incomplete.&lt;/p&gt;
&lt;p&gt;The WSGI team was in charge of turning WSGI support into a full featured backend that could replace &lt;a class="reference" href="http://twistedmatrix.com/trac/"&gt;Twisted&lt;/a&gt; in real production scenarii.&lt;/p&gt;
&lt;p&gt;Because we only had first class support for &lt;a class="reference" href="http://twistedmatrix.com/trac/"&gt;Twisted&lt;/a&gt;, some of the CubicWeb logic related to HTTP handling was implemented on the twisted side with twisted concepts. Our first task was to move this logic in CubicWeb itself. The handling of HTTP status in our response was improved in the process.&lt;/p&gt;
&lt;p&gt;Our second task was to focus on the &amp;quot;non-HTTP&amp;quot; part of CubicWeb (because the repository also manages background tasks). The developement mode for WSGI is now able to handle and run such tasks. For this purpose we have begun a process that aims to remove server related code from the repository object.&lt;/p&gt;
&lt;p&gt;We also Tested several WSGI middleware. One of the most promising  is &lt;a class="reference" href="https://github.com/darwin/firepython"&gt;Firepython&lt;/a&gt;, integrating python logging and debugging feature with &lt;a class="reference" href="https://getfirebug.com/"&gt;Firebug&lt;/a&gt;. &lt;a class="reference" href="http://werkzeug.pocoo.org/docs/debug/#enabling-the-debugger"&gt;werkzeug debugger&lt;/a&gt; seems neat too.&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2194267?vid=download" src="http://www.cubicweb.org/file/2194267?vid=download" /&gt;
&lt;p&gt;All these improvements open the road to a simple and efficient multi-process architecture in CubicWeb.&lt;/p&gt;
&lt;/div&gt;</description>
  <dc:date>2012-02-20T11:10-01:00</dc:date>
  <dc:creator>Pierre-Yves David</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/2198051</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/2194802</guid>
  <title>CubicWeb Sprint report for the "Benchmarks" team</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/U5iIt7Qh9X0/2194802</link>
  <description>&lt;div style="max-width:600px;font-size:110%"&gt;&lt;p&gt;One team during the &lt;a class="reference" href="http://www.cubicweb.org/blogentry/2133886"&gt;CubicWeb sprint&lt;/a&gt; looked at issues around monitoring benchmark values for CubicWeb development. This is a &lt;em&gt;huge&lt;/em&gt; task, so we tried to stay focused on a few aspects:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;production reponse times (using tools such as &lt;a class="reference" href="http://oss.oetiker.ch/smokeping/"&gt;smokeping&lt;/a&gt; and &lt;a class="reference" href="http://munin-monitoring.org/"&gt;munin&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;response times of test executions in continuous integration tests&lt;/li&gt;
&lt;li&gt;response times of test instances runinng in continuous integration&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We looked at using &lt;cite&gt;cpu.clock()&lt;/cite&gt; instead of &lt;cite&gt;cpu.time()&lt;/cite&gt; in the xunit files that report test results so as to be a bit more independent of the load of the machine (but subprocesses won't be counted for).&lt;/p&gt;
&lt;p&gt;Graphing test times in hudson/jenkins already exists (&lt;em&gt;/job/PROJECT/BUILDID/testReport/history/?&lt;/em&gt;) and can also be graphed by TestClass and by individual test. What is missing so far is a specific dashboard were one could select the significant graphs to look at.&lt;/p&gt;
&lt;p&gt;By the end of the first day we had a &amp;quot;lorem ipsum&amp;quot; test instance that is created on the fly on each hudson/jenkins build and a &lt;a class="reference" href="https://jmeter.apache.org/"&gt;jmeter&lt;/a&gt; bench running on it, it's results processed by the &lt;a class="reference" href="https://wiki.jenkins-ci.org/display/JENKINS/Performance+Plugin"&gt;performance plugin&lt;/a&gt;.&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2184036?vid=download" src="http://www.cubicweb.org/file/2184036?vid=download" /&gt;
&lt;p&gt;By the end of the second day we had some visualisation of existing data collected by &lt;a class="reference" href="http://www.cubicweb.org/project/apycot"&gt;apycot&lt;/a&gt; using &lt;a class="reference" href="http://jqplot.com/"&gt;jqplot&lt;/a&gt; javascript visulation (&lt;a class="reference" href="http://www.cubicweb.org/project/cubicweb-jqplot"&gt;cubicweb-jqplot&lt;/a&gt;):&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2184035?vid=download" src="http://www.cubicweb.org/file/2184035?vid=download" /&gt;
&lt;p&gt;By the end of the sprint, we got patches submitted for the following cubes :&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;apycot&lt;/li&gt;
&lt;li&gt;cubicweb-jqplot&lt;/li&gt;
&lt;li&gt;the original jqplot library (&lt;strong&gt;update&lt;/strong&gt; : patch accepted a few days later)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On the last hour of the sprint, since we had a &amp;quot;lorem ipsum&amp;quot; test application running each time the tests went through the continuous integration, we hacked up a proof of concept to get automatic screenshots of this temporary test application. So far, we get screenshots for firefox only, but it opens up possibilities for other browsers. Inspiration could be drawn from &lt;a class="reference" href="https://browsershots.org/"&gt;https://browsershots.org/&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;</description>
  <dc:date>2012-02-17T09:34-01:00</dc:date>
  <dc:creator>Arthur Lutz</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/2194802</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/2154794</guid>
  <title>"Data Fast-food": quick interactive exploratory processing and visualization of complex datasets with CubicWeb</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/PYKoYpa6m84/2154794</link>
  <description>
&lt;div id="localcontent"&gt;&lt;p&gt;With the emergence of the semantic web in the past few years, and the increasing number of high quality open data sets (cf the &lt;a class="reference" href="http://richard.cyganiak.de/2007/10/lod/"&gt;lod diagram&lt;/a&gt;), there is a growing interest in frameworks that allow to store/query/process/mine/visualize large data sets.&lt;/p&gt;
&lt;p&gt;We have seen in previous blog posts how &lt;a class="reference" href="http://www.cubicweb.org/"&gt;CubicWeb&lt;/a&gt; may be used as an efficient knowledge management system for various types of data, and how it may be used to perform complex queries. In this post, we will see, using &lt;a class="reference" href="http://www.geonames.org/"&gt;Geonames&lt;/a&gt; data, how CubicWeb may perform simple or complex data mining and machine learning procedures on data, using the &lt;a class="reference" href="http://www.cubicweb.org/project/cubicweb-datamining"&gt;datamining cube&lt;/a&gt;. This cube adds powerful tools to CubicWeb that make it easy to interactively process and visualize datasets.&lt;/p&gt;
&lt;p&gt;At this point, it is not meant to be used on massive datasets, for it is not fully optimized yet. If you try to perform a &lt;a class="reference" href="https://en.wikipedia.org/wiki/Tf%E2%80%93idf"&gt;TF-IDF (term frequency–inverse document frequency)&lt;/a&gt; with a hierarchical clustering on the full dbpedia abstracts dataset, be prepared to wait. But it is a promising way to enrich the user experience while playing with different datasets, for quick interactive exploratory datamining processing (what I've called the &amp;quot;Data fast-food&amp;quot;).
This cube is based on the &lt;a class="reference" href="http://scikit-learn.org/"&gt;scikit-learn&lt;/a&gt; toolbox that has recently gained a huge popularity in the machine learning and Python community. The release of this cube drastically increases the interest of CubicWeb for data management.&lt;/p&gt;
&lt;div class="section" id="the-datamining-cube"&gt;
&lt;h3&gt;&lt;a&gt;The Datamining cube&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;For a given query, similarly to SQL, CubicWeb returns a &lt;em&gt;result set&lt;/em&gt;. This result set may be presented by a &lt;em&gt;view&lt;/em&gt; to display a table, a map, a graph, etc (see &lt;a class="reference" href="http://docs.cubicweb.org/"&gt;documentation&lt;/a&gt; and previous blog posts).&lt;/p&gt;
&lt;p&gt;The datamining cube introduces the possibility to process the result set before presenting it, for example to apply machine learning algorithms to cluster the data.&lt;/p&gt;
&lt;p&gt;The datamining cube is based on two concepts:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;the concept of &lt;em&gt;processor&lt;/em&gt;: basically, a &lt;em&gt;processor&lt;/em&gt; transforms a &lt;em&gt;result set&lt;/em&gt; in a &lt;em&gt;numpy array&lt;/em&gt;, given some criteria defining the mathematical processing, and the columns/rows of the result set to be taken into account. The &lt;a class="reference" href="http://hal.inria.fr/docs/00/56/40/07/PDF/numpy_final.pdf"&gt;numpy-array&lt;/a&gt; is a polyvalent structure that is widely used for numerical computation. This &lt;em&gt;array&lt;/em&gt; could thus be efficiently used with any kind of datamining algorithms. Note that, in our context of knowledge management, it is more convenient to return a &lt;em&gt;numpy array&lt;/em&gt; with additional meta-information, such as indices or labels, the result being stored in what we call a &lt;em&gt;cw-array&lt;/em&gt;. Meta-information may be useful for display, but is not compulsory.&lt;/li&gt;
&lt;li&gt;the concept of &lt;em&gt;array-view&lt;/em&gt;: the &amp;quot;views&amp;quot; are basic components of &lt;em&gt;CubicWeb&lt;/em&gt;, distinguish querying and displaying the data is key in this framework. So, on a given result set, many different views can be applied. In the &lt;em&gt;datamining&lt;/em&gt; cube, we simply overload the basic &lt;em&gt;view&lt;/em&gt; of CubicWeb, so that it works with &lt;em&gt;cw-array&lt;/em&gt; instead of result sets. These &lt;em&gt;array-views&lt;/em&gt; are associated to some machine learning or datamining processes. For example, one can apply the &lt;a class="reference" href="https://en.wikipedia.org/wiki/K-means_clustering"&gt;k-means&lt;/a&gt; (clustering process) view on a given &lt;em&gt;cw-array&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A very important feature is that the processor and the array-view are called directly through the URL using the two related parameters &lt;em&gt;arid&lt;/em&gt; (for &lt;em&gt;ARray ID&lt;/em&gt;) and &lt;em&gt;vid&lt;/em&gt; (for &lt;em&gt;View ID&lt;/em&gt;, standard in CubicWeb).&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2154793?vid=download" src="http://www.cubicweb.org/file/2154793?vid=download" /&gt;
&lt;/div&gt;
&lt;div class="section" id="processors"&gt;
&lt;h3&gt;&lt;a&gt;Processors&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;We give some examples of basic &lt;em&gt;processors&lt;/em&gt; that may be found in the &lt;em&gt;datamining&lt;/em&gt; cube:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;em&gt;AttributesAsFloatArrayProcessor&lt;/em&gt; (&lt;em&gt;arid='attr-asfloat'&lt;/em&gt;): This processor turns all Int, BigInt and Float attributes in the result set to floats, and returns the corresponding array. The number of rows is equal to the number of rows in the result set, and the number of columns is equal to the number of convertible attributes in the result set.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;EntityAsFloatArrayProcessor&lt;/em&gt; (&lt;em&gt;arid='entity-asfloat'&lt;/em&gt;): This processor performs similarly to the &lt;em&gt;AttributesAsFloatArrayProcessor&lt;/em&gt;, but keeps the reference to the entities used to create the numpy-array. Thus, this information could be used for display (map, label, ...).&lt;/li&gt;
&lt;li&gt;&lt;em&gt;AttributesAsTokenArrayProcessor&lt;/em&gt; (&lt;em&gt;arid='attr-astoken'&lt;/em&gt;): This processor turns all String attributes in the result set in a numpy array, based on a Word-n-gram analyze. This may be used to tokenize a set of strings.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;PivotTableCountArrayProcessor&lt;/em&gt; (&lt;em&gt;arid='pivot-table-count'&lt;/em&gt;): This processor is used to create a &lt;em&gt;pivot&lt;/em&gt; table, with a count function. Other functions, such as &lt;em&gt;sum&lt;/em&gt; or &lt;em&gt;product&lt;/em&gt; also exist. This may be used to create some spreadsheet-like views.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;UndirectedRelationArrayProcessor&lt;/em&gt; (&lt;em&gt;arid='undirected-rel'&lt;/em&gt;): This processor creates a binary numpy array of dimension (nb_entities,  nb_entities), that represents the relations (or corelations) between entities. This may be used for graph-based vizualisation.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We are also planning to extend the concept of processor to sparse matrix (&lt;a class="reference" href="http://docs.scipy.org/doc/scipy/reference/sparse.html"&gt;scipy.sparse&lt;/a&gt;), in order to deal with very high dimensional data.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="array-views"&gt;
&lt;h3&gt;&lt;a&gt;Array Views&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The &lt;em&gt;array views&lt;/em&gt; that are found in the &lt;em&gt;datamining&lt;/em&gt; cube, are, for most of them, used for simple visualization. We used HTML-based templates and the &lt;a class="reference" href="http://www.protovis.org"&gt;Protovis&lt;/a&gt; Javascript Library.&lt;/p&gt;
&lt;p&gt;We will not detail all the views, but rather show some examples. Read the reference documentation for a complete and detailed description.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="examples-on-numerical-data"&gt;
&lt;h3&gt;&lt;a&gt;Examples on numerical data&lt;/a&gt;&lt;/h3&gt;
&lt;div class="section" id="histogram"&gt;
&lt;h4&gt;&lt;a&gt;Histogram&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;The request:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;LO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LA&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;latitude&lt;/span&gt; &lt;span class="n"&gt;LA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;latitude&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;longitude&lt;/span&gt; &lt;span class="n"&gt;LO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;longitude&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;elevation&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ss"&gt;&amp;quot;France&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;that may be translated as:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
All couples (latitude, longitude) of the locations in France, with an elevation not null
&lt;/pre&gt;
&lt;p&gt;and, using &lt;em&gt;vid=protovis-hist&lt;/em&gt; and  &lt;em&gt;arid=attr-asfloat&lt;/em&gt;&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2154795?vid=download" src="http://www.cubicweb.org/file/2154795?vid=download" /&gt;
&lt;/div&gt;
&lt;div class="section" id="scatter-plot"&gt;
&lt;h4&gt;&lt;a&gt;Scatter plot&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Using the notion of &lt;em&gt;view&lt;/em&gt;, we can display differently the same result set, for example using a &lt;em&gt;scatter plot&lt;/em&gt; (&lt;em&gt;vid=protovis-scatterplot&lt;/em&gt;).&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2156233?vid=download" src="http://www.cubicweb.org/file/2156233?vid=download" /&gt;
&lt;p&gt;Another example with the request:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;P&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="k"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;elevation&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;elevation&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;population&lt;/span&gt; &lt;span class="n"&gt;P&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;population&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt; &lt;span class="n"&gt;CO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CO&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ss"&gt;&amp;quot;France&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;that may be translated as:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
All couples (population, elevation) of locations in France,
with a population higher than 10 (inhabitants),and an elevation higher than 1 (meter)
&lt;/pre&gt;
&lt;p&gt;and, using the same &lt;em&gt;vid&lt;/em&gt; (&lt;em&gt;vid=protovis-scatterplot&lt;/em&gt;) and the same &lt;em&gt;arid&lt;/em&gt; (&lt;em&gt;arid=attr-asfloat&lt;/em&gt;)&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2154802?vid=download" src="http://www.cubicweb.org/file/2154802?vid=download" /&gt;
&lt;p&gt;If a third column is given in the result set (and thus in the numpy array), it will be encoded in the size/color of each dot of the scatter plot. For example with the request:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;LO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;latitude&lt;/span&gt; &lt;span class="n"&gt;LA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;latitude&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;longitude&lt;/span&gt; &lt;span class="n"&gt;LO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;longitude&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;elevation&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;elevation&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ss"&gt;&amp;quot;France&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;that may be translated as:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
All tuples (latitude, longitude, elevation) of the locations in France, with an elevation not null
&lt;/pre&gt;
&lt;p&gt;and, using the same &lt;em&gt;vid&lt;/em&gt; (&lt;em&gt;vid=protovis-scatterplot&lt;/em&gt;) and the same &lt;em&gt;arid&lt;/em&gt; (&lt;em&gt;arid=attr-asfloat&lt;/em&gt;), we can visualize the elevation on a map, encoded in size/color&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2154805?vid=download" src="http://www.cubicweb.org/file/2154805?vid=download" /&gt;
&lt;p&gt;Another example with the request:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;LO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LA&lt;/span&gt; &lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;50000&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="k"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;population&lt;/span&gt;  &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;latitude&lt;/span&gt; &lt;span class="n"&gt;LA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;longitude&lt;/span&gt; &lt;span class="n"&gt;LO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt; &lt;span class="n"&gt;CO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CO&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ss"&gt;&amp;quot;France&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;that may be translated as:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
All couples (latitude, longitude) of 50000 locations in France, with a population higher than 100 (inhabitants)
&lt;/pre&gt;
&lt;img alt="http://www.cubicweb.org/file/2156095?vid=download" src="http://www.cubicweb.org/file/2156095?vid=download" /&gt;
&lt;p&gt;There also exist some AreaChart view,  LineArray view, ...&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="examples-on-relational-data"&gt;
&lt;h3&gt;&lt;a&gt;Examples on relational data&lt;/a&gt;&lt;/h3&gt;
&lt;div class="section" id="relational-matrix-undirected-graph"&gt;
&lt;h4&gt;&lt;a&gt;Relational Matrix (undirected graph)&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;The request:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;Y&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;continent&lt;/span&gt; &lt;span class="n"&gt;CO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CO&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ss"&gt;&amp;quot;North America&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;neighbour_of&lt;/span&gt; &lt;span class="n"&gt;Y&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;that may be translated as:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
All neighbour countries in North America
&lt;/pre&gt;
&lt;p&gt;and using the &lt;em&gt;vid='protovis-binarymap'&lt;/em&gt; and &lt;em&gt;arid='undirected-rel'&lt;/em&gt;&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2154796?vid=download" src="http://www.cubicweb.org/file/2154796?vid=download" /&gt;
&lt;/div&gt;
&lt;div class="section" id="relational-matrix-directed-graph"&gt;
&lt;h4&gt;&lt;a&gt;Relational Matrix (directed graph)&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;If we do not want a symmetric matrix, i.e. if we want to keep the direction of a link (X,Y is not the same relation as Y,X), we can use the &lt;em&gt;directed*rel&lt;/em&gt; array processor. For example, with the following request:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;Y&lt;/span&gt; &lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;continent&lt;/span&gt; &lt;span class="n"&gt;Y&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;that may be translated as:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
20 countries and their continent
&lt;/pre&gt;
&lt;p&gt;and using the &lt;em&gt;vid='protovis-binarymap'&lt;/em&gt; and &lt;em&gt;arid='directed-rel'&lt;/em&gt;&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2154797?vid=download" src="http://www.cubicweb.org/file/2154797?vid=download" /&gt;
&lt;/div&gt;
&lt;div class="section" id="force-directed-graph"&gt;
&lt;h4&gt;&lt;a&gt;Force directed graph&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;For a dynamic representation of relations, we can use a force directed graph.
The request:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;Y&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;neighbour_of&lt;/span&gt; &lt;span class="n"&gt;Y&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;that may be translated as:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
All neighbour countries in the World.
&lt;/pre&gt;
&lt;p&gt;and using the &lt;em&gt;vid='protovis-forcedirected'&lt;/em&gt; and &lt;em&gt;arid='undirected-rel'&lt;/em&gt;, we can see the full graph, with small independent components (e.g. UK and Ireland)&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2154800?vid=download" src="http://www.cubicweb.org/file/2154800?vid=download" /&gt;
&lt;p&gt;Again, a third column in the result set could be used to encode some labeling information, for example the continent.&lt;/p&gt;
&lt;p&gt;The request:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;Y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;CO&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;neighbour_of&lt;/span&gt; &lt;span class="n"&gt;Y&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;continent&lt;/span&gt; &lt;span class="n"&gt;CO&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;that may be translated as:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
All neighbour countries in the World, and their corresponding continent.
&lt;/pre&gt;
&lt;p&gt;and again, using the &lt;em&gt;vid='protovis-forcedirected'&lt;/em&gt; and &lt;em&gt;arid='undirected-rel'&lt;/em&gt;, we can see the full graph with the continents encoded in color (Americas in green, Africa in dark blue, ...)&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2154801?vid=download" src="http://www.cubicweb.org/file/2154801?vid=download" /&gt;
&lt;/div&gt;
&lt;div class="section" id="dendrogram"&gt;
&lt;h4&gt;&lt;a&gt;Dendrogram&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;For hierarchical information, one can use the &lt;em&gt;Dendrogram&lt;/em&gt; view. For example, with the request:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;Y&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;continent&lt;/span&gt; &lt;span class="n"&gt;Y&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;that may be translated as:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
All couple (country, continent) in the World
&lt;/pre&gt;
&lt;p&gt;and using &lt;em&gt;vid='protovis-dendrogram'&lt;/em&gt; and &lt;em&gt;arid='directed-rel'&lt;/em&gt;, we have the following dendrogram (we only show a part due to lack of space)&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2154806?vid=download" src="http://www.cubicweb.org/file/2154806?vid=download" /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="unsupervised-learning"&gt;
&lt;h3&gt;&lt;a&gt;Unsupervised Learning&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;We have also developed some &lt;em&gt;machine learning&lt;/em&gt; view for &lt;em&gt;unsupervised learning&lt;/em&gt;. This is more a proof of concept than a fully optimized development, but we can already do some cool stuff. Each machine learning processing is referenced by a &lt;em&gt;mlid&lt;/em&gt;. For example, with the request:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;LO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LA&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="k"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;elevation&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;elevation&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;latitude&lt;/span&gt; &lt;span class="n"&gt;LA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;longitude&lt;/span&gt; &lt;span class="n"&gt;LO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt; &lt;span class="n"&gt;CO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;CO&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ss"&gt;&amp;quot;France&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;that may be translated as:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
All couples (latitude, longitude) of the locations in France, with an elevation higher than 1
&lt;/pre&gt;
&lt;p&gt;and using &lt;em&gt;vid='protovis-scatterplot'&lt;/em&gt; &lt;em&gt;arid='attr-asfloat'&lt;/em&gt; and &lt;em&gt;mlid='kmeans'&lt;/em&gt;, we can construct a scatter plot of all couples of latitude and longitude in France, and create 10 clusters using the &lt;em&gt;kmeans&lt;/em&gt; clustering. The labeling information is thus encoded in color/size:&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2154804?vid=download" src="http://www.cubicweb.org/file/2154804?vid=download" /&gt;
&lt;/div&gt;
&lt;div class="section" id="download"&gt;
&lt;h3&gt;&lt;a&gt;Download&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Finally, we have also implement a download view, based on the Pickle of the numpy-array. It is thus possible to access remotely any data within a Python shell, allowing to process them as you want. Changing the request can be done very easily by changing the &lt;em&gt;rql&lt;/em&gt; parameter in the URL. For example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;pickle&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nn"&gt;urllib&lt;/span&gt;
&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pickle&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;http://mydomain?rql=my request&amp;amp;vid=array-numpy&amp;amp;arid=attr-asfloat&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;
</description>
  <dc:date>2012-01-23T13:30-01:00</dc:date>
  <dc:creator>Vincent Michel</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/2154794</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/2133886</guid>
  <title>CubicWeb sprint in Paris - 2012/02/07-10</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/w2sqndac0U4/2133886</link>
  <description>&lt;div class="section" id="topics"&gt;
&lt;h3&gt;&lt;a&gt;Topics&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;To be decided. Some possible topics are :&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;optimization (still)&lt;/li&gt;
&lt;li&gt;porting cubicweb to python3&lt;/li&gt;
&lt;li&gt;porting cubicweb to pypy&lt;/li&gt;
&lt;li&gt;persistent sessions&lt;/li&gt;
&lt;li&gt;finish twisted / wsgi refactoring&lt;/li&gt;
&lt;li&gt;inter-instance communication bus&lt;/li&gt;
&lt;li&gt;use subprocesses to handle datafeeds&lt;/li&gt;
&lt;li&gt;developing more debug-tools (debug console, view profiling, etc.)&lt;/li&gt;
&lt;li&gt;pluggable / unpluggable external sources (as needed for the cubipedia and semantic family)&lt;/li&gt;
&lt;li&gt;client-side only applications (javascript + http)&lt;/li&gt;
&lt;li&gt;mercurial storage backend: see &lt;a class="reference" href="http://lists.cubicweb.org/pipermail/cubicweb/2011-October/000865.html"&gt;this thread&lt;/a&gt; of the mailing list&lt;/li&gt;
&lt;li&gt;mercurial-server integration: see &lt;a class="reference" href="http://lists.cubicweb.org/pipermail/cubicweb/2011-October/000866.html"&gt;this email&lt;/a&gt; to the mailing list&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;other ideas are welcome&lt;/strong&gt;, please bring them up on &lt;a class="reference" href="mailto:cubicweb&amp;#64;lists.cubicweb.org"&gt;cubicweb&amp;#64;lists.cubicweb.org&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="location"&gt;
&lt;h3&gt;&lt;a&gt;Location&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This sprint will take place from in february 2012 from tuesday the 7th to friday the 10th. You are more than welcome to come along, help out and contribute. An introduction is planned for newcomers.&lt;/p&gt;
&lt;p&gt;Network resources will be available for those bringing laptops.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Address&lt;/strong&gt; : 104 Boulevard Auguste-Blanqui, Paris. Ring &amp;quot;Logilab&amp;quot; (&lt;a class="reference" href="http://maps.google.fr/maps?f=q&amp;amp;source=s_q&amp;amp;hl=fr&amp;amp;geocode=&amp;amp;q=104+boulevard+blanqui,+paris&amp;amp;aq=&amp;amp;sll=46.75984,1.738281&amp;amp;sspn=9.726294,22.214355&amp;amp;ie=UTF8&amp;amp;hq=&amp;amp;hnear=104+Boulevard+Auguste+Blanqui,+75013+Paris,+Ile-de-France&amp;amp;z=16"&gt;googlemap&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Metro&lt;/strong&gt; : Glacière&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Contact&lt;/strong&gt; : &lt;a class="reference" href="http://www.logilab.fr/contact"&gt;http://www.logilab.fr/contact&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Dates&lt;/strong&gt; : 07/02/2012 to 10/02/2012&lt;/p&gt;
&lt;/div&gt;
</description>
  <dc:date>2011-12-21T15:50-01:00</dc:date>
  <dc:creator>Nicolas Chauvat</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/2133886</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/2124634</guid>
  <title>Geonames in CubicWeb !</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/mZadlztMB1A/2124634</link>
  <description>
&lt;div id="localcontent"&gt;&lt;p&gt;&lt;a class="reference" href="http://www.cubicweb.org/"&gt;CubicWeb&lt;/a&gt; is a semantic web framework written in Python that has been succesfully used in  large-scale projects, such as  &lt;a class="reference" href="http://data.bnf.fr"&gt;data.bnf.fr&lt;/a&gt; (French National Library's opendata) or  &lt;a class="reference" href="http://collections.musees-haute-normandie.fr/collections/"&gt;Collections des musées de Haute-Normandie&lt;/a&gt; (museums of Haute-Normandie).&lt;/p&gt;
&lt;p&gt;&lt;em&gt;CubicWeb&lt;/em&gt; provides a high-level query language, called &lt;a class="reference" href="http://docs.cubicweb.org/annexes/rql/index.html"&gt;RQL&lt;/a&gt;, operating over a relational database (PostgreSQL in our case), and allows to quickly instantiate an &lt;em&gt;entity-relationship data-model&lt;/em&gt;. By separating in two distinct steps the query and the display of data, it provides powerful means for data retrieval and processing.&lt;/p&gt;
&lt;p&gt;In this blog, we will demonstrate some of these capabilities on the &lt;a class="reference" href="http://www.geonames.org/"&gt;Geonames&lt;/a&gt; data.&lt;/p&gt;
&lt;div class="section" id="id2"&gt;
&lt;h3&gt;&lt;a&gt;Geonames&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;Geonames&lt;/em&gt; is an open-source compilation of geographical data from various sources:&lt;/p&gt;
&lt;blockquote&gt;
&amp;quot;...The GeoNames geographical database covers all countries and contains over eight million placenames that are available for download free of charge...&amp;quot; (&lt;a class="reference" href="http://www.geonames.org"&gt;http://www.geonames.org&lt;/a&gt;)&lt;/blockquote&gt;
&lt;p&gt;The data is available as a &lt;a class="reference" href="http://download.geonames.org/export/dump/"&gt;dump&lt;/a&gt; containing different CSV files:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;em&gt;allCountries&lt;/em&gt;: main file containing information about 8,000,000 places in the world. We won't detail the various attributes of each location, but we will focus on some important properties, such as &lt;em&gt;population&lt;/em&gt; and &lt;em&gt;elevation&lt;/em&gt;. Moreover, &lt;em&gt;admin_code_1&lt;/em&gt; and &lt;em&gt;admin_code_2&lt;/em&gt; will be used to link the different locations to the corresponding &lt;em&gt;AdministrativeRegion&lt;/em&gt;, and &lt;em&gt;feature_code&lt;/em&gt; will be used to link the data to the corresponding type.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;admin1CodesASCII.txt&lt;/em&gt; and &lt;em&gt;admin2Codes.txt&lt;/em&gt; detail the different &lt;em&gt;administrative regions&lt;/em&gt;, that are parts of the world such as region (&lt;em&gt;Ile-de-France&lt;/em&gt;), department (&lt;em&gt;Department of Yvelines&lt;/em&gt;), US counties...&lt;/li&gt;
&lt;li&gt;&lt;em&gt;featureCodes.txt&lt;/em&gt; details the different types of location that may be found in the data, such as &lt;em&gt;forest(s)&lt;/em&gt;, &lt;em&gt;first-order administrative division&lt;/em&gt;, &lt;em&gt;aqueduct&lt;/em&gt;, &lt;em&gt;research institute&lt;/em&gt;, ...&lt;/li&gt;
&lt;li&gt;&lt;em&gt;timeZones.txt&lt;/em&gt;, &lt;em&gt;countryInfo.txt&lt;/em&gt;, &lt;em&gt;iso-languagecodes.txt&lt;/em&gt; are additional files prodividing information about timezones, countries and languages. They will be included in our CubicWeb database but won't be explained in more details here.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The Geonames website also provides some ways to browse the data: by &lt;em&gt;Countries&lt;/em&gt;, by &lt;em&gt;Largest Cities&lt;/em&gt;, by &lt;em&gt;Highest mountains&lt;/em&gt;, by &lt;em&gt;postal codes&lt;/em&gt;, etc. We will see that CubicWeb could be used to automatically create such ways of browsing data while allowing far deeper queries.
There are two main challenges when dealing with such data:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;the number of entries: with 8,000,000 placenames, we have to use efficient tools for storing and querying them.&lt;/li&gt;
&lt;li&gt;the structure of the data: the different types of entries are separated in different files, but should be merged for efficient queries (&lt;em&gt;i.e.&lt;/em&gt; we have to rebuild the different links between entities, &lt;em&gt;e.g&lt;/em&gt; &lt;em&gt;Location&lt;/em&gt; to &lt;em&gt;Country&lt;/em&gt; or &lt;em&gt;Location&lt;/em&gt; to &lt;em&gt;AdministrativeRegion&lt;/em&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="section" id="data-model"&gt;
&lt;h4&gt;&lt;a&gt;Data model&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;With CubicWeb, the data model of the application is written in Python. It defines different &lt;em&gt;entity classes&lt;/em&gt; with their attributes, as well as the relationships between the different entity classes. Here is a sample of the schema.py that we have used for Geonames data:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EntityType&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;maxsize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indexed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;uri&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;unique&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;indexed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;geonameid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;indexed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;latitude&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;indexed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;longitude&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;indexed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;feature_code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SubjectRelation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;FeatureCode&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cardinality&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;?*&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;inlined&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;country&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SubjectRelation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Country&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cardinality&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;?*&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;inlined&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;main_administrative_region&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SubjectRelation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;AdministrativeRegion&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                              &lt;span class="n"&gt;cardinality&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;?*&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;inlined&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;timezone&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SubjectRelation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;TimeZone&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cardinality&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;?*&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;inlined&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;...&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This indicates that the main &lt;em&gt;Location&lt;/em&gt; class has a &lt;em&gt;name&lt;/em&gt; attribute (string), an &lt;em&gt;uri&lt;/em&gt; (string), a &lt;em&gt;geonameid&lt;/em&gt; (integer), a &lt;em&gt;latitude&lt;/em&gt; and a &lt;em&gt;longitude&lt;/em&gt; (both floats), and some relation to other entity classes such as &lt;em&gt;FeatureCode&lt;/em&gt; (the relation is named &lt;em&gt;feature_code&lt;/em&gt;), &lt;em&gt;Country&lt;/em&gt; (the relation is named &lt;em&gt;country&lt;/em&gt;), or &lt;em&gt;AdministrativeRegion&lt;/em&gt; called &lt;em&gt;main_administrative_region&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The cardinality of each relation is classically defined in a similar way as RDBMS, where &lt;em&gt;*&lt;/em&gt; means &lt;em&gt;any number&lt;/em&gt;, &lt;em&gt;?&lt;/em&gt; means &lt;em&gt;zero or one&lt;/em&gt; and &lt;em&gt;1&lt;/em&gt; means &lt;em&gt;one and only one&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;We give below a visualisation of the schema (obtained using the &lt;tt class="docutils literal"&gt;/schema&lt;/tt&gt; relative url)&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2124618?vid=download" src="http://www.cubicweb.org/file/2124618?vid=download" /&gt;
&lt;/div&gt;
&lt;div class="section" id="import"&gt;
&lt;h4&gt;&lt;a&gt;Import&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;The data contained in the CSV files could be pushed and stored without any processing, but it is interesting to reconstruct the relations that may exist between different entities and entity classes, so that queries will be easier and faster.&lt;/p&gt;
&lt;p&gt;Executing the import procedure took us 80 minutes on regular hardware, which seems very reasonable given the amount of data (~7,000,000 entities, 920MB for the &lt;em&gt;allCountries.txt&lt;/em&gt; file), and the fact that we are also constructing many indexes (on attributes or on relations) to improve the queries. This import procedure uses some low-level &lt;em&gt;SQL&lt;/em&gt; commands to load the data into the underlying relational database.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="queries-and-views"&gt;
&lt;h4&gt;&lt;a&gt;Queries and views&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;As stated before, queries are performed in CubicWeb using &lt;em&gt;RQL (Relational Query Language)&lt;/em&gt;, which is similar to &lt;em&gt;SPARQL&lt;/em&gt;, but with a syntax that is closer to &lt;em&gt;SQL&lt;/em&gt;. This language may be used to query directly the &lt;em&gt;concepts&lt;/em&gt; while abstracting the &lt;em&gt;physical structure&lt;/em&gt; of the underlying database. For example, one can use the following request:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="k"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;population&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ss"&gt;&amp;quot;France&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;that means:&lt;/p&gt;
&lt;blockquote&gt;
Give me 10 locations that have a population greater than 1000000, and that are in a country named &amp;quot;France&amp;quot;&lt;/blockquote&gt;
&lt;p&gt;The corresponding &lt;em&gt;SQL&lt;/em&gt; query is:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;_X&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cw_eid&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;cw_Country&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;_C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cw_Location&lt;/span&gt; &lt;span class="k"&gt;AS&lt;/span&gt; &lt;span class="n"&gt;_X&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;_X&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cw_population&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="mi"&gt;1000000&lt;/span&gt;
      &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;_X&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cw_country&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;_C&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cw_eid&lt;/span&gt; &lt;span class="k"&gt;AND&lt;/span&gt; &lt;span class="n"&gt;_C&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cw_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="ss"&gt;&amp;quot;France&amp;quot;&lt;/span&gt;
&lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We can see that &lt;em&gt;RQL&lt;/em&gt; is higher-level than &lt;em&gt;SQL&lt;/em&gt; and abstracts the details of the tables and the joins.&lt;/p&gt;
&lt;p&gt;A query returns a &lt;em&gt;result set&lt;/em&gt; (a list of results), that can be displayed using &lt;em&gt;views&lt;/em&gt;. A main feature of CubicWeb is to separate the two steps of &lt;em&gt;querying the data&lt;/em&gt; and &lt;em&gt;displaying the results&lt;/em&gt;. One can query some data and visualize the results in the standard &lt;em&gt;web framework&lt;/em&gt;, &lt;em&gt;download them in different formats (JSON, RDF, CSV,...)&lt;/em&gt;, or display them in some specific view developed in Python.&lt;/p&gt;
&lt;p&gt;In particular, we will use the &lt;em&gt;mapstraction.map&lt;/em&gt; which is based on the Mapstraction and the OpenLayers libraries to display information on maps using data from OpenStreetMap. This mapstraction.map &lt;em&gt;view&lt;/em&gt; uses a feature of &lt;em&gt;CubicWeb&lt;/em&gt; called &lt;em&gt;adapter&lt;/em&gt;. An &lt;em&gt;adapter&lt;/em&gt; adapts a class of entity to some interface, hence views can rely on interfaces instead of types and be able to display entities with different attributes and relations. In our case, the &lt;em&gt;IGeocodableAdapter&lt;/em&gt; returns a &lt;em&gt;latitude&lt;/em&gt; and a &lt;em&gt;longitude&lt;/em&gt; for a given class of entity (here, the mapping is trivial, but there are more complex cases... :) ):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;IGeocodableAdapter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EntityAdapter&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
      &lt;span class="n"&gt;__regid__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;IGeocodable&amp;#39;&lt;/span&gt;
      &lt;span class="n"&gt;__select__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;is_instance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Location&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="nd"&gt;@property&lt;/span&gt;
      &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;latitude&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;entity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;latitude&lt;/span&gt;
      &lt;span class="nd"&gt;@property&lt;/span&gt;
      &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;longitude&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;entity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;longitude&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We will give some results of queries and views later. It is important to notice that the following screenshoots are taken without any modification of the standard web interface of CubicWeb. It is possible to write specific &lt;em&gt;views&lt;/em&gt; and to define a specific &lt;em&gt;CSS&lt;/em&gt;, but we only wanted to show how CubicWeb could handle such data. However, the default web template of CubicWeb is sufficient for what we want to do, as it dynamically creates web pages showing attributes and relations, as well as some specific forms and javascript applets adapted directly to the data (&lt;em&gt;e.g.&lt;/em&gt; map-based tools).
Last but not least, the query and the view could be defined within the url, and thus open a world of new possibilities to the user:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
http://baseurl:port/?rql=The query that I want&amp;amp;vid=Identifier-of-the-view
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="section" id="facets"&gt;
&lt;h4&gt;&lt;a&gt;Facets&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;We will not get into too much details about &lt;em&gt;Facets&lt;/em&gt;, but let's just say that this feature may be used to determine some &lt;em&gt;filtering axis&lt;/em&gt; on the data, and thus may be used to post-filter a result set. In this example, we have defined four different facets: on the &lt;em&gt;population&lt;/em&gt;, on the &lt;em&gt;elevation&lt;/em&gt;, one the &lt;em&gt;feature_code&lt;/em&gt; and one the &lt;em&gt;main_administrative_region&lt;/em&gt;. We will see illustration of these facets below.&lt;/p&gt;
&lt;p&gt;We give here an example of the definition of a &lt;em&gt;Facet&lt;/em&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LocationPopulationFacet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;facet&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RangeFacet&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;__regid__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;population-facet&amp;#39;&lt;/span&gt;
    &lt;span class="n"&gt;__select__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;is_instance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Location&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
    &lt;span class="n"&gt;rtype&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;population&amp;#39;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;where &lt;em&gt;__select__&lt;/em&gt; defines which class(es) of entities are targeted by this facet, &lt;em&gt;order&lt;/em&gt; defines the order of display of the different facets, and &lt;em&gt;rtype&lt;/em&gt; defines the target attribute/relation that will be used for filtering.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="geonames-in-cubicweb"&gt;
&lt;h3&gt;&lt;a&gt;Geonames in CubicWeb&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The main page of the Geoname application is illustrated in the screenshot below. It provides general information on the database, in particular the number of entities in the different classes:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;7,984,330 locations.&lt;/li&gt;
&lt;li&gt;59,201 administrative regions (&lt;em&gt;e.g.&lt;/em&gt; regions, counties, departments...)&lt;/li&gt;
&lt;li&gt;7,766 languages.&lt;/li&gt;
&lt;li&gt;656 features (&lt;em&gt;e.g.&lt;/em&gt; types of location).&lt;/li&gt;
&lt;li&gt;410 time zones.&lt;/li&gt;
&lt;li&gt;252 countries.&lt;/li&gt;
&lt;li&gt;7 continents.&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt="http://www.cubicweb.org/file/2124617?vid=download" src="http://www.cubicweb.org/file/2124617?vid=download" /&gt;
&lt;div class="section" id="simple-query"&gt;
&lt;h4&gt;&lt;a&gt;Simple query&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;We will first illustrate the possibilites of &lt;em&gt;CubicWeb&lt;/em&gt; with the simple query that we have detailed before (that could be directly pasted in the url...):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="k"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;population&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ss"&gt;&amp;quot;France&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We obtain the following page:&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2124615?vid=download" src="http://www.cubicweb.org/file/2124615?vid=download" /&gt;
&lt;p&gt;This is the &lt;em&gt;standard view&lt;/em&gt; of &lt;em&gt;CubicWeb&lt;/em&gt; for displaying results. We can see (right box) that we obtain 10 locations that are indeed located in France, with a population of more than 1,000,000 inhabitants. The left box shows the &lt;em&gt;search panel&lt;/em&gt; that could be used to launch queries, and the &lt;em&gt;facet filters&lt;/em&gt; that may be used for filtering results, &lt;em&gt;e.g.&lt;/em&gt; we may ask to keep only results with a population greater than 4,767,709 inhabitants &lt;strong&gt;within&lt;/strong&gt; the previous results:&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2124616?vid=download" src="http://www.cubicweb.org/file/2124616?vid=download" /&gt;
&lt;p&gt;and we obtain now only 4 results. We can also notice that the &lt;em&gt;facets&lt;/em&gt; are linked: by restricting the result set using the &lt;em&gt;population facet&lt;/em&gt;, the other facets also restricted their possibilities.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="simple-query-but-with-more-information"&gt;
&lt;h4&gt;&lt;a&gt;Simple query (but with more information !)&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Let's say that we now want more information about the results that we have obtained previously (for example the exact population, the elevation and the name). This is really simple ! We just have to ask &lt;em&gt;within the RQL query&lt;/em&gt; what we want (of course, the names N, P, E of the variables could be almost anything...):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;P&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt; &lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="k"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;population&lt;/span&gt; &lt;span class="n"&gt;P&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;population&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;elevation&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ss"&gt;&amp;quot;France&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;img alt="http://www.cubicweb.org/file/2124619?vid=download" src="http://www.cubicweb.org/file/2124619?vid=download" /&gt;
&lt;p&gt;The empty column for the elevation simply means that we don't have any information about elevation.&lt;/p&gt;
&lt;p&gt;Anyway, we can see that fetching particular information could not be simpler! Indeed, with more complex queries, we can access countless information from the Geonames database:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;E&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;LA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;LO&lt;/span&gt; &lt;span class="n"&gt;ORDERBY&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt; &lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;  &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="k"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;latitude&lt;/span&gt; &lt;span class="n"&gt;LA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;longitude&lt;/span&gt; &lt;span class="n"&gt;LO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;elevation&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;elevation&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ss"&gt;&amp;quot;France&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;which means:&lt;/p&gt;
&lt;blockquote&gt;
Give me the 10 highest locations (the 10 first when sorting by decreasing elevation) with their name, elevation, latitude and longitude that are in a country named &amp;quot;France&amp;quot;&lt;/blockquote&gt;
&lt;img alt="http://www.cubicweb.org/file/2124626?vid=download" src="http://www.cubicweb.org/file/2124626?vid=download" /&gt;
&lt;p&gt;We can now use &lt;em&gt;another view&lt;/em&gt; on the &lt;em&gt;same request&lt;/em&gt;, &lt;em&gt;e.g.&lt;/em&gt; on a map (view &lt;em&gt;mapstraction.map&lt;/em&gt;):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;ORDERBY&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt; &lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;  &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="k"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;latitude&lt;/span&gt; &lt;span class="n"&gt;LA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;longitude&lt;/span&gt; &lt;span class="n"&gt;LO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;elevation&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;elevation&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ss"&gt;&amp;quot;France&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;img alt="http://www.cubicweb.org/file/2124631?vid=download" src="http://www.cubicweb.org/file/2124631?vid=download" /&gt;
&lt;p&gt;And now, we can add the fact that we want more results (20), and that the location should have a non-null population:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;Any&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;P&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LO&lt;/span&gt; &lt;span class="n"&gt;ORDERBY&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt; &lt;span class="k"&gt;DESC&lt;/span&gt; &lt;span class="k"&gt;LIMIT&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;  &lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="k"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;latitude&lt;/span&gt; &lt;span class="n"&gt;LA&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;longitude&lt;/span&gt; &lt;span class="n"&gt;LO&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;elevation&lt;/span&gt; &lt;span class="n"&gt;E&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;NOT&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;elevation&lt;/span&gt; &lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;population&lt;/span&gt; &lt;span class="n"&gt;P&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;population&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;X&lt;/span&gt; &lt;span class="n"&gt;country&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;C&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ss"&gt;&amp;quot;France&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;img alt="http://www.cubicweb.org/file/2124632?vid=download" src="http://www.cubicweb.org/file/2124632?vid=download" /&gt;
&lt;p&gt;... and on a map ...&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2124633?vid=download" src="http://www.cubicweb.org/file/2124633?vid=download" /&gt;
&lt;/div&gt;
&lt;div class="section" id="conclusion"&gt;
&lt;h4&gt;&lt;a&gt;Conclusion&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;In this blog, we have seen how CubicWeb could be used to store and query complex data, while providing (among other...) Web-based views for data vizualisation. It allows the user to directly query data within the URL and may be used to interact with and explore the data in depth. In a next blog, we will give more complex queries to show the full possibilities of the system.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
</description>
  <dc:date>2011-12-23T15:33-01:00</dc:date>
  <dc:creator>Vincent Michel</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/2124634</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/2116712</guid>
  <title>Importing thousands of entities into CubicWeb within a few seconds with dataimport</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/Ct8sKe6Dt-U/2116712</link>
  <description>
&lt;div id="localcontent"&gt;&lt;p&gt;In most cubicweb projects I've been developing on, there always comes a time where
I need to import legacy data in the new application. CubicWeb provides &lt;tt class="docutils literal"&gt;Store&lt;/tt&gt;
and &lt;tt class="docutils literal"&gt;Controller&lt;/tt&gt; objects in the &lt;a class="reference" href="http://hg.logilab.org/cubicweb/file/default/dataimport.py"&gt;dataimport&lt;/a&gt; module. I won't talk here about the
recommended general procedure described in the module's docstring (I find it a bit
convoluted for simple cases) but I will focus on &lt;tt class="docutils literal"&gt;Store&lt;/tt&gt; objects. &lt;tt class="docutils literal"&gt;Store&lt;/tt&gt;
objects in this module are more or less a thin layer around &lt;tt class="docutils literal"&gt;session&lt;/tt&gt; objects,
they provide high-level helpers such as &lt;tt class="docutils literal"&gt;create_entity()&lt;/tt&gt;, &lt;tt class="docutils literal"&gt;relate()&lt;/tt&gt;
and keep track of what was inserted, errors occurred, etc.&lt;/p&gt;
&lt;p&gt;In a recent project, I had to create a somewhat fair amount (a few million)
of simple entities (strings, integers, floats and dates) and relations. Default
object store (i.e. &lt;tt class="docutils literal"&gt;cubicweb.dataimport.RQLObjectStore&lt;/tt&gt;) is painfully slow,
the reason being all integrity / security / metadata hooks that are constantly
selected and executed. For large imports, &lt;a class="reference" href="http://hg.logilab.org/cubicweb/file/default/dataimport.py"&gt;dataimport&lt;/a&gt; also provides the
&lt;tt class="docutils literal"&gt;cubicweb.dataimport.NoHookRQLObjectStore&lt;/tt&gt;. This store bypasses all hooks
and uses the underlying system source primitives directly, making it around
two-times faster than the standard store. The problem is that we're still
doing each sql query sequentially and we're talking here of millions of
&lt;tt class="docutils literal"&gt;INSERT&lt;/tt&gt; / &lt;tt class="docutils literal"&gt;UPDATE&lt;/tt&gt; queries.&lt;/p&gt;
&lt;p&gt;My idea was to create my own &lt;tt class="docutils literal"&gt;ObjectStore&lt;/tt&gt; class inheriting from &lt;tt class="docutils literal"&gt;NoHookRQLObjectStore&lt;/tt&gt;
that would try to use &lt;tt class="docutils literal"&gt;executemany&lt;/tt&gt; or even &lt;tt class="docutils literal"&gt;copy_from&lt;/tt&gt; when possible &lt;a class="footnote-reference" href="#id3" id="id1"&gt;[1]&lt;/a&gt;. It
is actually not hard to make groups of similar SQL queries since &lt;tt class="docutils literal"&gt;create_entity()&lt;/tt&gt;
generates the same query for a given set of parameters. For instance:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;create_entity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Person&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;firstname&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;John&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;surname&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Doe&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;create_entity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Person&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;firstname&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Tim&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;surname&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;BL&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;will generate the following sql queries:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;cw_Person&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;cw_cwuri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cw_eid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cw_modification_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="n"&gt;cw_creation_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cw_firstname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cw_surname&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
       &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cw_cwuri&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cw_eid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cw_modification_date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cw_creation_date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cw_firstname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cw_surname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;cw_Person&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;cw_cwuri&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cw_eid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cw_modification_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                        &lt;span class="n"&gt;cw_creation_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cw_firstname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cw_surname&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
       &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cw_cwuri&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cw_eid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cw_modification_date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cw_creation_date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cw_firstname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cw_surname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The only thing that will differ is the actual data inserted. Well ... ahem ... CubicWeb actually
also generates a &amp;quot;few&amp;quot; extra sql queries to insert metadata for each entity:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;is_instance_of_relation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;eid_from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;eid_to&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;is_relation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;eid_from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;eid_to&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;cw_source_relation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;eid_from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;eid_to&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;owned_by_relation&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;eid_to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;eid_from&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;eid_to&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;eid_from&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;INSERT&lt;/span&gt; &lt;span class="k"&gt;INTO&lt;/span&gt; &lt;span class="n"&gt;created_by_relation&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="n"&gt;eid_to&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;eid_from&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;VALUES&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;eid_to&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;eid_from&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Those extra queries are actually even exactly the same for each entity insterted, whatever
the entity type is, hence craving for &lt;tt class="docutils literal"&gt;executemany&lt;/tt&gt; or &lt;tt class="docutils literal"&gt;copy_from&lt;/tt&gt;. Grouping together SQL queries
is not that hard &lt;a class="footnote-reference" href="#id4" id="id2"&gt;[2]&lt;/a&gt; but has a drawback : as you don't have an intermediate state
(the data is actually inserted only at the very end of the process),
you loose the ability to query your database to fetch the entities you've just created
during the import.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Now, a few benchmarks ...&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;To create those benchmarks, I decided to use the &lt;a class="reference" href="http://www.cubicweb.org/project/cubicweb-workorder"&gt;workorder&lt;/a&gt; cube which is a simple cube, yet complete enough : it provides only two entity types (&lt;em&gt;WorkOrder&lt;/em&gt; and &lt;em&gt;Order&lt;/em&gt;), a relation between them (&lt;em&gt;Order split_into WorkOrder&lt;/em&gt;) and uses different kind of attributes (&lt;em&gt;String&lt;/em&gt;, &lt;em&gt;Date&lt;/em&gt;, &lt;em&gt;Float&lt;/em&gt;).&lt;/p&gt;
&lt;p&gt;Once the cube was instantiated, I ran the following script to populate the database with my 3 different stores:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;sys&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;datetime&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;date&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;random&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;choice&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;itertools&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;logilab.common.decorators&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;timed&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cwconfig&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb.dbapi&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;in_memory_repo_cnx&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;workorders_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()):&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;xrange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;title&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;u&amp;#39;wo-title&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;description&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;u&amp;#39;foo&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
               &lt;span class="s"&gt;&amp;#39;begin_date&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;end_date&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;orders_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;()):&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;xrange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;title&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;u&amp;#39;o-title&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;date&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;budget&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.8&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;split_into&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;workorders&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;workorder&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;workorders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;choice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;workorder&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initial_state&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;etype&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Any S WHERE S is State, WF initial_state S, &amp;#39;&lt;/span&gt;
                           &lt;span class="s"&gt;&amp;#39;WF workflow_of ET, ET name &lt;/span&gt;&lt;span class="si"&gt;%(etn)s&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;etn&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;etype&lt;/span&gt;&lt;span class="p"&gt;})[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;


&lt;span class="nd"&gt;@timed&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;populate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nb_workorders&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nb_orders&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;set_state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;orders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create_entity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Order&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;attrs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
              &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;attrs&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;orders_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nb_orders&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="n"&gt;workorders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create_entity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;WorkOrder&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;attrs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;attrs&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;workorders_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;nb_workorders&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="c"&gt;## in_state is set by a hook, so NoHookObjectStore will need&lt;/span&gt;
    &lt;span class="c"&gt;## to set the relation manually&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;set_state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;order_state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;initial_state&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;Order&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;workorder_state&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;initial_state&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;WorkOrder&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;relate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;in_state&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;order_state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;workorder&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;workorders&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;relate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;workorder&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;in_state&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;workorder_state&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;workorder&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;split_into&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;workorders&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;relate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;split_into&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;workorder&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;__main__&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cwconfig&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;instance_configuration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;nb_orders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;nb_workorders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cnx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;in_memory_repo_cnx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;login&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;admin&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;admin&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_get_session&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cnx&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sessionid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb.dataimport&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;RQLObjectStore&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;NoHookRQLObjectStore&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubes.mycube.dataimport.store&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CopyFromRQLObjectStore&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;testing RQLObjectStore&amp;#39;&lt;/span&gt;
    &lt;span class="n"&gt;store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;RQLObjectStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;populate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nb_workorders&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nb_orders&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;testing NoHookRQLObjectStore&amp;#39;&lt;/span&gt;
    &lt;span class="n"&gt;store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;NoHookRQLObjectStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;populate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;store&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nb_workorders&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nb_orders&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;set_state&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;testing CopyFromRQLObjectStore&amp;#39;&lt;/span&gt;
    &lt;span class="n"&gt;store&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CopyFromRQLObjectStore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I ran the script and asked to create 100 &lt;em&gt;Order&lt;/em&gt; entities, 1000 &lt;em&gt;WorkOrder&lt;/em&gt; entities
and to link each created &lt;em&gt;WorkOrder&lt;/em&gt; to a parent &lt;em&gt;Order&lt;/em&gt;&lt;/p&gt;
&lt;pre class="literal-block"&gt;
adim&amp;#64;esope:~/tmp/bench_cwdi$ python bench_cwdi.py bench_cwdi 100 1000
testing RQLObjectStore
populate clock: 24.590000000 / time: 46.169721127
testing NoHookRQLObjectStore
populate clock: 8.100000000 / time: 25.712352991
testing CopyFromRQLObjectStore
populate clock: 0.830000000 / time: 1.180006981
&lt;/pre&gt;
&lt;p&gt;My interpretation of the above times is :&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;The &lt;em&gt;clock&lt;/em&gt; time indicates the time spent on CubicWeb server side (i.e. hooks
and data pre/postprocessing around SQL queries). The &lt;em&gt;time&lt;/em&gt; time should be
the sum of &lt;em&gt;clock&lt;/em&gt; time + time spent in postgresql.&lt;/li&gt;
&lt;li&gt;&lt;tt class="docutils literal"&gt;RQLObjectStore&lt;/tt&gt; is slow ;-). Nothing new here, but the clock/time ratio
means that we're speding a lot of time on the python side (i.e. hooks
as I told earlier) and a fair amount of time in postgresql.&lt;/li&gt;
&lt;li&gt;&lt;tt class="docutils literal"&gt;NoHookRQLObjectStore&lt;/tt&gt; really takes down the time spent on the python side,
the time in postgresql remains about the same as for &lt;tt class="docutils literal"&gt;RQLObjectStore&lt;/tt&gt;, this
is not surprising, queries performed are the same in both cases.&lt;/li&gt;
&lt;li&gt;&lt;tt class="docutils literal"&gt;CopyFromRQLObjectStore&lt;/tt&gt; seems blazingly fast in comparison (inserting
a few thousands of elements in postgresql with a &lt;tt class="docutils literal"&gt;COPY FROM&lt;/tt&gt; statement
is not a problem). And ... yes, I checked the data was actually inserted,
and I even a ran a &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;cubicweb-ctl&lt;/span&gt; &lt;span class="pre"&gt;db-check&lt;/span&gt;&lt;/tt&gt; on the instance afterwards.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This probably opens new perspective for massive data imports since the client API
remains the same as before for the programmer. It's still a bit experimental, can only be
used for &amp;quot;dummy&amp;quot;, brute-force import scenario where you can preprocess your data
in Python before updating the database, but it's probably worth having such
a store in the the &lt;a class="reference" href="http://hg.logilab.org/cubicweb/file/default/dataimport.py"&gt;dataimport&lt;/a&gt; module.&lt;/p&gt;
&lt;table class="docutils footnote" frame="void" id="id3" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#id1"&gt;[1]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;The idea is to promote an &lt;tt class="docutils literal"&gt;&lt;span class="pre"&gt;executemany('INSERT&lt;/span&gt; INTO &lt;span class="pre"&gt;...',&lt;/span&gt; data)&lt;/tt&gt; statement into
a &lt;tt class="docutils literal"&gt;COPY FROM&lt;/tt&gt; whenever possible (i.e. simple data types, easy enough to escape). In that case,
the underlying database and python modules have to provide support for this functionality.
For the record, the &lt;a class="reference" href="http://initd.org/psycopg/"&gt;psycopg2&lt;/a&gt; module exposes a &lt;tt class="docutils literal"&gt;copy_from()&lt;/tt&gt; method and soon &lt;a class="reference" href="https://www.logilab.org/project/logilab-database"&gt;logilab-database&lt;/a&gt;
will provide an additional high-level helper for this functionality (see this &lt;a class="reference" href="https://www.logilab.org/ticket/84168"&gt;ticket&lt;/a&gt;).&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;table class="docutils footnote" frame="void" id="id4" rules="none"&gt;
&lt;colgroup&gt;&lt;col class="label" /&gt;&lt;col /&gt;&lt;/colgroup&gt;
&lt;tbody valign="top"&gt;
&lt;tr&gt;&lt;td class="label"&gt;&lt;a class="fn-backref" href="#id2"&gt;[2]&lt;/a&gt;&lt;/td&gt;&lt;td&gt;The code will be posted later or even integrated into CubicWeb
at &lt;a class="reference" href="https://www.cubicweb.org/ticket/2110234"&gt;some point&lt;/a&gt;. For now, it requires a bit of monkey patching around
one or two methods in the source so that SQL is not executed but just
recorded for later executions.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;</description>
  <dc:date>2011-12-09T19:23-01:00</dc:date>
  <dc:creator>Adrien Di Mascio</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/2116712</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/2110309</guid>
  <title>Reusing OpenData from Data.gouv.fr with CubicWeb in 2 hours</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/GzM1pNJkBMA/2110309</link>
  <description>&lt;p&gt;&lt;strong&gt;Data.gouv.fr is great news for the OpenData movement!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Two days ago, the French government released thousands of data sets on &lt;a class="reference" href="http://data.gouv.fr/"&gt;http://data.gouv.fr/&lt;/a&gt; under an &lt;a class="reference" href="http://www.data.gouv.fr/Licence-Ouverte-Open-Licence"&gt;open licensing scheme&lt;/a&gt; that allows people to access and play with them. Thanks to the &lt;a class="reference" href="http://www.cubicweb.org/"&gt;CubicWeb&lt;/a&gt; semantic web framework, it took us only a couple hours to put some of that open data to good use. Here is how we mapped the french railway system.&lt;/p&gt;
&lt;div class="figure align-right"&gt;
&lt;img alt="http://www.cubicweb.org/file/2110281?vid=download" src="http://www.cubicweb.org/file/2110281?vid=download" style="width: 300px;" /&gt;
&lt;p class="caption"&gt;Train stations in french Britany&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="source-datasets"&gt;
&lt;h3&gt;&lt;a&gt;Source Datasets&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;We used two of the datasets available on data.gouv.fr:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p class="first"&gt;&lt;a class="reference" href="http://www.data.gouv.fr/donnees/view/Gares-ferroviaires-de-tous-types%2C-exploit%C3%A9es-ou-non-30383132"&gt;Train stations&lt;/a&gt; : description of the 6442 train stations in France, including their name, type and geographic coordinates.
Here is a sample of the file&lt;/p&gt;
&lt;pre class="literal-block"&gt;
441000;St-Germain-sur-Ille;Desserte Voyageur;48,23955;-1,65358
441000;Montreuil-sur-Ille;Desserte Voyageur-Infrastructure;48,3072;-1,6741
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p class="first"&gt;&lt;a class="reference" href="http://www.data.gouv.fr/donnees/view/Passages-à-niveau-30383135"&gt;LevelCrossings&lt;/a&gt; : description of the 18159 level crossings on french railways, including their type and location.
Here is a sample of the file&lt;/p&gt;
&lt;pre class="literal-block"&gt;
558000;PN privé pour voitures avec barrières sans passage piétons accolé;48,05865;1,60697
395000;PN privé pour voitures avec barrières avec passage piétons accolé public;;48,82544;1,65795
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="data-model"&gt;
&lt;h3&gt;&lt;a&gt;Data Model&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Given the above datasets, we wrote the following data model to store the data in CubicWeb:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Location&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EntityType&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;indexed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;latitude&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;indexed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;longitude&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;indexed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;feature_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SubjectRelation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;FeatureType&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cardinality&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;?*&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;data_source&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SubjectRelation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;DataGovSource&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cardinality&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;1*&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;inlined&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FeatureType&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EntityType&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;indexed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DataGovSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EntityType&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;indexed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;uri&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;indexed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;icon&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;em&gt;Location&lt;/em&gt; object is used for both train stations and level crossings. It has a name (text information), a latitude and a longitude (numeric information), it can be linked to multiple &lt;em&gt;FeatureType&lt;/em&gt; objects and to a &lt;em&gt;DataGovSource&lt;/em&gt;. The &lt;em&gt;FeatureType&lt;/em&gt; object is used to store the type of train station or level crossing and is defined by a name (text information). The &lt;em&gt;DataGovSource&lt;/em&gt; object is defined by a name, a description and a uri used to link back to the source data on data.gouv.fr.&lt;/p&gt;
&lt;div class="figure"&gt;
&lt;img alt="http://www.cubicweb.org/file/2110311?vid=download" src="http://www.cubicweb.org/file/2110311?vid=download" /&gt;
&lt;p class="caption"&gt;Schema of the data model&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="data-import"&gt;
&lt;h3&gt;&lt;a&gt;Data Import&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;We had to write a few lines of code to benefit from the massive data import feature of CubicWeb before we could load the content of the CSV files with a single command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;cubicweb-ctl import-datagov-location datagov_geo gare.csv-fr.CSV  --source-type&lt;span class="o"&gt;=&lt;/span&gt;gare
&lt;span class="nv"&gt;$ &lt;/span&gt;cubicweb-ctl import-datagov-location datagov_geo passage_a_niveau.csv-fr.CSV  --source-type&lt;span class="o"&gt;=&lt;/span&gt;passage
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In less than a minute, the import was completed and we had:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;2 &lt;em&gt;DataGovSource&lt;/em&gt; objects, corresponding to the two data sets,&lt;/li&gt;
&lt;li&gt;24 &lt;em&gt;FeatureType&lt;/em&gt; objects, corresponding to the different types of locations that exist (&lt;em&gt;e.g.&lt;/em&gt; &lt;em&gt;Non exploitée&lt;/em&gt;,         &lt;em&gt;Desserte Voyageur&lt;/em&gt;, &lt;em&gt;PN public isolé pour piétons avec portillons&lt;/em&gt; or &lt;em&gt;PN public pour voitures avec barrières gardé avec passage piétons accolé manoeuvré à distance&lt;/em&gt;),&lt;/li&gt;
&lt;li&gt;24601 &lt;em&gt;Locations&lt;/em&gt;, corresponding to the different train stations and level crossings.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="data-visualization"&gt;
&lt;h3&gt;&lt;a&gt;Data visualization&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;CubicWeb allows to build complex applications by assembling existing components (called &lt;em&gt;cubes&lt;/em&gt;). Here we used a cube that
wraps the &lt;a class="reference" href="http://mapstraction.com/"&gt;Mapstraction&lt;/a&gt; and the &lt;a class="reference" href="http://openlayers.org/"&gt;OpenLayers&lt;/a&gt; libraries to display information on maps using data from &lt;a class="reference" href="http://www.openstreetmap.org/"&gt;OpenStreetMap&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In order for the &lt;em&gt;Location&lt;/em&gt; type defined in the data model to be displayable on a map, it is sufficient to write the following adapter:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;IGeocodableAdapter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EntityAdapter&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
      &lt;span class="n"&gt;__regid__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;IGeocodable&amp;#39;&lt;/span&gt;
      &lt;span class="n"&gt;__select__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;is_instance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Location&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="nd"&gt;@property&lt;/span&gt;
      &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;latitude&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;entity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;latitude&lt;/span&gt;
      &lt;span class="nd"&gt;@property&lt;/span&gt;
      &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;longitude&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;entity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;longitude&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;That was it for the development part!&lt;/strong&gt; The next step was to use the application to browse the structure of the french train network on the map.&lt;/p&gt;
&lt;p&gt;Train stations in use:&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2110279?vid=download" src="http://www.cubicweb.org/file/2110279?vid=download" style="width: 600px;" /&gt;
&lt;p&gt;Train stations not in use:&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2110280?vid=download" src="http://www.cubicweb.org/file/2110280?vid=download" style="width: 600px;" /&gt;
&lt;p&gt;Zooming on some parts of the map, for example Brittany, we get to see more details and clicking on the train icons gives more information on the corresponding &lt;em&gt;Location&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Train stations in use:&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2110281?vid=download" src="http://www.cubicweb.org/file/2110281?vid=download" style="width: 400px;" /&gt;
&lt;p&gt;Train stations not in use:&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2110282?vid=download" src="http://www.cubicweb.org/file/2110282?vid=download" style="width: 400px;" /&gt;
&lt;p&gt;Since CubicWeb separates querying the data and displaying the result of a query, we can switch the view to display the same data in tables or to export it back to a CSV file.&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2110313?vid=download" src="http://www.cubicweb.org/file/2110313?vid=download" style="width: 600px;" /&gt;
&lt;/div&gt;
&lt;div class="section" id="querying-data"&gt;
&lt;h3&gt;&lt;a&gt;Querying Data&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;CubicWeb implements a query langage very similar to &lt;a class="reference" href="http://www.w3.org/TR/rdf-sparql-query/"&gt;SPARQL&lt;/a&gt;, that makes the data available without the need to learn a specific API.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p class="first"&gt;Example 1: &lt;cite&gt;http:/some.url.demo/?rql=Any X WHERE X is Location, X name LIKE &amp;quot;%miny&amp;quot;&lt;/cite&gt;&lt;/p&gt;
&lt;p&gt;This request gives all the &lt;em&gt;Location&lt;/em&gt; with a name that ends with &amp;quot;miny&amp;quot;. It returns only one element, the &lt;em&gt;Firminy&lt;/em&gt; train station.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt="http://www.cubicweb.org/file/2110286?vid=download" src="http://www.cubicweb.org/file/2110286?vid=download" /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p class="first"&gt;Example 2: &lt;cite&gt;http:/some.url.demo/?rql=Any X WHERE X is Location, X name LIKE &amp;quot;%ny&amp;quot;&lt;/cite&gt;&lt;/p&gt;
&lt;p&gt;This request gives all the &lt;em&gt;Location&lt;/em&gt; with a name that ends with &amp;quot;ny&amp;quot;, and return 112 trainstations.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt="http://www.cubicweb.org/file/2110287?vid=download" src="http://www.cubicweb.org/file/2110287?vid=download" /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p class="first"&gt;Example 3: &lt;cite&gt;http:/some.url.demo/?rql=Any X WHERE X latitude &amp;lt; 47.8, X latitude&amp;gt;47.6, X longitude &amp;gt;-1.9, X longitude&amp;lt;-1.8&lt;/cite&gt;&lt;/p&gt;
&lt;p&gt;This request gives all the &lt;em&gt;Location&lt;/em&gt; that have a latitude between 47.6 and 47.8, and a longitude between -1.9 and -1.8.&lt;/p&gt;
&lt;p&gt;We obtain 11 &lt;em&gt;Location&lt;/em&gt; (&lt;em&gt;9&lt;/em&gt; levelcrossings and &lt;em&gt;2&lt;/em&gt; trainstations). We can map them using the &lt;em&gt;view&lt;/em&gt; &lt;em&gt;mapstraction.map&lt;/em&gt; that we describe previously.&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2110288?vid=download" src="http://www.cubicweb.org/file/2110288?vid=download" style="width: 600px;" /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Example 4: &lt;cite&gt;http:/domainname:8080/?rql=Any X WHERE X latitude &amp;lt; 47.8, X  latitude&amp;gt;47.6, X longitude &amp;gt;-1.9, X longitude&amp;lt;-1.8, X  feature_type F, F name &amp;quot;Desserte Voyageur&amp;quot;&lt;/cite&gt;&lt;/p&gt;
&lt;p&gt;Will limit the previous results set to train stations that are used for passenger service:&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2110289?vid=download" src="http://www.cubicweb.org/file/2110289?vid=download" style="width: 600px;" /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Example 5: &lt;cite&gt;http:/domainname:8080/?rql=Any X WHERE X feature_type F, F name &amp;quot;PN  public pour voitures sans barrières sans SAL&amp;quot;&amp;amp;vid=mapstraction.map&lt;/cite&gt;&lt;/p&gt;
&lt;p&gt;Finally, one can map all the level crossings for vehicules without barriers (there are 3704):&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/2110290?vid=download" src="http://www.cubicweb.org/file/2110290?vid=download" style="width: 600px;" /&gt;
&lt;img alt="http://www.cubicweb.org/file/2110291?vid=download" src="http://www.cubicweb.org/file/2110291?vid=download" style="width: 600px;" /&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As you could see in the last URL, the map &lt;em&gt;view&lt;/em&gt; was chosen directly with the parameter &lt;cite&gt;vid&lt;/cite&gt;, meaning that the URL is shareable and can be easily included in a blog with a iframe for example.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="data-sharing"&gt;
&lt;h3&gt;&lt;a&gt;Data sharing&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The result of a query can also be &amp;quot;displayed&amp;quot; in &lt;a class="reference" href="http://www.w3.org/RDF/"&gt;RDF&lt;/a&gt;, thus allowing users to download a semantic version of the information,
without having to do the preprocessing themselves:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="nt"&gt;&amp;lt;rdf:Description&lt;/span&gt; &lt;span class="na"&gt;rdf:about=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;cwuri24684b3a955d4bb8830b50b4e7521450&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;rdf:type&lt;/span&gt; &lt;span class="na"&gt;rdf:resource=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://ns.cubicweb.org/cubicweb/0.0/Location&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;cw:cw_source&lt;/span&gt; &lt;span class="na"&gt;rdf:resource=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://some.url.demo/&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;cw:longitude&lt;/span&gt; &lt;span class="na"&gt;rdf:datatype=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://www.w3.org/2001/XMLSchema#float&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;-1.89599&lt;span class="nt"&gt;&amp;lt;/cw:longitude&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;cw:latitude&lt;/span&gt; &lt;span class="na"&gt;rdf:datatype=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://www.w3.org/2001/XMLSchema#float&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;47.67778&lt;span class="nt"&gt;&amp;lt;/cw:latitude&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;cw:feature_type&lt;/span&gt; &lt;span class="na"&gt;rdf:resource=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://some.url.demo/7222&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;cw:data_source&lt;/span&gt; &lt;span class="na"&gt;rdf:resource=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;http://some.url.demo/7206&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/rdf:Description&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="conclusion"&gt;
&lt;h3&gt;&lt;a&gt;Conclusion&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;For someone who knows the CubicWeb framework, a couple hours are enough to create a CubicWeb application that stores,
displays, queries and shares data downloaded from &lt;a class="reference" href="http://www.data.gouv.fr/"&gt;http://www.data.gouv.fr/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The full source code for the above will be released before the end of the week.&lt;/p&gt;
&lt;p&gt;If you want to see more of CubicWeb in action, browse &lt;a class="reference" href="http://data.bnf.fr"&gt;http://data.bnf.fr&lt;/a&gt; or learn how to develop your own application at &lt;a class="reference" href="http://docs.cubicweb.org/"&gt;http://docs.cubicweb.org/&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
</description>
  <dc:date>2011-12-07T23:36-01:00</dc:date>
  <dc:creator>Vincent Michel</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/2110309</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/1919421</guid>
  <title>ensure that 2 boolean attributes of an entity never have the same value</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/ZeYSYlGPMPY/1919421</link>
  <description>&lt;p&gt;I want to implement an entity with 2 boolean attributes, and a
requirement is that these two attributes never have the same boolean
value (think of some kind of radio buttons).&lt;/p&gt;
&lt;p&gt;Let's start with a simple schema example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c"&gt;# in schema.py&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyEntity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EntityType&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
   &lt;span class="n"&gt;use_option1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;required&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="n"&gt;use_option2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;required&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So new entities will be conform to the spec.&lt;/p&gt;
&lt;p&gt;To do this, you need two things:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;a constraint in the entity schema which will ring if both attributes
have the same value&lt;/li&gt;
&lt;li&gt;a hook which will toggle the other attribute when one attribute is
changed.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;RQL constraints are generally meant to be used on relations, but you
can use them on attributes too. Simply use 'S' to denote the entity,
and write the constraint normally. You need to have the same constraint on both attributes, because the constraint evaluation is triggered by the modification of the attribute.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c"&gt;# in schema.py&lt;/span&gt;
&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyEntity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EntityType&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
   &lt;span class="n"&gt;use_option1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;required&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                         &lt;span class="n"&gt;constraints&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
                              &lt;span class="n"&gt;RQLConstraint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;S use_option1 O1, S use_option2 != O1&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                                       &lt;span class="p"&gt;])&lt;/span&gt;
   &lt;span class="n"&gt;use_option2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Boolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;required&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                         &lt;span class="n"&gt;constraints&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
                              &lt;span class="n"&gt;RQLConstraint&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;S use_option1 O1, S use_option2 != O1&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                                       &lt;span class="p"&gt;])&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;With this update, it is no longer possible to have both options set to
True or False (you will get a ValidationError). The nice thing to
have is to get the other option to be updated when one of the two
attributes is changed, which means that you don't have to take care of
this when editing the entity in the web interface (which you cannot do
anyway if you are using reledit for instance).&lt;/p&gt;
&lt;p&gt;A nice way of writing the hook is to use Python's sets to avoid
tedious logic code:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;RadioButtonUpdateHook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Hook&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
   &lt;span class="sd"&gt;&amp;#39;&amp;#39;&amp;#39;ensure use_option1 = not use_option2 (and conversely)&amp;#39;&amp;#39;&amp;#39;&lt;/span&gt;
   &lt;span class="n"&gt;__regid__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;mycube.radiobuttonhook&amp;#39;&lt;/span&gt;
   &lt;span class="n"&gt;events&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;before_update_entity&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;before_add_entity&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="n"&gt;__select__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Hook&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__select__&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;is_instance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;MyEntity&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="c"&gt;# we prebuild the set of boolean attribute names&lt;/span&gt;
   &lt;span class="n"&gt;_flag_attributes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;use_option1&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;use_option2&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
   &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__call__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
       &lt;span class="n"&gt;entity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;entity&lt;/span&gt;
       &lt;span class="n"&gt;edited&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cw_edited&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
       &lt;span class="n"&gt;attributes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_flag_attributes&lt;/span&gt;
       &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;attributes&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;issubset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;edited&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
           &lt;span class="c"&gt;# both were changed, let the integrity hooks do their job&lt;/span&gt;
           &lt;span class="k"&gt;return&lt;/span&gt;
       &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;attributes&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;edited&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
           &lt;span class="c"&gt;# none of our attributes where changed, do nothing&lt;/span&gt;
           &lt;span class="k"&gt;return&lt;/span&gt;
       &lt;span class="c"&gt;# find which attribute was modified&lt;/span&gt;
       &lt;span class="n"&gt;modified_set&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;attributes&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;edited&lt;/span&gt;
       &lt;span class="c"&gt;# find the name of the other attribute&lt;/span&gt;
       &lt;span class="n"&gt;to_change&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attributes&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;modified_set&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
       &lt;span class="n"&gt;modified_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;modified_set&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
       &lt;span class="c"&gt;# set the value of that attribute&lt;/span&gt;
       &lt;span class="n"&gt;entity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cw_edited&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;to_change&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;entity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cw_edited&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;modified_name&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That's it!&lt;/p&gt;
</description>
  <dc:date>2011-09-08T17:51-01:00</dc:date>
<feedburner:origLink>http://www.cubicweb.org/blogentry/1919421</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/1839294</guid>
  <title>What's new in CubicWeb 3.13?</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/s3VCJS3p9Xo/1839294</link>
  <description>&lt;p&gt;CubicWeb 3.13 has been developed for a while and includes some cool
stuff:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;generate and handle Apache's modconcat compatible URLs, to minimize the number
of HTTP requests necessary to retrieve JS and CSS files, along with a new
cubicweb-ctl command to generate a static 'data' directory that can be served
by a front-end instead of CubicWeb&lt;/li&gt;
&lt;li&gt;major facet enhancements:&lt;ul&gt;
&lt;li&gt;nicer layout and visual feedback when filtering is in-progress&lt;/li&gt;
&lt;li&gt;new &lt;cite&gt;RQLPathFacet&lt;/cite&gt; to easily express new filters that are more than one hop
away from the filtered entities&lt;/li&gt;
&lt;li&gt;a more flexibile API, usable in cases where it wasn't previously possible&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;some form handling refactorings and cleanups, notably introduction of a new
method to process posted content, and updated documentation&lt;/li&gt;
&lt;li&gt;support for new base types : &lt;cite&gt;BigInt&lt;/cite&gt;, &lt;cite&gt;TZDateTime&lt;/cite&gt; and &lt;cite&gt;TZTime&lt;/cite&gt; (in 3.12 actually for those two)&lt;/li&gt;
&lt;li&gt;write queries optimization, and several RQL fixes on complex queries
(e.g. using HAVING, sub-queries...), as well as new support for CAST() function
and REGEXP operator&lt;/li&gt;
&lt;li&gt;datafeed source and default CubicWeb xml parsers:&lt;ul&gt;
&lt;li&gt;refactored into smaller and overridable chunks&lt;/li&gt;
&lt;li&gt;easier to configure&lt;/li&gt;
&lt;li&gt;make it work&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As usual, the 3.13 also includes a bunch of other minor enhancements,
refactorings and bug fixes. Please download and install CubicWeb 3.13 and report
any problem on the tracker and/or the mailing-list!&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;
</description>
  <dc:date>2011-07-21T11:18-01:00</dc:date>
  <dc:creator>Sylvain Thenault</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/1839294</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/1560560</guid>
  <title>CubicWeb sprint in Paris / Need for Speed</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/QkSHnmbC4Ek/1560560</link>
  <description>&lt;p&gt;Logilab is hosting a CubicWeb sprint - 3 days in our Paris offices.&lt;/p&gt;
&lt;p&gt;The general focus will be on speed :&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;on cubicweb-server side : improve performance of massive insertions / deletions&lt;/li&gt;
&lt;li&gt;on cubicweb-client side : cache implementation, HTTP server, massive parallel usage, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This sprint will take place from in April 2011 from tuesday the 26th to thursday the 28th. You are more than welcome to come along and help out, contribute, but unlike previous sprints, at least basic knowledge of CubicWeb will be required for participants since no introduction is planned.&lt;/p&gt;
&lt;p&gt;Network resources will be available for those bringing laptops.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Address&lt;/strong&gt; : 104 Boulevard Auguste-Blanqui, Paris. Ring &amp;quot;Logilab&amp;quot; (&lt;a class="reference" href="http://maps.google.fr/maps?f=q&amp;amp;source=s_q&amp;amp;hl=fr&amp;amp;geocode=&amp;amp;q=104+boulevard+blanqui,+paris&amp;amp;aq=&amp;amp;sll=46.75984,1.738281&amp;amp;sspn=9.726294,22.214355&amp;amp;ie=UTF8&amp;amp;hq=&amp;amp;hnear=104+Boulevard+Auguste+Blanqui,+75013+Paris,+Ile-de-France&amp;amp;z=16"&gt;googlemap&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Metro&lt;/strong&gt; : Glacière&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Contact&lt;/strong&gt; : &lt;a class="reference" href="http://www.logilab.fr/contact"&gt;http://www.logilab.fr/contact&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Dates&lt;/strong&gt; : 26/04/2011 to 28/04/2011&lt;/p&gt;
</description>
  <dc:date>2011-03-30T21:08-01:00</dc:date>
  <dc:creator>Adrien Di Mascio</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/1560560</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/1512775</guid>
  <title>What's new in CubicWeb 3.11?</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/GhML-Xx02dw/1512775</link>
  <description>&lt;p&gt;Unlike recent major version of CubicWeb, the 3.11 doesn't come with many API
changes or refactorings and introduces a fairly small set of new features. But
those are important features!&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p class="first"&gt;'pyrorql' sources mapping is now stored in the database instead of a python
file in the instance's home. This eases the deployment and maintenance of
distributed aplications.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;A new 'datafeed' source was introduced, inspired by the soon to be
deprecated &lt;a class="reference" href="http://www.cubicweb.org/project/cubicweb-datafeed"&gt;datafeed&lt;/a&gt; cube. It needs polishing but sets the foundation for
advanced semantic web applications that import content from others site
using simple http request.&lt;/p&gt;
&lt;p&gt;A 'datafeed' source is associated to a &lt;em&gt;parser&lt;/em&gt; that analyses the imported
data and then creates/updates entities accordingly. There is currently a
single parser in the core that imports CubicWeb-generated xml and needs to
be configured with a mapping information that defines how relations are to
be followed. It provides a viable alternative to 'pyrorql' sources. Other
parsers to import RDF, RSS, etc should come soon.&lt;/p&gt;
&lt;p&gt;A new facet to filter entities based on the source they came from is now
available.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;The management interface for users, groups, sources and site preferences
was simplified so it should be more intuitive to newbies (and others). Most
items have been dropped from the user drop-down menu and the simpler views
were made available through the '/manage' url.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;The default 'index' / 'manage' view has been simplified to deprecate features
that rely on external &lt;a class="reference" href="http://www.cubicweb.org/project/cubicweb-folder"&gt;folder&lt;/a&gt; and &lt;a class="reference" href="http://www.cubicweb.org/project/cubicweb-card"&gt;card&lt;/a&gt; cubes. That's almost the only
deprecation warning you'll get in upgrading to 3.11. Just this one won't
hurt!&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;The &lt;cite&gt;old_calendar&lt;/cite&gt; module has been dropped in favor of
&lt;a class="reference" href="http://arshaw.com/fullcalendar/"&gt;jQuery's fullcalendar&lt;/a&gt; powered views. That's a great news for applications
using calendar features.  Since it was added to the exising &lt;cite&gt;calendar&lt;/cite&gt;
module, you shouldn't have to change anything to get it working, unless you
were using &lt;cite&gt;old_calendar&lt;/cite&gt; in which case you may have to update a few things.
This work was initiated by our mexican friends from &lt;a class="reference" href="http://www.crealibre.com/"&gt;Crealibre&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As usual, the 3.11 also includes a bunch of other minor enhancements,
refactorings and bug fixes. Please download and install CubicWeb 3.11 and
report any problem to the mailing-list!&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;
</description>
  <dc:date>2011-03-10T12:31-01:00</dc:date>
  <dc:creator>Sylvain Thenault</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/1512775</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/1484253</guid>
  <title>A simple scalable web server HA architecture suitable for medium sized projects</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/RlDm6phW11A/1484253</link>
  <description>&lt;p&gt;Having deployed and maintained several public medium sized web sites running
CubicWeb when I worked at &lt;a class="reference" href="http://www.secondweb.fr/"&gt;SecondWeb&lt;/a&gt;, I was asked
by my friends from &lt;a class="reference" href="http://www.logilab.fr"&gt;Logilab&lt;/a&gt; to write a blog post
describing how we managed our deployment while working with the customer and the
hosting company.&lt;/p&gt;
&lt;div class="section" id="non-technical-albeit-important-considerations"&gt;
&lt;h3&gt;&lt;a&gt;Non technical (albeit important) considerations&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Customers that want to run such a medium traffic web site either tell you
which hosting company they partner with, or ask you to find one, so you have no
other choice to deal with an external hosting structure to manage the servers.
I prefer this by the way because:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;High Availability (HA) hosting really requires skills and hardware that are
neither common nor cheap;&lt;/li&gt;
&lt;li&gt;HA hosting requires 24/7/365 availability that SecondWeb could not (and did
not even want to) offer.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;It is clearly difficult for all parties (try to put yourself in the shoes of the
customer...) to manage a website with 3 partners involved, each with their own
goals. From the development leader point of view, you will notice that the
technical people of the hosting company continuously change and you keep seeing
the same operational errors even if you provide and keep improving high  quality
documentation. The software upgrade documentation has to be particularly clear
as it greatly influences the overall web site availability. You also have to
keep an history of the interventions on the servers yourself and maintain an
up-to-date copy of the configuration files.&lt;/p&gt;
&lt;p&gt;The overall architecture proposed here partly benefits from this experience with
managed hosting company, in that we tried to keep it simple.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="which-traffic-size-why-not-bigger"&gt;
&lt;h3&gt;&lt;a&gt;Which traffic size ? Why not bigger ?&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The architecture proposed here has been successfully tested with sites
delivering web pages to &lt;strong&gt;up to 2 millions unique visitors per month&lt;/strong&gt;. It should
scale further up depending on your site database access needs: if you need very
fresh data and have a lot of write operations to the database, you will need
to distribute database access amongst several servers, which is beyond the scope
of this post.&lt;/p&gt;
&lt;p&gt;This is the main limitation of the proposed architecture and the reason why it
is not well-suited for a bigger traffic.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="design-choices"&gt;
&lt;h3&gt;&lt;a&gt;Design choices&lt;/a&gt;&lt;/h3&gt;
&lt;div class="section" id="load-balancing-preserve-user-sessions"&gt;
&lt;h4&gt;&lt;a&gt;Load balancing - Preserve user sessions&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;To achieve very high availability for your web site, you must have no single
point of failure in the whole architecture, which can be far from reasonable
from the costs point of view. However, hosting companies can share costs
between their customers and have them benefit from a double network
infrastructure all along the way from the Internet to your web servers,
themselves hosted on two distant locations. You may then choose an even number
of web servers, half of them hosted on each network infrastructure.&lt;/p&gt;
&lt;p&gt;The important thing is that you must preserve user sessions. As of CubicWeb
3.10, DB persistent sessions have not been implemented yet (it will soon, there
is a &lt;a class="reference" href="http://www.cubicweb.org/ticket/1381328"&gt;ticket&lt;/a&gt; planned for this
functionality), thus you must preserve session cookies by always directing a
given user to the same web server, which is usually achieved by configuring the
load balancer(s) in IP hash mode (it is faster than balancing on the session
cookie, which implies reaching the http stack rather than staying at the TCP/IP level).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="squid-caching-processor-load-balancing"&gt;
&lt;h4&gt;&lt;a&gt;Squid caching, processor load balancing&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Now if you have multi-processor web servers (which is very likely these times)
you will need to use one CubicWeb application instance per processor or the
Python GIL will limit the CPU of your application to a fraction of the available
power. This is pretty easy, you just have to duplicate configuration directories
from &lt;tt class="docutils literal"&gt;/etc/cubicweb.d&lt;/tt&gt;, changing instance names and ports. You can use a simple
sed-based script to generate these copies automatically and keep them in sync.&lt;/p&gt;
&lt;p&gt;Now that we have one instance per processor, the problem of preserving sessions
is back. It can be elegantly solved using &lt;a class="reference" href="http://www.squid-cache.org/"&gt;Squid&lt;/a&gt;,
which can of course deliver cached objects (in particular images, more on this
later), but also listen on several ports and distribute incoming requests evenly
among the CubicWeb instances based on their port of origin. Note that the load
balancer must be set up to balance between ports of the web servers, one port
for each processor. The Squid configuration file to achieve this, looks like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;http_port&lt;/span&gt; &lt;span class="m"&gt;81&lt;/span&gt; defaultsite=www.example.org vhost
&lt;span class="k"&gt;acl&lt;/span&gt; portA myport &lt;span class="m"&gt;81&lt;/span&gt;

&lt;span class="k"&gt;http_port&lt;/span&gt; &lt;span class="m"&gt;82&lt;/span&gt; defaultsite=www.example.org vhost
&lt;span class="k"&gt;acl&lt;/span&gt; portB myport &lt;span class="m"&gt;82&lt;/span&gt;

&lt;span class="k"&gt;acl&lt;/span&gt; site1 &lt;span class="k"&gt;dstdomain&lt;/span&gt; www.example.org

&lt;span class="k"&gt;cache_peer&lt;/span&gt; &lt;span class="m"&gt;127.0.0.1&lt;/span&gt; &lt;span class="no"&gt;parent&lt;/span&gt; &lt;span class="m"&gt;8081&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="no"&gt;no-query&lt;/span&gt; originserver &lt;span class="no"&gt;default&lt;/span&gt; name=server_1
&lt;span class="k"&gt;cache_peer_access&lt;/span&gt; server_1 &lt;span class="no"&gt;allow&lt;/span&gt; portA site1
&lt;span class="k"&gt;cache_peer_access&lt;/span&gt; server_1 &lt;span class="no"&gt;deny&lt;/span&gt; &lt;span class="no"&gt;all&lt;/span&gt;

&lt;span class="k"&gt;cache_peer&lt;/span&gt; &lt;span class="m"&gt;127.0.0.1&lt;/span&gt; &lt;span class="no"&gt;parent&lt;/span&gt; &lt;span class="m"&gt;8082&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="no"&gt;no-query&lt;/span&gt; originserver &lt;span class="no"&gt;default&lt;/span&gt; name=server_2
&lt;span class="k"&gt;cache_peer_access&lt;/span&gt; server_2 &lt;span class="no"&gt;allow&lt;/span&gt; portB site1
&lt;span class="k"&gt;cache_peer_access&lt;/span&gt; server_2 &lt;span class="no"&gt;deny&lt;/span&gt; &lt;span class="no"&gt;all&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is a way to setup Squid to listen to ports 81 and 82 and distribute requests
for www.example.org to ports 8081 and 8082 respectively. This way, requests
should be evenly balanced between the processors a on bi-processor web server.&lt;/p&gt;
&lt;p&gt;You can now setup Squid more classically to achieve what it is initially done
for: caching. See Squid docs for this, particularly the
&lt;a class="reference" href="http://www.squid-cache.org/Doc/config/refresh_pattern/"&gt;refresh_pattern&lt;/a&gt;
directive. Note you do not need to force any HTTP cache standard feature in
Squid, as CubicWeb enables you to fine tune caching using simple
&lt;tt class="docutils literal"&gt;HTTPCacheManager&lt;/tt&gt; classes found in &lt;tt class="docutils literal"&gt;cubicweb/web/httpcache.py&lt;/tt&gt; (at the end of this
file, you will also find default cache manager configuration for the entity and
startup views).&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="cubicweb-with-apache-frontend"&gt;
&lt;h4&gt;&lt;a&gt;CubicWeb with Apache frontend&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;This is controversial but it did not hurt for me: I like to put an Apache frontend
between Squid and the Twisted-based CubicWeb application, because the hosting
companies are usually pretty good at setting it up, like to use server status for
monitoring, mod_deflate for textual content compression, mod_rewrite and other
modules to customize, monitor or fine tune the web servers.&lt;/p&gt;
&lt;p&gt;It can however be argued that Apache is a huge piece of software for such a
restrictive usage, and its memory footprint would be better used for caching.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="no-shared-disk"&gt;
&lt;h4&gt;&lt;a&gt;No shared disk&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;This is an interesting part that simplifies the overall setup: if you want to
save data on disk, it is likely that you also want to keep it in sync between
the web servers, or use a highly secure network storage solution.&lt;/p&gt;
&lt;p&gt;As we already have a data store accessible from the web servers, namely the
database itself, I often choose to use it even for images. This looks like the
nightmare of every sysadmin, but if you make sure the images are not fetched
every second from the database, by using fine tuned cache settings, it will not
hurt. And this way you still benefit from the flexibility of a database and the
easier maintenance of a single data store. We can use CubicWeb cache settings
to allow squid caching images for 1 hour for example. If you have a very dynamic
web site however, you will then need to force a URL change when an image is
edited. This can easily be achieved in CubicWeb using a custom edit controller
that creates a new image when the data attribute of an Image instance was
edited, as illustrated here:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;typed_eid&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb.selectors&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;yes&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb.web.views.editcontroller&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;EditController&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomEditController&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EditController&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;__select__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;EditController&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__select__&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;yes&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;handle_updated_image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;old_eid&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="s"&gt;&amp;#39;modify submitted form to change old_eid into a new entity eid in all key/ values&amp;#39;&lt;/span&gt;
        &lt;span class="n"&gt;old_eid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;unicode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;old_eid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_cw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;
        &lt;span class="n"&gt;new_eid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_cw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;varmaker&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="c"&gt;# handle image eid&lt;/span&gt;
        &lt;span class="k"&gt;del&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;__type:&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;old_eid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;__type:&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;new_eid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;u&amp;#39;Image&amp;#39;&lt;/span&gt;
        &lt;span class="c"&gt;# handle eid list&lt;/span&gt;
        &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;eid&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;old_eid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;eid&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;eid&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;][:&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;new_eid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;eid&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt;
        &lt;span class="c"&gt;# handle attribute and relations&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;iteritems&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;old_eid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new_eid&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;endswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;u&amp;#39;:&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;old_eid&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
                &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;old_eid&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;new_eid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;
                &lt;span class="k"&gt;del&lt;/span&gt; &lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;_default_publish&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c"&gt;# implement image creation when data image was updated, so that we can use&lt;/span&gt;
        &lt;span class="c"&gt;# a far expiry date cache on download view&lt;/span&gt;
        &lt;span class="n"&gt;images&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_cw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;iteritems&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;Image&amp;#39;&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;__type&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_cw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;__maineid&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;
            &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;eid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;typed_eid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt;
            &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="ne"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_cw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;form&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;data-subject:&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;handle_updated_image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nb"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;CustomEditController&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_default_publish&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;eid&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;images&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_cw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;DELETE Image I WHERE I eid &lt;/span&gt;&lt;span class="si"&gt;%(eid)s&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;eid&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To add the 1 hour expiry date for image download view, you can use:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb.selectors&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;yes&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb.web&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;httpcache&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb.web.views.idownloadable&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;DownloadView&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomDownloadView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;DownloadView&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;__select__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;DownloadView&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__select__&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;yes&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;http_cache_manager&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;httpcache&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;MaxAgeHTTPCacheManager&lt;/span&gt;
    &lt;span class="n"&gt;cache_max_age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3600&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="database-server"&gt;
&lt;h4&gt;&lt;a&gt;Database server&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;Hosting companies now often have a pretty good knowledge of PostgreSQL, the
favorite DB back end for CubicWeb. They usually propose to replicate the database
for data safety at a low cost, using PostgreSQL log shipping feature. Note that
new PostgreSQL 9 versions should make it easier to setup replication modes that
could be useful to improve performance and scalability, but there is still a
lack of production level experience for the moment. Please share if you have,
because it is the main issue to deal with to scale up further.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="pre-production"&gt;
&lt;h4&gt;&lt;a&gt;Pre-production&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;This is worth mentioning you need a pre-production server hosted by the same
company on the same hardware (or virtual machine), because:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;software upgrade will run smoother if the technical staff of the hosting company
has already performed the same upgrade operation once: check the same person
does both within a short timeframe if possible;&lt;/li&gt;
&lt;li&gt;you will feel better if your migration scripts have successfully run on a
fresh copy of the production data: ask for a db copy before a pre-production
upgrade; this is much easier to do if you do not have to copy the database
dumps remotely.&lt;/li&gt;
&lt;li&gt;the pre-production server can host its own database server and the replication
of the production one.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="section" id="monitoring"&gt;
&lt;h4&gt;&lt;a&gt;Monitoring&lt;/a&gt;&lt;/h4&gt;
&lt;p&gt;When you experience a web site downtime, it is much too late to take a look at
the available monitoring. It is important to prepare the tools you need to
diagnose a problem, get used to read the graphs and have the orders of
magnitude of the values and their variations in mind.&lt;/p&gt;
&lt;p&gt;Even the simplest graphs, like CPU usage, need to be correctly interpreted. In
a recent setup, I did not realize that only one CPU was used on a bi-pro server,
delivering half the power it should... When you cannot access the machine and
use &lt;em&gt;top&lt;/em&gt;, you only see the information of the monitoring graphs, so you must
know how to read them !&lt;/p&gt;
&lt;p&gt;Apart from the classical CPU, CPU load, (detailed) memory usage, and network
traffic, ask for PostgreSQL, Squid, and Apache specific graphs (plug-ins for them
are easy to find and install for classic monitoring solutions).&lt;/p&gt;
&lt;p&gt;For CubicWeb web sites, it is also worth setting up following views and use
them for automatic alerts:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;a software / db version consistency monitoring&lt;/li&gt;
&lt;li&gt;a db pool size monitoring&lt;/li&gt;
&lt;li&gt;a simple db connection check view&lt;/li&gt;
&lt;li&gt;a view writing the server host name is not interesting for automatic alerts but
to see on which server your IP is directed to: this is needed when you do not
reproduce the behaviour the customer is complaining about...&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are some classes I use for these tasks. Feel free to reuse and adapt them
to your needs:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;socket&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;gethostname&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb.view&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;View&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;_MonitoringView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;View&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;__abstract__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
    &lt;span class="n"&gt;__select__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;yes&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;content_type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;text/plain&amp;#39;&lt;/span&gt;
    &lt;span class="n"&gt;templatable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PoolMonitoringView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_MonitoringView&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;__regid__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;monitor_pool&amp;#39;&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;repo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_cw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cnx&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_repo&lt;/span&gt;
        &lt;span class="n"&gt;max_pool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_cw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vreg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;connections-pool-size&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;percent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;max_pool&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_available_pools&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;qsize&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;100.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;max_pool&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;u&amp;#39;&lt;/span&gt;&lt;span class="si"&gt;%s%%&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;percent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DBMonitoringView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_MonitoringView&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;__regid__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;monitor_db&amp;#39;&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_cw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Any COUNT(X) WHERE X is CWUser&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;u&amp;#39;ServiceOK : &lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s"&gt; users in DB&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;u&amp;#39;ServiceKO&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VersionMonitoringView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_MonitoringView&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;__regid__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;monitor_version&amp;#39;&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;versions_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;versions&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;u&amp;#39; | &amp;#39;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cube&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;u&amp;#39;: &amp;#39;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;u&amp;#39;.&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;unicode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                           &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;versions&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_cw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vreg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;
        &lt;span class="n"&gt;vc_config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;vc_config&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;db_config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;cubicweb&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vc_config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;cubicweb&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;?&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;))]&lt;/span&gt;
        &lt;span class="n"&gt;fs_config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;cubicweb&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cubicweb_version&lt;/span&gt;&lt;span class="p"&gt;())]&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;cube&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cubes&lt;/span&gt;&lt;span class="p"&gt;()):&lt;/span&gt;
            &lt;span class="n"&gt;db_config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;cube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;vc_config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;?&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
            &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;fs_version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cube_version&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cube&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;except&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;fs_version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;?&amp;#39;&lt;/span&gt;
            &lt;span class="n"&gt;fs_config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;cube&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fs_version&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="n"&gt;db_config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;versions_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db_config&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;fs_config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;versions_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fs_config&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;db_config&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;fs_config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;u&amp;#39;ServiceOK : FS config &lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s"&gt; == DB config &lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fs_config&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;db_config&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;u&amp;#39;ServiceKO : FS config &lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s"&gt; !$ DB config &lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fs_config&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;db_config&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HostnameMonitoringView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_MonitoringView&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;__regid__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;monitor_hostname&amp;#39;&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;unicode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gethostname&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="sketch-of-the-architecture-and-conclusion"&gt;
&lt;h3&gt;&lt;a&gt;Sketch of the architecture and conclusion&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;There is a sketch of the proposed architecture. Please comment on it and share
your experience on the topic, I would be happy to learn your tips and tricks.&lt;/p&gt;
&lt;p&gt;I would conclude with an important remark regarding performance: a good scalable
architecture is of great help to run a busy web site smoothly, however the
performance boost you get by optimizing your software performance is usually
worth it and must be seriously considered before any hardware upgrade, may it
seem costly at first glance.&lt;/p&gt;
&lt;img alt="/file/1521968?vid=download" src="/file/1521968?vid=download" /&gt;
&lt;/div&gt;
</description>
  <dc:date>2011-03-08T14:24-01:00</dc:date>
  <dc:creator>Florent Cayré</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/1484253</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/1440518</guid>
  <title>Building my photos web site with CubicWeb part V: let's make it even more user friendly</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/3qgUVbR4FI4/1440518</link>
  <description>&lt;p&gt;We'll now see how to benefit from features introduced in 3.9 and 3.10 releases of CubicWeb&lt;/p&gt;
&lt;div class="section" id="step-1-tired-of-the-default-look"&gt;
&lt;h3&gt;&lt;a&gt;Step 1: tired of the default look?&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;OK... Now our site has its most desired features. But... I would like to make it look
somewhat like &lt;em&gt;my&lt;/em&gt; website. It is not www.cubicweb.org after all. Let's tackle this
first!&lt;/p&gt;
&lt;p&gt;The first thing we can to is to change the logo. There are various way to achieve
this. The easiest way is to put a &lt;cite&gt;logo.png&lt;/cite&gt; file into the cube's &lt;cite&gt;data&lt;/cite&gt;
directory. As data files are looked at according to cubes order (CubicWeb
resources coming last), that file will be selected instead of CubicWeb's one.&lt;/p&gt;
&lt;div class="note"&gt;
&lt;h3 class="first"&gt;&lt;a&gt;Note&lt;/a&gt;&lt;/h3&gt;
&lt;p class="last"&gt;As the location for static resources are cached, you'll have to restart
your instance for this to be taken into account.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Though there are some cases where you don't want to use a &lt;cite&gt;logo.png&lt;/cite&gt; file.
For instance if it's a JPEG file. You can still change the logo by defining in
the cube's &lt;cite&gt;uiprops.py&lt;/cite&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;LOGO&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;logo.jpg&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The uiprops machinery has been introduced in &lt;a class="reference" href="http://www.cubicweb.org/blogentry/1179899"&gt;CubicWeb 3.9&lt;/a&gt;. It is used to define
some static file resources, such as the logo, default Javascript / CSS files, as
well as CSS properties (we'll see that later).&lt;/p&gt;
&lt;div class="note"&gt;
&lt;h3 class="first"&gt;&lt;a&gt;Note&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This file is imported specifically by &lt;em&gt;CubicWeb&lt;/em&gt;, with a predefined name space,
containing for instance the &lt;cite&gt;data&lt;/cite&gt; function, telling the file is somewhere
in a cube or CubicWeb's data directory.&lt;/p&gt;
&lt;p class="last"&gt;One side effect of this is that it can't be imported as a regular python
module.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;The nice thing is that in debug mode, change to a &lt;cite&gt;uiprops.py&lt;/cite&gt; file are detected
and then automatically reloaded.&lt;/p&gt;
&lt;p&gt;Now, as it's a photos web-site, I would like to have a photo of mine as background...
After some trials I won't detail here, I've found a working recipe explained &lt;a class="reference" href="http://webdesign.about.com/od/css3/f/blfaqbgsize.htm"&gt;here&lt;/a&gt;.
All I've to do is to override some stuff of the default CubicWeb user interface to
apply it as explained.&lt;/p&gt;
&lt;p&gt;The first thing to to get the &lt;tt class="docutils literal"&gt;&amp;lt;img/&amp;gt;&lt;/tt&gt; tag as first element after the
&lt;tt class="docutils literal"&gt;&amp;lt;body&amp;gt;&lt;/tt&gt; tag.  If you know a way to avoid this by simply specifying the image
in the CSS, tell me!  The easiest way to do so is to override the
&lt;cite&gt;HTMLPageHeader&lt;/cite&gt; view, since that's the one that is directly called once
the &lt;tt class="docutils literal"&gt;&amp;lt;body&amp;gt;&lt;/tt&gt; has been written. How did I find this?  By looking in the
&lt;cite&gt;cubiweb.web.views.basetemplates&lt;/cite&gt; module, since I know that global page
layouts sits there. I could also have grep the &amp;quot;body&amp;quot; tag in
&lt;cite&gt;cubicweb.web.views&lt;/cite&gt;... Finding this was the hardest part. Now all I need is
to customize it to write that &lt;tt class="docutils literal"&gt;img&lt;/tt&gt; tag, as below:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HTMLPageHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;basetemplates&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HTMLPageHeader&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="c"&gt;# override this since it&amp;#39;s the easier way to have our bg image&lt;/span&gt;
    &lt;span class="c"&gt;# as the first element following &amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;u&amp;#39;&amp;lt;img id=&amp;quot;bg-image&amp;quot; src=&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;%s&lt;/span&gt;&lt;span class="s"&gt;background.jpg&amp;quot; alt=&amp;quot;background image&amp;quot;/&amp;gt;&amp;#39;&lt;/span&gt;
               &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_cw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;datadir_url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nb"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HTMLPageHeader&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;registration_callback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vreg&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;vreg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;register_all&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;globals&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HTMLPageHeader&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;vreg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;register_and_replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;HTMLPageHeader&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;basetemplates&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HTMLPageHeader&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As you may have guessed, my background image is in a &lt;cite&gt;background.jpg&lt;/cite&gt; file
in the cube's &lt;cite&gt;data&lt;/cite&gt; directory, but there are still some things to explain
to newcomers here:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;The &lt;cite&gt;call&lt;/cite&gt; method is there the main access point of the view. It's called by
the view's &lt;cite&gt;render&lt;/cite&gt; method. It is not the only access point for a view, but
this will be detailed later.&lt;/li&gt;
&lt;li&gt;Calling &lt;cite&gt;self.w&lt;/cite&gt; writes something to the output stream. Except for binary views
(which do not generate text), it &lt;em&gt;must&lt;/em&gt; be passed an Unicode string.&lt;/li&gt;
&lt;li&gt;The proper way to get a file in &lt;cite&gt;data&lt;/cite&gt; directory is to use the &lt;cite&gt;datadir_url&lt;/cite&gt;
attribute of the incoming request (e.g. &lt;cite&gt;self._cw&lt;/cite&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I won't explain again the &lt;cite&gt;registration_callback&lt;/cite&gt; stuff, you should understand it
now!  If not, go back to previous posts in the series :)&lt;/p&gt;
&lt;p&gt;Fine. Now all I've to do is to add a bit of CSS to get it to behave nicely (which
is not the case at all for now). I'll put all this in a &lt;cite&gt;cubes.sytweb.css&lt;/cite&gt;
file, stored as usual in our &lt;cite&gt;data&lt;/cite&gt; directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="c"&gt;/* fixed full screen background image&lt;/span&gt;
&lt;span class="c"&gt; * as explained on http://webdesign.about.com/od/css3/f/blfaqbgsize.htm&lt;/span&gt;
&lt;span class="c"&gt; *&lt;/span&gt;
&lt;span class="c"&gt; * syt update: set z-index=0 on the img instead of z-index=1 on div#page &amp;amp; co to&lt;/span&gt;
&lt;span class="c"&gt; * avoid pb with the user actions menu&lt;/span&gt;
&lt;span class="c"&gt; */&lt;/span&gt;
&lt;span class="nt"&gt;img&lt;/span&gt;&lt;span class="nf"&gt;#bg-image&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;position&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;fixed&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;top&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;left&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;width&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;height&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;z-index&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="nf"&gt;#page&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;table&lt;/span&gt;&lt;span class="nf"&gt;#header&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="nf"&gt;#footer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;background&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;transparent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;position&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* add some space around the logo&lt;/span&gt;
&lt;span class="c"&gt; */&lt;/span&gt;
&lt;span class="nt"&gt;img&lt;/span&gt;&lt;span class="nf"&gt;#logo&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;padding&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt; &lt;span class="m"&gt;0px&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* more dark font for metadata to have a chance to see them with the background&lt;/span&gt;
&lt;span class="c"&gt; *  image&lt;/span&gt;
&lt;span class="c"&gt; */&lt;/span&gt;
&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="nc"&gt;.metadata&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;color&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can see here stuff explained in the cited page, with only a slight modification
explained in the comments, plus some additional rules to make things somewhat cleaner:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;a bit of padding around the logo&lt;/li&gt;
&lt;li&gt;darker metadata which appears by default below the content (the white frame in the page)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To get this CSS file used everywhere in the site, I have to modify the &lt;cite&gt;uiprops.py&lt;/cite&gt; file
introduced above:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;STYLESHEETS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sheet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;STYLESHEETS&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;cubes.sytweb.css&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;div class="note"&gt;
&lt;h3 class="first"&gt;&lt;a&gt;Note&lt;/a&gt;&lt;/h3&gt;
&lt;p class="last"&gt;&lt;cite&gt;sheet&lt;/cite&gt; is another predefined variable containing values defined by
already process &lt;tt class="docutils literal"&gt;uiprops.py&lt;/tt&gt; file, notably the CubicWeb's one.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Here we simply want our CSS in addition to CubicWeb's base CSS files, so we
redefine the &lt;cite&gt;STYLESHEETS&lt;/cite&gt; variable to existing CSS (accessed through the &lt;cite&gt;sheet&lt;/cite&gt;
variable) with our one added. I could also have done:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;sheet&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;STYLESHEETS&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;cubes.sytweb.css&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;But this is less interesting since we don't see the overriding mechanism...&lt;/p&gt;
&lt;p&gt;At this point, the site should start looking good, the background image being
resized to fit the screen.&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/1440508?vid=download" src="http://www.cubicweb.org/file/1440508?vid=download" /&gt;
&lt;p&gt;The final touch: let's customize CubicWeb's CSS to get less orange... By simply adding&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="n"&gt;contextualBoxTitleBg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;incontextBoxTitleBg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;#AAAAAA&amp;#39;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;and reloading the page we've just seen, we know have a nice greyed box instead of
the orange one:&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/1440510?vid=download" src="http://www.cubicweb.org/file/1440510?vid=download" /&gt;
&lt;p&gt;This is because CubicWeb's CSS include some variables which are
expanded by values defined in uiprops file. In our case we controlled the
properties of the CSS &lt;cite&gt;background&lt;/cite&gt; property of boxes with CSS class
&lt;cite&gt;contextualBoxTitleBg&lt;/cite&gt; and &lt;cite&gt;incontextBoxTitleBg&lt;/cite&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="step-2-configuring-boxes"&gt;
&lt;h3&gt;&lt;a&gt;Step 2: configuring boxes&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Boxes present to the user some ways to use the application. Let's first do a few
user interface tweaks in our &lt;cite&gt;views.py&lt;/cite&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb.selectors&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;none_rset&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb.web.views&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;bookmark&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubes.zone&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;views&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;zone&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubes.tag&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;views&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;tag&lt;/span&gt;

&lt;span class="c"&gt;# change bookmarks box selector so it&amp;#39;s only displayed on startup views&lt;/span&gt;
&lt;span class="n"&gt;bookmark&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BookmarksBox&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__select__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bookmark&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BookmarksBox&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;__select__&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;none_rset&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="c"&gt;# move zone box to the left instead of in the context frame and tweak its order&lt;/span&gt;
&lt;span class="n"&gt;zone&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ZoneBox&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;left&amp;#39;&lt;/span&gt;
&lt;span class="n"&gt;zone&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ZoneBox&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="c"&gt;# move tags box to the left instead of in the context frame and tweak its order&lt;/span&gt;
&lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TagsBox&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;left&amp;#39;&lt;/span&gt;
&lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TagsBox&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;102&lt;/span&gt;
&lt;span class="c"&gt;# hide similarity box, not interested&lt;/span&gt;
&lt;span class="n"&gt;tag&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SimilarityBox&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;visible&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The idea is to move all boxes in the left column, so we get more space for the
photos.  Now, serious things: I want a box similar to the tags box but to handle
the &lt;cite&gt;Person displayed_on File&lt;/cite&gt; relation. We can do this simply by adding a
&lt;cite&gt;AjaxEditRelationCtxComponent&lt;/cite&gt; subclass to our views, as below:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;logilab.common.decorators&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;monkeypatch&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ValidationError&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb.web&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;uicfg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;component&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb.web.views&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;basecontrollers&lt;/span&gt;

&lt;span class="c"&gt;# hide displayed_on relation using uicfg since it will be displayed by the box below&lt;/span&gt;
&lt;span class="n"&gt;uicfg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;primaryview_section&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tag_object_of&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;*&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;displayed_on&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;*&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;hidden&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PersonBox&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;component&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AjaxEditRelationCtxComponent&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;__regid__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;sytweb.displayed-on-box&amp;#39;&lt;/span&gt;
    &lt;span class="c"&gt;# box position&lt;/span&gt;
    &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;101&lt;/span&gt;
    &lt;span class="n"&gt;context&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;left&amp;#39;&lt;/span&gt;
    &lt;span class="c"&gt;# define relation to be handled&lt;/span&gt;
    &lt;span class="n"&gt;rtype&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;displayed_on&amp;#39;&lt;/span&gt;
    &lt;span class="n"&gt;role&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;object&amp;#39;&lt;/span&gt;
    &lt;span class="n"&gt;target_etype&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;Person&amp;#39;&lt;/span&gt;
    &lt;span class="c"&gt;# messages&lt;/span&gt;
    &lt;span class="n"&gt;added_msg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;person has been added&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;removed_msg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;person has been removed&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c"&gt;# bind to js_* methods of the json controller&lt;/span&gt;
    &lt;span class="n"&gt;fname_vocabulary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;unrelated_persons&amp;#39;&lt;/span&gt;
    &lt;span class="n"&gt;fname_validate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;link_to_person&amp;#39;&lt;/span&gt;
    &lt;span class="n"&gt;fname_remove&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;unlink_person&amp;#39;&lt;/span&gt;


&lt;span class="nd"&gt;@monkeypatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;basecontrollers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;JSonController&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@basecontrollers.jsonize&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;js_unrelated_persons&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="sd"&gt;&amp;quot;&amp;quot;&amp;quot;return tag unrelated to an entity&amp;quot;&amp;quot;&amp;quot;&lt;/span&gt;
    &lt;span class="n"&gt;rql&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Any F + &amp;#39; &amp;#39; + S WHERE P surname S, P firstname F, X eid &lt;/span&gt;&lt;span class="si"&gt;%(x)s&lt;/span&gt;&lt;span class="s"&gt;, NOT P displayed_on X&amp;quot;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,)&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_cw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rql&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;x&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;})]&lt;/span&gt;


&lt;span class="nd"&gt;@monkeypatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;basecontrollers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;JSonController&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;js_link_to_person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;people&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;req&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_cw&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;people&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;firstname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;surname&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="n"&gt;ValidationError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;displayed_on&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;object&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;provide &amp;lt;first name&amp;gt; &amp;lt;surname&amp;gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
        &lt;span class="n"&gt;rset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Person P WHERE &amp;#39;&lt;/span&gt;
                           &lt;span class="s"&gt;&amp;#39;P firstname &lt;/span&gt;&lt;span class="si"&gt;%(firstname)s&lt;/span&gt;&lt;span class="s"&gt;, P surname &lt;/span&gt;&lt;span class="si"&gt;%(surname)s&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                           &lt;span class="nb"&gt;locals&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rset&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_entity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;create_entity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;Person&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;firstname&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;firstname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                            &lt;span class="n"&gt;surname&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;surname&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;SET P displayed_on X WHERE &amp;#39;&lt;/span&gt;
                    &lt;span class="s"&gt;&amp;#39;P eid &lt;/span&gt;&lt;span class="si"&gt;%(p)s&lt;/span&gt;&lt;span class="s"&gt;, X eid &lt;/span&gt;&lt;span class="si"&gt;%(x)s&lt;/span&gt;&lt;span class="s"&gt;, NOT P displayed_on X&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;p&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;x&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="nd"&gt;@monkeypatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;basecontrollers&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;JSonController&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;js_unlink_person&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;personeid&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_cw&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;DELETE P displayed_on X WHERE P eid &lt;/span&gt;&lt;span class="si"&gt;%(p)s&lt;/span&gt;&lt;span class="s"&gt;, X eid &lt;/span&gt;&lt;span class="si"&gt;%(x)s&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                     &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;&amp;#39;p&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;personeid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;x&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;eid&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You basically subclass to configure with some class attributes. The &lt;cite&gt;fname_*&lt;/cite&gt;
attributes give the name of methods that should be defined on the json control to
make the AJAX part of the widget work: one to get the vocabulary, one to add a
relation and another to delete a relation. These methods must start by a &lt;cite&gt;js_&lt;/cite&gt;
prefix and are added to the controller using the &lt;cite&gt;&amp;#64;monkeypatch&lt;/cite&gt; decorator. In my
case, the most complicated method is the one which adds a relation, since it
tries to see if the person already exists, and else automatically create it,
assuming the user entered &amp;quot;firstname surname&amp;quot;.&lt;/p&gt;
&lt;p&gt;Let's see how it looks like on a file primary view:&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/1440509?vid=download" src="http://www.cubicweb.org/file/1440509?vid=download" /&gt;
&lt;p&gt;Great, it's now as easy for me to link my pictures to people than to tag them.
Also, visitors get a consistent display of these two pieces of information.&lt;/p&gt;
&lt;div class="note"&gt;
&lt;h3 class="first"&gt;&lt;a&gt;Note&lt;/a&gt;&lt;/h3&gt;
&lt;p class="last"&gt;The ui component system has been refactored in &lt;a class="reference" href="http://www.cubicweb.org/blogentry/1330518"&gt;CubicWeb 3.10&lt;/a&gt;, which also
introduced the &lt;cite&gt;AjaxEditRelationCtxComponent&lt;/cite&gt; class.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="step-3-configuring-facets"&gt;
&lt;h3&gt;&lt;a&gt;Step 3: configuring facets&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The last feature we'll add today is facet configuration. If you access to the
'/file' url, you'll see a set of 'facets' appearing in the left column. Facets
provide an intuitive way to build a query incrementally, by proposing to the user
various way to restrict the result set. For instance CubicWeb proposes a facet to
restrict based on who created an entity; the tag cube proposes a facet to
restrict based on tags; the zoe cube a facet to restrict based on geographical
location, and so on. In that gist, I want to propose a facet to restrict based on
the people displayed on the picture. To do so, there are various classes in the
&lt;cite&gt;cubicweb.web.facet&lt;/cite&gt; module which simply have to be configured using class
attributes as we've done for the box. In our case, we'll define a subclass of
&lt;cite&gt;RelationFacet&lt;/cite&gt;.&lt;/p&gt;
&lt;div class="note"&gt;
&lt;h3 class="first"&gt;&lt;a&gt;Note&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Since that's ui stuff, we'll continue to add code below to our
&lt;cite&gt;views.py&lt;/cite&gt; file. Though we begin to have a lot of various code their, so
it's may be a good time to split our views module into submodules of a &lt;cite&gt;view&lt;/cite&gt;
package. In our case of a simple application (glue) cube, we could start using
for instance the layout below:&lt;/p&gt;
&lt;pre class="last literal-block"&gt;
views/__init__.py   # uicfg configuration, facets
views/layout.py     # header/footer/background stuff
views/components.py # boxes, adapters
views/pages.py      # index view, 404 view
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;cubicweb.web&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;facet&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DisplayedOnFacet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;facet&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RelationFacet&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;__regid__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;displayed_on-facet&amp;#39;&lt;/span&gt;
    &lt;span class="c"&gt;# relation to be displayed&lt;/span&gt;
    &lt;span class="n"&gt;rtype&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;displayed_on&amp;#39;&lt;/span&gt;
    &lt;span class="n"&gt;role&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;object&amp;#39;&lt;/span&gt;
    &lt;span class="c"&gt;# view to use to display persons&lt;/span&gt;
    &lt;span class="n"&gt;label_vid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;combobox&amp;#39;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Let's say we also want to filter according to the &lt;cite&gt;visibility&lt;/cite&gt; attribute. This is
even simpler as we just have to derive from the &lt;cite&gt;AttributeFacet&lt;/cite&gt; class:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VisibilityFacet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;facet&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AttributeFacet&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;__regid__&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;visibility-facet&amp;#39;&lt;/span&gt;
    &lt;span class="n"&gt;rtype&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;&amp;#39;visibility&amp;#39;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now if I search for some pictures on my site, I get the following facets available:&lt;/p&gt;
&lt;img alt="http://www.cubicweb.org/file/1440517?vid=download" src="http://www.cubicweb.org/file/1440517?vid=download" /&gt;
&lt;div class="note"&gt;
&lt;h3 class="first"&gt;&lt;a&gt;Note&lt;/a&gt;&lt;/h3&gt;
&lt;p class="last"&gt;By default a facet must be applyable to every entity in the result set and
provide at leat two elements of vocabulary to be displayed (for instance you
won't see the &lt;cite&gt;created_by&lt;/cite&gt; facet if the same user has created all
entities). This may explain why you don't see yours...&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="conclusion"&gt;
&lt;h3&gt;&lt;a&gt;Conclusion&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;We started to see the power behind the infrastructure provided by the
framework, both on the pure ui (CSS, Javascript) side and on the Python side
(high level generic classes for components, including boxes and facets). We now
have, with a few lines of code, a full-featured web site with a personalized look.&lt;/p&gt;
&lt;p&gt;Of course we'll probably want more as time goes, but we can now
concentrate on making good pictures, publishing albums and sharing them with
friends...&lt;/p&gt;
&lt;/div&gt;
</description>
  <dc:date>2011-01-24T11:53-01:00</dc:date>
  <dc:creator>Sylvain Thenault</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/1440518</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/1382381</guid>
  <title>CubicWeb sprint in Paris on january 19/20/21 2011</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/0dlDwD5KQ_s/1382381</link>
  <description>&lt;img alt="http://farm1.static.flickr.com/183/419945378_4ead41a76d_m.jpg" class="align-right" src="http://farm1.static.flickr.com/183/419945378_4ead41a76d_m.jpg" /&gt;
&lt;p&gt;Almost everything is in the title: we'll hold a CubicWeb sprint in our Paris office after the first &lt;a class="reference" href="http://www.semweb.pro"&gt;French Semantic Web conference&lt;/a&gt;, so on 19, 20 and 21 of january 2011.&lt;/p&gt;
&lt;p&gt;The main topic will be to enhance newcomers experience in installing and using CubicWeb.&lt;/p&gt;
&lt;p&gt;If you wish to come, you're welcome, that's a great way to meet us, learn the framework and share thoughts about it. Simply &lt;a class="reference" href="mailto:contact&amp;#64;logilab.fr"&gt;contact us&lt;/a&gt; so we can check there is still some room available.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;photo by&lt;/em&gt; &lt;a class="reference" href="http://www.flickr.com/photos/giovannijl-s_photohut/"&gt;Sebastian Mary&lt;/a&gt; &lt;em&gt;under&lt;/em&gt; &lt;a class="reference" href="http://creativecommons.org/licenses/by-sa/2.0/"&gt;creative commons licence&lt;/a&gt;.&lt;/p&gt;
</description>
  <dc:date>2010-12-03T20:52-01:00</dc:date>
  <dc:creator>Sylvain Thenault</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/1382381</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/1334028</guid>
  <title>HTML5 features presented at Paris Web 2010 by Paul Rouget</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/rn8je7t_0Bc/1334028</link>
  <description>&lt;p&gt;While at &lt;a class="reference" href="http://www.paris-web.fr/"&gt;Paris Web 2010&lt;/a&gt; we were all impressed by the presentation and
demos by &lt;a class="reference" href="http://paulrouget.com/"&gt;Paul Rouget&lt;/a&gt; on HTML5 (tech evangelist must be a hard
job!). Here is my take and a few URLs on the things that were presented.&lt;/p&gt;
&lt;img alt="http://hacks.mozilla.org/wp-content/themes/Hacks2010/img/mozilla.png" class="align-right" src="http://hacks.mozilla.org/wp-content/themes/Hacks2010/img/mozilla.png" /&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;Websockets&lt;/strong&gt; with persistent connections between the server and the
browser. That way you can avoid pulling information every 5 seconds,
the server can tell the web page a new info is available. The
immediate uses we have for this are :&lt;ul&gt;
&lt;li&gt;realtime feed display&lt;/li&gt;
&lt;li&gt;jabber web chat rooms&lt;/li&gt;
&lt;li&gt;in cubicweb's forge : new comment indication on a ticket&lt;/li&gt;
&lt;li&gt;in cubicweb in general : notification that the edited element has
been openned by another user (instead of a lock mechanism)&lt;/li&gt;
&lt;li&gt;real time collaborative editing (etherpad style functionality)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;File upload&lt;/strong&gt; demo : &lt;a class="reference" href="http://demos.hacks.mozilla.org/openweb/uploadingFiles/"&gt;http://demos.hacks.mozilla.org/openweb/uploadingFiles/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;File &lt;strong&gt;EXIF extraction&lt;/strong&gt;, client side resize or geolocalisation
&lt;a class="reference" href="http://demos.hacks.mozilla.org/openweb/FileAPI/"&gt;http://demos.hacks.mozilla.org/openweb/FileAPI/&lt;/a&gt; . That could be very
cool for things such as resizing an image before it is sent to the
server (you know, for your mother who doesn't know how to resize
that 2 Mbytes photo before sending it to the site). Reference :
&lt;a class="reference" href="https://developer.mozilla.org/en/Using_files_from_web_applications"&gt;https://developer.mozilla.org/en/Using_files_from_web_applications&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Using &lt;strong&gt;File IO&lt;/strong&gt;, you can do some heavy &lt;strong&gt;Drag'n'drop&lt;/strong&gt; from your computer
to your browser directly in the browser (yes, you can get rid of that
nasty java applet). Apparently Google implemented in Chromium a
non-standard drag'n'drop the other way around : from the web app to
your desktop, which could be cool as well.&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt="http://farm5.static.flickr.com/4147/5085028912_173337f0ba.jpg" class="align-center" src="http://farm5.static.flickr.com/4147/5085028912_173337f0ba.jpg" /&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;strong&gt;XHR - XMLHttpRequest&lt;/strong&gt;. Usually this type of requests is not possible
cross-domain. Now they will be (with an authorization
mechanism). That way, you will be able to post and control websites
from the page in your browser.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Audio Data API&lt;/strong&gt; : you can now access &amp;amp; modify audio files directly in
your browser (before uploading them server side). This makes me think
of the first time I realized people where implementing traditionally &amp;quot;heavy&amp;quot;
applications (photo editing, music editing, even movie edition) in web
applications. I was (and still am) very surprised and skeptic, but this kind
of evolution makes me believe that there can be a day when you don't
even need to send massive files to the server to edit them.&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt="http://farm1.static.flickr.com/191/513636061_98d07f7966_t.jpg" class="align-left" src="http://farm1.static.flickr.com/191/513636061_98d07f7966_t.jpg" /&gt;
&lt;p&gt;Admittedly, you probably need to see the thrilling presentation and
demos to be tempted to go and dip into these technologies. Reading the
documentation will probably not encourage you to go and code some cool
new features.&lt;/p&gt;
&lt;p&gt;One of the things that the audience commented about at the end of the
presentation is that there was still a huge lack of &amp;quot;authoring tools&amp;quot;
for HTML5. For some coders that never leave vim or emacs, this is
heresy, but we have to admit that the adoption of flash and
silverlight (apparently) is very much driven by simple click'n'program
tools.&lt;/p&gt;
&lt;img alt="http://www.mozilla.org/images/minefield_168.png" class="align-right" src="http://www.mozilla.org/images/minefield_168.png" /&gt;
&lt;p&gt;During the presentation, I used a Chrome 6 that I had lying around on
my &lt;strong&gt;Ubuntu&lt;/strong&gt;, but by the end of the presentation I had installed &lt;strong&gt;Firefox4&lt;/strong&gt;
using the mozilla PPA&lt;/p&gt;
&lt;pre class="literal-block"&gt;
sudo add-apt-repository ppa:ubuntu-mozilla-daily/ppa
sudo apt-get update
sudo apt-get -uVf install firefox-4.0
&lt;/pre&gt;
&lt;p&gt;The PPA version keeps config files separate so you can easily switch
between your &amp;quot;standard&amp;quot; Firefox3 profile and the cutting edge Firefox4
(obviously the big downside is not having all your cool extensions).&lt;/p&gt;
&lt;p&gt;The only thing missing from the presentation was the code... a request
I hope Paul will grant to the community (a bunch of tweets about that
followed the presentation).&lt;/p&gt;
</description>
  <dc:date>2010-10-20T11:08-01:00</dc:date>
  <dc:creator>Arthur Lutz</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/1334028</feedburner:origLink></item>
<item>
<guid isPermaLink="false">http://www.cubicweb.org/blogentry/1330518</guid>
  <title>What's new in CubicWeb 3.10?</title>
  <link>http://feedproxy.google.com/~r/cubicweborg/~3/kJVeAdGWsfo/1330518</link>
  <description>&lt;p&gt;The 3.10 development started during August, with  two
important patches: one on the repository / entity API, another one on the boxes /
content navigation components unification (more on this later). Then it somewhat came to a halt, as more work was done on other projects and to stabilize the
3.9 branch. We finally got back on it during September, adding several other major
changes or enhancements.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p class="first"&gt;Cleanup of the repository side entity API, i.e. the API you may use when
writing hooks.  Beside simple namespace cleanup (a few renamings), the API has
been modified to move out attributes being edited from the read cache. So now:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;entities do not inherit from &lt;cite&gt;dict&lt;/cite&gt; anymore; access to the dict protocol on an
entity will raise deprecation warnings&lt;/li&gt;
&lt;li&gt;the attributes cache is now a &lt;cite&gt;cw_attr_cache&lt;/cite&gt; dictionary on the entity&lt;/li&gt;
&lt;li&gt;edited attributes are in a &lt;cite&gt;cw_edited&lt;/cite&gt; attribute special object, which is only
available in hooks for a modified entity (i.e.
'[before|after]_[add|update]_entity', you should use the dict protocol on that object to get
modified attributes or to modify what is edited (in 'before' hooks only, and
this is now enforced). This deprecates the former &lt;cite&gt;edited_attributes&lt;/cite&gt; attribute.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Unification of 'boxes' / 'contentnavigation' registries and base classes, into
&amp;quot;contextual components&amp;quot; stored in the 'ctxcomponents' registry. This implied the
introduction of &amp;quot;layout&amp;quot; objects which are &lt;em&gt;appobjects&lt;/em&gt; responsible of displaying
the components according to the context they are displayed in.&lt;/p&gt;
&lt;p&gt;This separation of content / layout and some css cleanups allows us to move former
boxes and content components into each other's place in the user interface: for
instance, go to your preferences pages and try to move the search box. You now have many
more different locations available. Though one component may not go anywhere, so
forthcoming releases should tweak this to avoid proposing dumb choices. But the hot
stuff is there!&lt;/p&gt;
&lt;p&gt;Also, a cache has been set on the registry to avoid recomputing possible
components for each context (place in the ui).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Upgraded jQuery and jQuery UI respectively to version 1.4.2 and 1.8. Removed
jquery.autocomplete.js since jQuery UI provides its own autocomplete
plugin. A &lt;tt class="docutils literal"&gt;cwautocomplete&lt;/tt&gt; plugin was added in order to keep widgets
as backward compatible as possible. If you used custom autocomplete feature,
you should take a look at this &lt;a class="reference" href="http://www.learningjquery.com/2010/06/autocomplete-migration-guide"&gt;guide&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;The &lt;cite&gt;RelationFacet&lt;/cite&gt; base class now automatically proposes to search for
entities &lt;strong&gt;without&lt;/strong&gt; the relation if this is allowed by the schema and if there
are some in current results. Example: search for tickets which are not planned in a version.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Data sources have been modeled as CubicWeb entity type &lt;cite&gt;CWSource&lt;/cite&gt;. The
'sources' file is still there but will now only contains definition of the
system source, as well as default manager account login and password. This
implied changes in instance initialization commands, introduction of a new
'add-source' command to cubicweb-ctl, as well as change in the repository
startup. Also, on a multi-sources instance, we can now search using a facet on
the &lt;cite&gt;cw_source&lt;/cite&gt; relation (a new mandatory metadata relation on each entities)
to filter according to the data source entities are coming from.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Although introduced during 3.9 releases, it's worth mentioning the new support
for multi-columns unicity constraint through yams's &lt;cite&gt;__unique_together__&lt;/cite&gt;
entity type attribute, allowing for unicity constraint enforced by the
underlying database instead of CubicWeb hooks. This is limited and doesn't
work in every configuration, but is a must have when running several distributed
CubicWeb instance of the same application (hence database).&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Also as usual, the 3.10 includes a bunch of other minor enhancements, refactorings
and bug fixes. Every introduced change should be backward compatible, except
probably some minor ui details due to the css box simplification. That's it.&lt;/p&gt;
&lt;p&gt;So please download and install CubicWeb 3.10 and report us any problem on the
mailing-list!&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;
</description>
  <dc:date>2010-10-20T16:39-01:00</dc:date>
  <dc:creator>Sylvain Thenault</dc:creator>
<feedburner:origLink>http://www.cubicweb.org/blogentry/1330518</feedburner:origLink></item>
  </channel>
</rss>

