Script Guide¶
pfpopulate¶
After a fresh installation, pfpopulate is used to populate database and retrieve content from repositories.
Usage¶
(virtualenv)$ pfpopulate [options] <ini_file> [<file> <file>...]
Available options are:
--help
: display help and stop.--drop-tables
: drop existing tables before repopulating.--no-pull
: do not synchronize storages.--reset-index
: delete storage indexes.--no-index
: do not index storages.--log-level=LOGLEVEL
: set log level. Available values are:DEBUG
,INFO
,WARNING
,ERROR
orCRITICAL
. The default isINFO
.
Examples¶
Just after installing your instance, in development mode:
(virtualenv)$ pfpopulate development.ini
Drop tables and populate database again:
(virtualenv)$ pfpopulate --drop-tables development.ini
Populate database with exported XML files:
(virtualenv)$ pfpopulate production.ini users.pfusr.xml
Use a special [app:Foo]
section:
(virtualenv)$ pfpopulate development.ini#Foo
XML Configuration Files¶
pfpopulate reads INI file and fills database according to Populate
section (See [Populate] Section). It is based on an
administrator definition and XML configuration files.
XML configuration files are also used in import/export operations.
A XML configuration file can contain:
- one item, for instance a user defined by
<user>
tag ; - several items of the same type, for instance users defined by a tag
<users>
containing<user>
tags ; - or an entire configuration, with, in this order,
<users>
,<groups>
,<storages>
and<projects>
.
Users¶
<?xml version="1.0" encoding="utf-8"?>
<publiforge version="1.0">
<users>
<!-- ================================================================== -->
<user login="user1">
<password>user1sesame</password>
<name>Marc HINDÉLAIBILE</name>
<email>user1@prismallia.fr</email>
<language>fr</language>
<home>projects</home>
<page_size>5</page_size>
<permissions>
<permission scope="all">manager</permission>
</permissions>
</user>
<!-- ================================================================== -->
<user login="user2">
<password>user2sesame</password>
<name>Luc SAMBOUR</name>
<email>user2@prismallia.fr</email>
<language>fr</language>
<home>storages</home>
</user>
<!-- ================================================================== -->
<user login="user3">
<password>user3sesame</password>
<name>Anne HORAQUE</name>
<email>user3@prismallia.fr</email>
<language>fr</language>
</user>
<!-- ================================================================== -->
<user login="user4">
<password>user4sesame</password>
<name>Captain O'CLOCK</name>
<email>user4@prismallia.fr</email>
</user>
<!-- ================================================================== -->
<user login="test1" status="inactive">
<password>test1sesame</password>
<name>Édith AVULEUR</name>
<email>test1@prismallia.fr</email>
<expiration>2011-12-01</expiration>
<ips>
<ip>10.0.0.1</ip>
<ip>10.0.1.1</ip>
</ips>
</user>
</users>
</publiforge>
Required elements are login
attribute and <name>
and <email>
tags.
Other available elements are:
status
:<user>
attribute ; available values areactive
(default),draft
andinactive
<password>
: clear password<language>
: a ISO 639 value ; the default value if the value ofdefault_locale_name
option of[app:PubliForge]
section<page_size>
: items per page in lists ; default value is 20<home>
: available values areprojects
(default) andstorages
<expiration>
: an ISO date for account expiration<ips>
: tag containing<ip>
tags to restrict access<permissions>
: tag containing<permission>
tags ; it defines permission groups (see Permissions)
Groups¶
<?xml version="1.0" encoding="utf-8"?>
<publiforge version="1.0">
<groups>
<!-- ================================================================== -->
<group xml:id="managers">
<label>Managers</label>
<description>
Managers can create, destroy and modify different elements of the site.
</description>
<permissions>
<permission scope="all">manager</permission>
</permissions>
</group>
<!-- ================================================================== -->
<group xml:id="editors">
<label>Editors</label>
<description>
Editors can modify different elements of the site.
</description>
<permissions>
<permission scope="doc">editor</permission>
<permission scope="usr">editor</permission>
<permission scope="grp">editor</permission>
<permission scope="stg">editor</permission>
<permission scope="prj">editor</permission>
</permissions>
<members>
<member>user2</member>
</members>
</group>
<!-- ================================================================== -->
<group xml:id="users">
<label>Users</label>
<permissions>
<permission scope="all">user</permission>
</permissions>
<members>
<member>user3</member>
</members>
</group>
<!-- ================================================================== -->
<group xml:id="storage_users">
<label>Users of storage</label>
<description>
Members of this group can browse storages which accept this group.
</description>
<permissions>
<permission scope="stg">user</permission>
</permissions>
<members>
<member>user4</member>
</members>
</group>
</groups>
</publiforge>
For <group>
, attribute xml:id
is required as well as the <label>
tag.
Other available elements are:
<description>
: a short description (< 255 characters) of the group<permissions>
: tag containing<permission>
tags ; it defines permission groups (see Permissions)<members>
: tag containing<member>
tags. Each<member>
tag contains a user who belongs to this group.
Storages¶
<?xml version="1.0" encoding="utf-8"?>
<publiforge version="1.0">
<storages>
<!-- ================================================================== -->
<storage xml:id="Result">
<label>Results</label>
<vcs type="none">
<public>ftp://data.publiforge.org/Results</public>
</vcs>
<reset>true</reset>
<members>
<member in-menu="true">user1</member>
<member in-menu="true">user2</member>
</members>
</storage>
<!-- ================================================================== -->
<storage xml:id="DataLocal">
<label>Data</label>
<description>
Local Mercurial Version Control System manages this storage.
</description>
<vcs type="local">
<public>https://storages.publiforge.org/DataLocal</public>
</vcs>
<access>restricted</access>
<members>
<member in-menu="true" permission="editor">user1</member>
</members>
</storage>
<!-- ================================================================== -->
<storage xml:id="DataHg">
<label>Remote repository</label>
<description>
This storage is linked to a Mercurial repository.
</description>
<vcs type="hg">
<url>https://hgpub.prismallia.fr/DataHg</url>
<user>publiforge</user>
<password>sesame</password>
</vcs>
<access>restricted</access>
<refresh>300</refresh>
<indexed>\.(txt|ini|rst|xml)$</indexed>
<members>
<member in-menu="true">user1</member>
<member in-menu="true">user2</member>
<member in-menu="true" permission="editor">user3</member>
<member-group>storage_users</member-group>
</members>
</storage>
</storages>
</publiforge>
Required elements for <storage>
are:
- attribute
xml:id
: storage ID <label>
: storage label<vcs>
: Version Control System engine
Other available elements are:
<description>
: a short description (< 255 characters) of the storage.<access>
: the kind of access amongopen
,restricted
andclosed
. default isopen
.<reset>
: iftrue
, the storage is cleaned at eachpfpopulate
execution.<refresh>
: delay to synchronize repository with its referencial.<indexed>
: a regular expression to select files to index.<members>
: tag containing<member>
or<member-group>
tags. Each<member>
or<member-group>
tag contains a user who can access this storage. Attributepermission
defines a permission access amongeditor
oruser
(default). You can add ain-menu
attribute to<member>
tag to put this storage in main menu.
Indexers¶
<?xml version="1.0" encoding="utf-8"?>
<publiforge version="1.0">
<indexers>
<!-- ================================================================== -->
<indexer id="title" value="string">
<label xml:lang="en">Document title</label>
<label xml:lang="fr">Titre du document</label>
<extractors>
<extractor type="xpath">
<indexed>\.xml$</indexed>
<parameter>/*/*/head/title</parameter>
</extractor>
</extractors>
</indexer>
<!-- ================================================================== -->
<indexer id="extract" value="string">
<label xml:lang="en">Extract</label>
<label xml:lang="fr">Extrait</label>
<extractors>
<extractor type="regex">
<indexed>\.(txt|ini|rst)$</indexed>
<parameter limit="150">.*</parameter>
</extractor>
<extractor type="xpath">
<indexed>\.xml$</indexed>
<parameter limit="150">//p|//caption</parameter>
</extractor>
</extractors>
</indexer>
<!-- ================================================================== -->
<indexer id="keyword" value="string">
<label xml:lang="en">Keywords</label>
<label xml:lang="fr">Mots clés</label>
<extractors>
<extractor type="xpath">
<indexed>\.xml$</indexed>
<parameter>//keyword</parameter>
</extractor>
</extractors>
</indexer>
<!-- ================================================================== -->
<indexer id="date" value="string">
<label xml:lang="en">Date</label>
<label xml:lang="fr">Date</label>
<extractors>
<extractor type="xpath">
<indexed>\.xml$</indexed>
<parameter>/*/*/date/@value</parameter>
</extractor>
</extractors>
</indexer>
<!-- ================================================================== -->
<indexer id="content" value="string">
<label xml:lang="en">Words of text</label>
<label xml:lang="fr">Mots du texte</label>
<extractors>
<extractor type="regex">
<indexed>\.(txt|ini|rst)$</indexed>
<parameter>.*</parameter>
</extractor>
<extractor type="xpath">
<indexed>\.xml$</indexed>
<parameter>//section//text()</parameter>
</extractor>
</extractors>
</indexer>
</indexers>
</publiforge>
Required elements for <indexer>
are:
- attribute
id
: indexer ID <label>
: indexer labels in several languages<extractors>
: list of extractors to extract content from files
Each extractor has the following required elements:
- attribute
type
: type of extractor amongregex
andxpath
. <indexed>
: a regular expression to select files to process.<parameter>
: parameter for extractor engine. For regex extractor it is a regular expression, for xpath extractor it is a XPath expression. Attribute limit limits the size of indexed text.
Projects¶
<?xml version="1.0" encoding="utf-8"?>
<publiforge version="1.0">
<project status="active">
<label>Documents Publidoc</label>
<description>
Transformations diverses de documents Publidoc.
</description>
<deadline>2013-12-31</deadline>
<!-- ================================================================== -->
<roles>
<role xml:id="author">
<label>Auteur</label>
<description>Rédacteur de fichier XML.</description>
</role>
<role xml:id="illustrator">
<label>Illustrateur</label>
</role>
</roles>
<!-- ================================================================== -->
<processings>
<processing xml:id="prc01">
<label>Transformation en XHTML</label>
<description>
Transformation en XHTML 1.1, compressé dans un ZIP ou non, de
documents Publidoc.
</description>
<processor>Publidoc2XHtml</processor>
<variables>
<var name="subdir"><default></default></var>
<var name="zip" visible="true"/>
<var name="img_optimize">
<value user="user1">0</value>
<value user="user2">2</value>
<default>3</default>
</var>
</variables>
<resources>
<resource>DataHg/Xml/Documents/Images</resource>
<resource>DataHg/Xml/Documents/Audios</resource>
</resources>
<templates>
<template to="RelaxNG">DataHg/RelaxNG</template>
</templates>
<output>Result/XHtml</output>
</processing>
<processing>
<label>Liste des images en CSV</label>
<processor>Publidoc2Csv</processor>
<output>Result/%(user)s/Csv</output>
</processing>
</processings>
<!-- ================================================================== -->
<tasks>
<task xml:id="tsk01">
<label>Création XML</label>
<description>
Créer les nouveaux fichiers XML et les transmettre à la relecture.
</description>
<deadline>2013-12-31</deadline>
<processings>
<processing trigger="manual" ref="prc01"/>
</processings>
<operator type="role">author</operator>
<connections>
<next task="tsk03"/>
</connections>
</task>
<task xml:id="tsk03">
<label>Relecture XML</label>
<description>
Relire le XML et envoyer les demandes de correction à
l'auteur ou valider le lot.
</description>
<processings>
<processing trigger="manual" ref="prc01"/>
</processings>
<operator type="user">user1</operator>
<connections>
<next task="tsk01"/>
<next task="tsk04"/>
</connections>
</task>
<task xml:id="tsk04">
<label>Terminé</label>
<operator type="auto"/>
</task>
</tasks>
<!-- ================================================================== -->
<packs>
<pack>
<label>Documents de test</label>
<files>
<file>DataHg/Xml/Documents/torture_test.xml</file>
<file>DataHg/Xml/Topics/centre_pompidou.xml</file>
<file>DataHg/Xml/Topics/états-unis_les faucons.xml</file>
</files>
<resources>
<resource>DataHg/Xml/Topics/Images</resource>
</resources>
<templates>
<template to="Css/custom.css">DataHg/Css/prismallia.css</template>
</templates>
<events>
<event task="Relecture XML" operator="Marc HINDÉLAIBILE" begin="2012-02-10T18:30:00"/>
<event task="Création XML" operator="Luc SAMBOUR" begin="2012-02-01T10:40:00"/>
<event task="Création XML" operator="[Rôle] Auteur" begin="2012-02-01T08:45:00"/>
</events>
</pack>
<pack recursive="true">
<label>Répertoire de sujets</label>
<files>
<file>DataHg/Xml/Topics</file>
</files>
<resources>
<resource>DataHg/Xml/Topics/Images</resource>
</resources>
<events>
<event task="Création XML" operator="[Rôle] Auteur" begin="2012-02-01T08:45:00"/>
</events>
</pack>
</packs>
<!-- ================================================================== -->
<members>
<member in-menu="true" permission="leader" roles="author">user1</member>
<member in-menu="true" entries="tasks" roles="author">user2</member>
<member in-menu="true" roles="author illustrator">user3</member>
<member-group>project_users</member-group>
<member-group permission="leader">project_leaders</member-group>
<member-group permission="packmaker">project_packmakers</member-group>
<member-group permission="packeditor">project_packeditors</member-group>
<member-group>project_members</member-group>
</members>
</project>
</publiforge>
pfbackup¶
pfbackup is used to backup site into a XML configuration file (See XML Configuration Files).
Usage¶
(virtualenv)$ pfbackup [options] <ini_file> <backup_file>
Available options are:
--help
: display help and stop.--no-users
: do not backup users.--no-groups
: do not backup groups.--no-storages
: do not backup storages.--no-index
: do not backup indexers.--no-project
: do not backup projects.--log-level=LOGLEVEL
: set log level. Available values are:DEBUG
,INFO
,WARNING
,ERROR
orCRITICAL
. The default isINFO
.
Examples¶
Backup the whole site:
(virtualenv)$ pfbackup pfinstance.ini pfinstance.pf.xml
Backup everything except users:
(virtualenv)$ pfbackup pfinstance.ini pfinstance.pf.xml --nousers
Backup projects:
(virtualenv)$ pfbackup pfinstance.ini projects.pfprj.xml --nousers --nogroups --nostorages --no-index