c-c create stopped asking if anonymous access should be activated
introduced by 2654:6512522860aa, close #469418
Generic behaviour of WebCreateHandler should be kept for
twisted and all-in-one configurations.
.. -*- coding: utf-8 -*-.._Concepts:The Core Concepts of CubicWeb=============================This section defines some terms and core concepts of the *CubicWeb*framework. To avoid confusion while reading this book, take time to go throughthe following definitions and use this section as a reference during yourreading..._Cube:Cubes-----A cube is a software component made of three parts: its data model(:file:`schema`), its logic (:file:`entities`) and its user interface(:file:`views`).A cube can use other cubes as building blocks and assemble them to providea whole with richer functionnalities than its parts. The cubes `cubicweb-blog`_and `cubicweb-comment`_ could be used to make a cube named *myblog* withcommentable blog entries.The `CubicWeb Forge`_ offers a large number of cubes developed by the communityand available under a free software license.The command ``cubicweb-ctl list`` displays the list of cubes installed on yoursystem.On a Unix system, the available cubes are usually stored in the directory:file:`/usr/share/cubicweb/cubes`. During development, the cubes are commonlyfound in the directory :file:`/path/to/cubicweb_forest/cubes`. The environmentvariable :envvar:`CW_CUBES_PATH` gives additionnal locations where to search forcubes..._`CubicWeb Forge`: http://www.cubicweb.org/project/.._`cubicweb-blog`: http://www.cubicweb.org/project/cubicweb-blog.._`cubicweb-comment`: http://www.cubicweb.org/project/cubicweb-commentInstances---------An instance is a runnable application installed on a computer and based on acube.The instance directory contains the configuration files. Several instances canbe created and based on the same cube. For exemple, several software forges canbe set up on one computer system based on the `cubicweb-forge`_ cube..._`cubicweb-forge`: http://www.cubicweb.org/project/cubicweb-forgeInstances can be of three different types: all-in-one, web engine or datarepository. For applications that support high traffic, several web (front-end)and data (back-end) instances can be set-up to share the load...image:: ../../images/archi_globale.en.pngThe command ``cubicweb-ctl list`` also displays the list of instancesinstalled on your system.On a Unix system, the instances are usually stored in the directory:file:`/etc/cubicweb.d/`. During development, the :file:`~/etc/cubicweb.d/`directory is looked up, as well as the paths in :envvar:`CW_INSTANCES_DIR`environment variable.The term application is used to refer to "something that should do something as awhole", eg more like a project and so can refer to an instance or to a cube,depending on the context. This book will try to use *application*, *cube* and*instance* as appropriate.Data Repository---------------The data repository [#]_ provides access to one or more data sources (includingSQL databases, LDAP repositories, Mercurial or Subversion version controlsystems, other CubicWeb instance repositories, GAE's DataStore, etc).All interactions with the repository are done using the Relation Query Language(RQL). The repository federates the data sources and hides them from thequerier, which does not realize when a query spans accross several data sourcesand requires running sub-queries and merges to complete.It is common to run the web engine and the repository in the same process (seeinstances of type all-in-one above), but this is not a requirement. A repositorycan be set up to be accessed remotely using Pyro (`Python Remote Objects`_) andact as a server.Some logic can be attached to events that happen in the repository, likecreation of entities, deletion of relations, etc. This is used for example tosend email notifications when the state of an object changes. See `Hooks` below..._[#]: not to be confused with a Mercurial repository or a Debian repository..._`Python Remote Objects`: http://pyro.sourceforge.net/Web Engine----------The web engine replies to http requests and runs the user interfaceand most of the application logic.By default the web engine provides a default user interface based onthe data model of the instance. Entities can be created, displayed,updated and deleted. As the default user interface is not very fancy,it is usually necessary to develop your own.Schema (Data Model)-------------------The data model of a cube is described as an entity-relationship schema using acomprehensive language made of Python classes imported from the yams_ library..._yams: http://www.logilab.org/project/yams/An `entity type` defines a set of attributes and is used in some relations.Attributes may be of the following types: `String`, `Int`, `Float`, `Boolean`,`Date`, `Time`, `Datetime`, `Interval`, `Password`, `Bytes`, `RichString`. See:ref:`yams.BASE_TYPES` for details.A `relation type` is used to define an oriented binary relation between twoentity types. The left-hand part of a relation is named the `subject` and theright-hand part is named the `object`.A `relation definition` is a triple (*subject entity type*, *relation type*, *objectentity type*) associated with a set of properties such as cardinality,constraints, etc.Permissions can be set on entity types and relation types to control who will beable to create, read, update or delete entities and relations.Some meta-data necessary to the system is added to the data model. That includesentities like users and groups, the entities used to store the data modelitself and attributes like unique identifier, creation date, creator, etc.When you create a new *CubicWeb* instance, the schema is stored in the database.When the cubes the instance is based on evolve, they may change their data modeland provide migration scripts that will be executed when the administrator willrun the upgrade process for the instance.Registries and Objects----------------------Application objects~~~~~~~~~~~~~~~~~~~Beside a few core functionalities, almost every feature of the framework isachieved by dynamic objects (`application objects` or `appobjects`) stored in atwo-levels registry (the `vregistry`). Each object is affected to a registry withan identifier in this registry. You may have more than one object sharing anidentifier in the same registry, At runtime, appobjects are selected in thevregistry according to the context.Application objects are stored in the registry using a two-level hierarchy : object's `__registry__` : object's `id` : [list of app objects]The base class of appobjects is `AppObject` (module `cubicweb.appobject`).The `vregistry`~~~~~~~~~~~~~~~At startup, the `registry` inspects a number of directories lookingfor compatible classes definition. After a recording process, theobjects are assigned to registers so that they can be selecteddynamically while the instance is running.Selectors~~~~~~~~~Each appobject has a selector, that is used to compute how well the object fitsa given context. The better the object fits the context, the higher the score.CubicWeb provides a set of basic selectors that may be parametrized. Selectorscan be combined with the binary operators `&` and `|` to build more complexselector that can be combined too.There are three common ways to retrieve some appobject from the repository:* get the most appropriate objects by specifying a registry and an identifier. In that case, the object with the greatest score is selected. There should always be a single appobject with a greater score than others.* get all appobjects applying to a context by specifying a registry. In that case, every object with the a postive score is selected.* get the object within a particular registry/identifier. In that case no selection process is involved, the vregistry will expect to find a single object in that cell.Selector sets are the glue that tie views to the data model. Using themappropriately is an essential part of the construction of well behaved cubes.When no score is higher than the others, an exception is raised in developmentmode to let you know that the engine was not able to identify the view toapply. This error is silenced in production mode and one of the objects with thehigher score is picked.If no object has a positive score, ``NoSelectableObject`` exception is raised.If no object is found for a particular registry and identifier,``ObjectNotFound`` exception is raised.In such cases you would need to review your design and make sure your views areproperly defined.The RQL query language----------------------**No need for a complicated ORM when you have a powerful query language**All the persistent data in a CubicWeb instance is retrieved and modified by using theRelation Query Language.This query language is inspired by SQL but is on a higher level in order toemphasize browsing relations.db-api~~~~~~The repository exposes a `db-api`_ like api but using the RQL instead of SQL.XXX feed meResult set~~~~~~~~~~Every request made (using RQL) to the data repository returns anobject we call a Result Set. It enables easy use of the retrieveddata, providing a translation layer between the backend's nativedatatypes and *CubicWeb* schema's EntityTypes.Result sets provide access to the raw data, yielding either basicPython data types, or schema-defined high-level entities, in astraightforward way.Views-----** *CubicWeb* is data driven **The view system is loosely coupled to data through a selectionsystem. Views are, in essence, defined by an id, a selection predicateand an entry point (generaly producing html).XXX feed me.Hooks-----** *CubicWeb* provides an extensible data repository **The data model defined using Yams types allows to express the datamodel in a comfortable way. However several aspects of the data modelcan not be expressed there. For instance:* managing computed attributes* enforcing complicated structural invariants* real-world side-effects linked to data events (email notification being a prime example)The hook system is much like the triggers of an SQL database engine,except that:* it is not limited to one specific SQL backend (every one of them having an idiomatic way to encode triggers), nor to SQL backends at all (think about LDAP or a Subversion repository)* it is well-coupled to the rest of the frameworkHooks are basically functions that dispatch on both:* events : after/before add/update/delete on entities/relations* entity or relation typesThey are an essential building block of any moderately complicatedcubicweb application.