|
blog entries created by Sylvain Thenault
CubicWeb 3.15 introduces a bunch of new functionalities. In short (more details below):
- ability to use ZMQ instead of Pyro to connect to repositories
- ZMQ inter-instances messages bus
- new LDAP source using the datafeed approach, much more flexible than the legacy 'ldapuser' source
- full undo support
Plus some refactorings regarding Ajax function calls, WSGI, the registry, etc. Read more for the detail.
- Add ZMQ server, based on the cutting edge ZMQ socket
library. This allows to access distant instances, in a similar way as Pyro.
- Publish/subscribe mechanism using ZMQ for communication among cubicweb
instances. The new zmq-address-sub and zmq-address-pub configuration variables
define where this communication occurs. As of this release this mechanism is
used for entity cache invalidation.
- Improved WSGI support. While there are still some caveats, most of the code
which was twisted only is now generic and allows related functionalities to work
with a WSGI front-end.
- Full undo/transaction support: undo of modifications has finally been
implemented, and the configuration simplified (basically you activate it or not
on an instance basis).
- Controlling HTTP status code returns is now much easier:
- WebRequest now has a status_out attribute to control the response status ;
- most web-side exceptions take an optional status argument.
The base registry implementation has been moved to a new
logilab.common.registry module (see #1916014). This includes code from :
- cubicweb.vreg (everything that was in there)
- cw.appobject (base selectors and all).
In the process, some renaming was done:
- the top level registry is now RegistryStore (was VRegistry), but that
should not impact CubicWeb client code;
- former selectors functions are now known as "predicate", though you still use
predicates to build an object'selector;
- for consistency, the objectify_selector decorator has hence been renamed to
objectify_predicate;
- on the CubicWeb side, the selectors module has been renamed to
predicates.
Debugging refactoring dropped the need for the lltrace decorator. There
should be full backward compat with proper deprecation warnings. Notice the
yes predicate and objectify_predicate decorator, as well as the
traced_selection function should now be imported from the
logilab.common.registry module.
All login forms are now submitted to <app_root>/login. Redirection to requested
page is now handled by the login controller (it was previously handled by the
session manager).
Publisher.publish has been renamed to Publisher.handle_request. This
method now contains a generic version of the logic previously handled by
Twisted. Controller.publish is not affected.
- New 'ldapfeed' source type, designed to replace 'ldapuser' source with
data-feed (i.e. copy based) source ideas.
- New 'zmqrql' source type, similar to 'pyrorql' but using ømq instead of Pyro.
- A new registry called 'services' has appeared, where you can register
server-side cubicweb.server.Service child classes. Their call method can be
invoked from a web-side AppObject instance using the new self._cw.call_service
method or a server-side one using self.session.call_service. This is a new
way to call server-side methods, much cleaner than monkey patching the
Repository class, which becomes a deprecated way to perform similar tasks.
- a new ajaxfunction registry now hosts all remote functions (i.e. functions
callable through the asyncRemoteExec JS api). A convenience ajaxfunc
decorator will let you expose your python functions easily without all the
appobject standard boilerplate. Backwards compatibility is preserved.
- the 'json' controller is now deprecated in favor of the 'ajax' one.
- WebRequest.build_url can now take a __secure__ argument. When True, cubicweb
tries to generate an https url.
A new 'undohistory' view exposes the undoable transactions and gives access to undo
some of them.
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.
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 :
- Fix some bad old design.
- 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).
- If there is a best way to do something, just do it and refrain from providing configurability and options.
First, a few simple things could be done to simplify the UI code:
- drop xhtml support: always return text/html content type, stop bothering
with this stillborn stuff and use html5
- move away everything that should not be in the framework: calendar?, embedding,
igeocodable, isioc, massmailing, owl?, rdf?, timeline, timetable?, treeview?,
vcard, wdoc?, xbel, xmlrss?
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).
At a first glance, we should start with the following core cubes:
- corelayout, the default interface layout and generic components. Modules to
backport there: application (not an appobject yet), basetemplates, error,
boxes, basecomponents, facets, ibreadcrumbs, navigation, undohistory.
- coreviews, 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.
- corebackoffice, 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.
- coreservices, 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.
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 cubicweb.web packages may be moved
to the relevant cube.
Each cube should provide an interface so that one could replace it with another
one. For instance, move from the default coreviews and corelayout 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 Orbui 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.
Regarding current implementation, we should take care that Contextual components
are a powerful way to build "pluggable" UI, but we should probably add an
intermediate layer that would make more obvious / explicit:
- what the available components are
- what the available slots are
- which component should go in which slot when possible
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.
The current looping task / repo thread mecanism is used for various sort of
things and has several problems:
- 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);
- tasks is a repository only api but we also need web-side tasks;
- there is probably some abuse of the system that may lead to unnecessary
resources usage.
Analyzing a sample http://www.logilab.org/ instance, below are the running looping
task by categories. Tasks that have to run on each web instance:
- clean_sessions, automatically closes unused repository sessions. Notice
cw.etwist.server 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).
- regular_preview_dir_cleanup (preview 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.
Tasks that should run on a single instance:
- update_feeds, update copy based sources (e.g. datafeed, ldapfeed). Controlled
by 'synchronize' source configuration (persistent source attribute that may be
overridden by instance using CWSourceHostConfig entities)
- expire_dataimports, delete CWDataImport entities older than an amount of
time specified in the 'logs-lifetime' configuration option. Not controlled
yet.
- cleanup_auth_cookies (rememberme cube), delete CWAuthCookie entities
whose life-time is exhausted. Not controlled yet.
- cleaning_revocation_key (forgotpwd cube), delete Fpasswd entities with
past revocation_date. Not controlled yet.
- cleanup_plans (narval cube), delete Plan 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.
- refresh_local_repo_caches (vcsfile cube), pull or clone vcs repositories
cache if the Repository 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.
Some deeper thinking is needed here so we can improve things. That includes
thinking about:
- the inter-instances messages bus based on zmq and introduced in 3.15,
- the Celery project (http://celeryproject.org/), an asynchronous task queue,
widely used and written in Python,
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).
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:
- shared_dir returns the cubicweb.web package path instead of the path to the
shared cube,
- i18n_lib_dir returns the cubicweb/i18n directory path instead of the path to the
shared/i18n cube,
- migration_scripts_dir returns the cubicweb/misc/migration directory path
instead of share/cubicweb/migration.
Moving web related objects as proposed in the Bootstrap section would resolve the
problem for the content web/data and most of i18n (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 cubicweb/schemas and
cubicweb/misc/migration to a cube (though only a small benefit is to be expected
here).
We should also have fewer environment variables... Let's see what we have today:
- CW_INSTANCES_DIR, where to look for instances configuration
- CW_INSTANCES_DATA_DIR, where to look for instances persistent data files
- CW_RUNTIME_DIR, where to look for instances run-time data files
- CW_MODE, set to 'system' or 'user' will predefine above environment variables differently
- CW_CUBES_PATH, additional directories where to look for cubes
- CW_CUBES_DIR, location of the system 'cubes' directory
- CW_INSTALL_PREFIX, installation prefix, from which we can compute path to 'etc', 'var', 'share', etc.
I would propose the following changes:
- 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;
- CW_INSTANCES_DATA_DIR and CW_RUNTIME_DIR are replaced by configuration file
options, with smart values generated at instance creation time;
- the above change should make CW_MODE useless;
- CW_CUBES_DIR is to be dropped, CW_CUBES_PATH should be enough;
- 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.
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:
- one configuration file per instance, with all options provided by installed
parts of the framework used by the application.
- activate 'services' (or not): web server, repository, zmq server, pyro
server. Default services to be started are stored in the configuration file.
There is probably more that can be done here (less configuration options?), but
that would already be a great step forward.
The following projects should be investigated to see if we could benefit from them:
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).
Please provide feedbacks:
- do you think choices proposed above are good/bad choices? Why?
- do you know some additional libraries that should be investigated?
- do you have other changes in mind that could/should be done in cw 4.0?
CubicWeb 3.13 has been developed for a while and includes some cool
stuff:
- 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
- major facet enhancements:
- nicer layout and visual feedback when filtering is in-progress
- new RQLPathFacet to easily express new filters that are more than one hop
away from the filtered entities
- a more flexibile API, usable in cases where it wasn't previously possible
- some form handling refactorings and cleanups, notably introduction of a new
method to process posted content, and updated documentation
- support for new base types : BigInt, TZDateTime and TZTime (in 3.12 actually for those two)
- 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
- datafeed source and default CubicWeb xml parsers:
- refactored into smaller and overridable chunks
- easier to configure
- make it work
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!
Enjoy!
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!
'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.
A new 'datafeed' source was introduced, inspired by the soon to be
deprecated datafeed cube. It needs polishing but sets the foundation for
advanced semantic web applications that import content from others site
using simple http request.
A 'datafeed' source is associated to a parser 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.
A new facet to filter entities based on the source they came from is now
available.
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.
The default 'index' / 'manage' view has been simplified to deprecate features
that rely on external folder and card cubes. That's almost the only
deprecation warning you'll get in upgrading to 3.11. Just this one won't
hurt!
The old_calendar module has been dropped in favor of
jQuery's fullcalendar powered views. That's a great news for applications
using calendar features. Since it was added to the exising calendar
module, you shouldn't have to change anything to get it working, unless you
were using old_calendar in which case you may have to update a few things.
This work was initiated by our mexican friends from Crealibre.
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!
Enjoy!
We'll now see how to benefit from features introduced in 3.9 and 3.10 releases of CubicWeb
OK... Now our site has its most desired features. But... I would like to make it look
somewhat like my website. It is not www.cubicweb.org after all. Let's tackle this
first!
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 logo.png file into the cube's data
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.
As the location for static resources are cached, you'll have to restart
your instance for this to be taken into account.
Though there are some cases where you don't want to use a logo.png file.
For instance if it's a JPEG file. You can still change the logo by defining in
the cube's uiprops.py file:
The uiprops machinery has been introduced in CubicWeb 3.9. 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).
This file is imported specifically by CubicWeb, with a predefined name space,
containing for instance the data function, telling the file is somewhere
in a cube or CubicWeb's data directory.
One side effect of this is that it can't be imported as a regular python
module.
The nice thing is that in debug mode, change to a uiprops.py file are detected
and then automatically reloaded.
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 here.
All I've to do is to override some stuff of the default CubicWeb user interface to
apply it as explained.
The first thing to to get the <img/> tag as first element after the
<body> 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
HTMLPageHeader view, since that's the one that is directly called once
the <body> has been written. How did I find this? By looking in the
cubiweb.web.views.basetemplates module, since I know that global page
layouts sits there. I could also have grep the "body" tag in
cubicweb.web.views... Finding this was the hardest part. Now all I need is
to customize it to write that img tag, as below:
class HTMLPageHeader(basetemplates.HTMLPageHeader):
# override this since it's the easier way to have our bg image
# as the first element following <body>
def call(self, **kwargs):
self.w(u'<img id="bg-image" src="%sbackground.jpg" alt="background image"/>'
% self._cw.datadir_url)
super(HTMLPageHeader, self).call(**kwargs)
def registration_callback(vreg):
vreg.register_all(globals().values(), __name__, (HTMLPageHeader))
vreg.register_and_replace(HTMLPageHeader, basetemplates.HTMLPageHeader)
As you may have guessed, my background image is in a background.jpg file
in the cube's data directory, but there are still some things to explain
to newcomers here:
- The call method is there the main access point of the view. It's called by
the view's render method. It is not the only access point for a view, but
this will be detailed later.
- Calling self.w writes something to the output stream. Except for binary views
(which do not generate text), it must be passed an Unicode string.
- The proper way to get a file in data directory is to use the datadir_url
attribute of the incoming request (e.g. self._cw).
I won't explain again the registration_callback stuff, you should understand it
now! If not, go back to previous posts in the series :)
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 cubes.sytweb.css
file, stored as usual in our data directory:
/* fixed full screen background image
* as explained on http://webdesign.about.com/od/css3/f/blfaqbgsize.htm
*
* syt update: set z-index=0 on the img instead of z-index=1 on div#page & co to
* avoid pb with the user actions menu
*/
img#bg-image {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
div#page, table#header, div#footer {
background: transparent;
position: relative;
}
/* add some space around the logo
*/
img#logo {
padding: 5px 15px 0px 15px;
}
/* more dark font for metadata to have a chance to see them with the background
* image
*/
div.metadata {
color: black;
}
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:
- a bit of padding around the logo
- darker metadata which appears by default below the content (the white frame in the page)
To get this CSS file used everywhere in the site, I have to modify the uiprops.py file
introduced above:
STYLESHEETS = sheet['STYLESHEETS'] + [data('cubes.sytweb.css')]
sheet is another predefined variable containing values defined by
already process uiprops.py file, notably the CubicWeb's one.
Here we simply want our CSS in addition to CubicWeb's base CSS files, so we
redefine the STYLESHEETS variable to existing CSS (accessed through the sheet
variable) with our one added. I could also have done:
sheet['STYLESHEETS'].append(data('cubes.sytweb.css'))
But this is less interesting since we don't see the overriding mechanism...
At this point, the site should start looking good, the background image being
resized to fit the screen.
The final touch: let's customize CubicWeb's CSS to get less orange... By simply adding
contextualBoxTitleBg = incontextBoxTitleBg = '#AAAAAA'
and reloading the page we've just seen, we know have a nice greyed box instead of
the orange one:
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 background property of boxes with CSS class
contextualBoxTitleBg and incontextBoxTitleBg.
Boxes present to the user some ways to use the application. Let's first do a few
user interface tweaks in our views.py file:
from cubicweb.selectors import none_rset
from cubicweb.web.views import bookmark
from cubes.zone import views as zone
from cubes.tag import views as tag
# change bookmarks box selector so it's only displayed on startup views
bookmark.BookmarksBox.__select__ = bookmark.BookmarksBox.__select__ & none_rset()
# move zone box to the left instead of in the context frame and tweak its order
zone.ZoneBox.context = 'left'
zone.ZoneBox.order = 100
# move tags box to the left instead of in the context frame and tweak its order
tag.TagsBox.context = 'left'
tag.TagsBox.order = 102
# hide similarity box, not interested
tag.SimilarityBox.visible = False
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 Person displayed_on File relation. We can do this simply by adding a
AjaxEditRelationCtxComponent subclass to our views, as below:
from logilab.common.decorators import monkeypatch
from cubicweb import ValidationError
from cubicweb.web import uicfg, component
from cubicweb.web.views import basecontrollers
# hide displayed_on relation using uicfg since it will be displayed by the box below
uicfg.primaryview_section.tag_object_of(('*', 'displayed_on', '*'), 'hidden')
class PersonBox(component.AjaxEditRelationCtxComponent):
__regid__ = 'sytweb.displayed-on-box'
# box position
order = 101
context = 'left'
# define relation to be handled
rtype = 'displayed_on'
role = 'object'
target_etype = 'Person'
# messages
added_msg = _('person has been added')
removed_msg = _('person has been removed')
# bind to js_* methods of the json controller
fname_vocabulary = 'unrelated_persons'
fname_validate = 'link_to_person'
fname_remove = 'unlink_person'
@monkeypatch(basecontrollers.JSonController)
@basecontrollers.jsonize
def js_unrelated_persons(self, eid):
"""return tag unrelated to an entity"""
rql = "Any F + ' ' + S WHERE P surname S, P firstname F, X eid %(x)s, NOT P displayed_on X"
return [name for (name,) in self._cw.execute(rql, {'x' : eid})]
@monkeypatch(basecontrollers.JSonController)
def js_link_to_person(self, eid, people):
req = self._cw
for name in people:
name = name.strip().title()
if not name:
continue
try:
firstname, surname = name.split(None, 1)
except:
raise ValidationError(eid, {('displayed_on', 'object'): 'provide <first name> <surname>'})
rset = req.execute('Person P WHERE '
'P firstname %(firstname)s, P surname %(surname)s',
locals())
if rset:
person = rset.get_entity(0, 0)
else:
person = req.create_entity('Person', firstname=firstname,
surname=surname)
req.execute('SET P displayed_on X WHERE '
'P eid %(p)s, X eid %(x)s, NOT P displayed_on X',
{'p': person.eid, 'x' : eid})
@monkeypatch(basecontrollers.JSonController)
def js_unlink_person(self, eid, personeid):
self._cw.execute('DELETE P displayed_on X WHERE P eid %(p)s, X eid %(x)s',
{'p': personeid, 'x': eid})
You basically subclass to configure with some class attributes. The fname_*
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 js_
prefix and are added to the controller using the @monkeypatch 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 "firstname surname".
Let's see how it looks like on a file primary view:
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.
The ui component system has been refactored in CubicWeb 3.10, which also
introduced the AjaxEditRelationCtxComponent class.
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
cubicweb.web.facet 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
RelationFacet.
Since that's ui stuff, we'll continue to add code below to our
views.py 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 view
package. In our case of a simple application (glue) cube, we could start using
for instance the layout below:
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
from cubicweb.web import facet
class DisplayedOnFacet(facet.RelationFacet):
__regid__ = 'displayed_on-facet'
# relation to be displayed
rtype = 'displayed_on'
role = 'object'
# view to use to display persons
label_vid = 'combobox'
Let's say we also want to filter according to the visibility attribute. This is
even simpler as we just have to derive from the AttributeFacet class:
class VisibilityFacet(facet.AttributeFacet):
__regid__ = 'visibility-facet'
rtype = 'visibility'
Now if I search for some pictures on my site, I get the following facets available:
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 created_by facet if the same user has created all
entities). This may explain why you don't see yours...
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.
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...
Almost everything is in the title: we'll hold a CubicWeb sprint in our Paris office after the first French Semantic Web conference, so on 19, 20 and 21 of january 2011.
The main topic will be to enhance newcomers experience in installing and using CubicWeb.
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 contact us so we can check there is still some room available.
photo by Sebastian Mary under creative commons licence.
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.
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:
- entities do not inherit from dict anymore; access to the dict protocol on an
entity will raise deprecation warnings
- the attributes cache is now a cw_attr_cache dictionary on the entity
- edited attributes are in a cw_edited 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 edited_attributes attribute.
Unification of 'boxes' / 'contentnavigation' registries and base classes, into
"contextual components" stored in the 'ctxcomponents' registry. This implied the
introduction of "layout" objects which are appobjects responsible of displaying
the components according to the context they are displayed in.
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!
Also, a cache has been set on the registry to avoid recomputing possible
components for each context (place in the ui).
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 cwautocomplete 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 guide.
The RelationFacet base class now automatically proposes to search for
entities without 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.
Data sources have been modeled as CubicWeb entity type CWSource. 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 cw_source relation (a new mandatory metadata relation on each entities)
to filter according to the data source entities are coming from.
Although introduced during 3.9 releases, it's worth mentioning the new support
for multi-columns unicity constraint through yams's __unique_together__
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).
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.
So please download and install CubicWeb 3.10 and report us any problem on the
mailing-list!
Enjoy!
For that last sprint day, each team made some nice achievements:
- Steph & Alain worked on the mv/cp actions implementation to makes
them working properly and supporting globs. Last but not least, with
a full set of tests.
- Alex & Charles got back what we call apycot 'full' tests, eg running
test with coverage enabled, checking that code coverage is greater
than a given threshold, but also running pylint and checking that
its global evaluation is at least 7 (configurable, of course).
- Katia & Aurélien provided a sharp implementation of recipe checking,
so that we know we don't launch a recipe badly constructed, as well
as informing the user nicely from what errors his recipe suffer.
- Julien managed to set up a recipe managing from Debian package
construction to Debian repository publication, going through lintian
on the way
- Pierre-Yves helped other teams to solve the narval related bugs
they encountered, and finished by writing a thread-safe implementation
of apycot's writer so we can run several checker simultaneously.
- Celso continued working on a proof of concept blue-theme cube,
wondering how to make CubicWeb looks nicer and be easily customisable
in future versions.
- Sylvain helped there and there and integrated patches...
So we finally didn't get up to the demo. But we now have everything to
set it up, so I've a good hope that we will have a beta version of our
brand new production chain up and running before the end of August!
Thanks to everyone for all this good work, and for this time spent all together!
We started this first day by several presentations by Sylvain about Logilab's current development process workflow, and compared it to what it should be after the sprint. Sylvain also introduced Narval.
We then set up a dev environment on everyone's computer: a working forge with a local Narval agent that can be used for tests during the week.
Regarding more concrete tasks:
- Charles and Alexandre started writing some basic Narval actions such as move, to move a file from a place to another, and had to grasp narval's concepts on the way.
- Pierre-Yves dug into the code to understand how exceptions are propagated in the Narval engine, his goal was to get better reports.
- Stéphanie and Alain worked on a nice bot status view.
- Katia, Aurélien studied the new mercurial cache solution for vcsfile
- Julien started some piece of documentation.
- Celso, our Mexican friend, discovered some new features of recent cubicweb releases and setup his environment to later work on Spanish translation, CSS, etc.
- Sylvain came with a basically working narval implementation on top of cubicweb, and spent the day helping various people...
Although this week is normally the regular annual holidays here at Logilab, some of us will sprint in Paris exceptionally.
We're starting this week with an exciting goal: integrating all our release
process into our continuous integration suite (through the apycot cube).
Including Debian repository management, pypi registration, etc...
The hot stuff to achieve this is the third resurrection of Narval, the project
Logilab was originaly based on, but this time it is built on top of
CubicWeb framework. Narval will be used to rewrite
some parts of apycot, in order to make it more flexible and powerful.
It is not just a refactoring or a simple upgrade!
We hope to automate common tasks, simplify maintenance, and thus
enhance release quality, but also gain a lot of functionality in near future.
- merge Apycotbot process manager into a new Narval incarnation, and rewrite
it as Narval actions and recipes
- improve vcsfile cube with a new cache system for mercurial
- define Logilab's release process as new Narval recipes, triggered by actions
such as adding release tag into the source repository
More detailed stuff will come with the sprint reports that we'll try to issue each day.
|