Updated NLTK install and Portlet docs doc-dc
authorDamien Correia
Tue, 15 May 2018 18:31:37 +0200
branchdoc-dc
changeset 56 60a1fbdbbed3
parent 55 949d496c4e96
child 57 e7d62e94392f
child 61 cfb7276fdd33
Updated NLTK install and Portlet docs
src/source/appextend.rst
src/source/conf.py
src/source/developerguide.rst
src/source/extend.rst
src/source/plugins.rst
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/source/appextend.rst	Tue May 15 18:31:37 2018 +0200
@@ -0,0 +1,115 @@
+.. _appextend:
+
+How to create a new Portlet ?
+-----------------------------
+
+**Portlets** are pluggable user interface software components that are managed and displayed in a web portal,
+for example an enterprise portal or a web CMS. A portlet can aggregate (integrate) and personalize content from
+different sources within a web page. A portlet responds to requests from a web client with and generates dynamic content.
+(*reference:* `Wiki portlet`_)
+
+.. _`wiki portlet`: https://en.wikipedia.org/wiki/Portlet
+
+
+**Pyams Portal** provides predefined portlets that to compose and organize the structure of a website.
+
+1. Define a Portlet setting
+'''''''''''''''''''''''''''
+
+Portlet setting interface are defined in ``interfaces.py``, you can use IPortletSettings or extend the interface
+by adding an additional properties for example:
+
+.. code-block:: python
+
+    from zope.schema import Text
+
+    class INewPortletSettings(IPortletSettings):
+
+        comment = Text(title=_("Comment"),
+                   required=True,
+                   default=True)
+
+PortletSetting component does what IPortletSettings describes. This is usually referred to as the implementation
+of IPortletSettings.
+
+.. code-block:: python
+
+    @implementer(IPortletSettings)
+    class ImagePortletSettings(PortletSettings):
+        """Image portlet settings"""
+
+        _image = FileProperty(IImagePortletSettings['image'])
+
+        @property
+        def image(self):
+            return self._image
+
+        @image.setter
+        def image(self, value):
+            self._image = value
+            if (value is not None) and (value is not DELETED_FILE):
+                alsoProvides(self._image, IResponsiveImage)
+
+
+
+2. Create Portlet
+'''''''''''''''''
+
+The Porltet component is a utility, it implement the IPortlet interface and it registered by the portlet_config adapter
+
+To register a new portlet you must specify the settings_class associated
+
+.. code-block:: python
+
+    @portlet_config(permission=VIEW_PERMISSION)
+    class ImagePortlet(Portlet):
+        """Image portlet"""
+
+        name = IMAGE_PORTLET_NAME
+        label = _("Image")
+
+        toolbar_image = None
+        toolbar_css_class = 'fa fa-fw fa-2x fa-picture-o'
+
+        settings_class = ImagePortletSettings
+
+
+
+4. Create HTML template
+'''''''''''''''''''''''
+
+
+.. code-block:: genshi
+
+    <span>${view.settings.comment}</span>
+
+
+
+5. Renderer
+'''''''''''
+
+.. code-block:: python
+
+    @adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IImagePortletSettings), provides=IPortletRenderer)
+    @template_config(template='image.pt', layer=IPyAMSLayer)
+    class ImagePortletRenderer(PortletRenderer):
+        """Image portlet renderer"""
+
+        label = _("Responsive image renderer")
+
+
+
+6. Zmi integration module
+'''''''''''''''''''''''''
+
+.. code-block:: python
+
+    @pagelet_config(name='properties.html', context=IImagePortletSettings, request_type=IPyAMSLayer,
+                    permission=VIEW_SYSTEM_PERMISSION)
+    class ImagePortletSettingsEditor(PortletSettingsEditor):
+        """Image portlet settings editor"""
+
+        settings = IImagePortletSettings
+
+
+
--- a/src/source/conf.py	Wed May 09 17:33:41 2018 +0200
+++ b/src/source/conf.py	Tue May 15 18:31:37 2018 +0200
@@ -107,7 +107,7 @@
 #
 # This is also used if you do content translation via gettext catalogs.
 # Usually you set "language" from the command line for these cases.
-language = None
+language = 'en'
 
 # List of patterns, relative to source directory, that match files and
 # directories to ignore when looking for source files.
@@ -117,10 +117,12 @@
 # The name of the Pygments (syntax highlighting) style to use.
 pygments_style = 'sphinx'
 
+# The default language to highlight source code in.
+highlight_language = 'python3'
+
 # If true, `todo` and `todoList` produce output, else they produce nothing.
 todo_include_todos = False
 
-
 # -- Options for HTML output ----------------------------------------------
 
 # The theme to use for HTML and HTML Help pages.  See the documentation for
@@ -241,5 +243,6 @@
 
 
 def setup(app):
+
     app.add_stylesheet('css/custom.css')
 
--- a/src/source/developerguide.rst	Wed May 09 17:33:41 2018 +0200
+++ b/src/source/developerguide.rst	Tue May 15 18:31:37 2018 +0200
@@ -11,4 +11,8 @@
    :maxdepth: 2
 
    zca
-   extend
+   package_layout
+   appextend
+   zmi_integration
+   traverser
+   tales
--- a/src/source/extend.rst	Wed May 09 17:33:41 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-.. _extending:
-
-Extending PyAMS
-===============
-
-.. toctree::
-   :maxdepth: 2
-
-   package_layout
-   appextend
-   zmi_integration
-   traverser
-   tales
-
-
--- a/src/source/plugins.rst	Wed May 09 17:33:41 2018 +0200
+++ b/src/source/plugins.rst	Tue May 15 18:31:37 2018 +0200
@@ -13,7 +13,7 @@
 Visit  https://www.elastic.co/ to learn how to install Elasticsearch Server, and how install `ingest-attachment` plug-in
 
 
-.. tips:: Documentation for installing ElasticSearch 5.4
+.. tip:: Documentation for installing ElasticSearch 5.4
 
     - https://www.elastic.co/guide/en/elasticsearch/reference/5.4/gs-installation.html
     - https://www.elastic.co/guide/en/elasticsearch/plugins/5.4/ingest-attachment.html
@@ -79,7 +79,7 @@
 3. Create or update index:
 ''''''''''''''''''''''''''
 
-You have to index PyAMS objects into ES database. From a shell:
+You have to Update ElasticSearch indexes with all database contents with ``pymas_es_index``. From a shell:
 
 .. code-block:: bash
 
@@ -93,7 +93,7 @@
 ===============================
 
 
-With the package *PyAMS_nltk* PyAMS can use the NLTK features
+PyAMS enjoy the NLTK features through the *PyAMS_calalog*
 
 .. seealso::
 
@@ -101,12 +101,12 @@
 
 
 
+Initializing NLTK (Natural Language Toolkit)
+--------------------------------------------
 
-Initializing NLTK
------------------
-
-Some NLTK (Natural Language Toolkit) tokenizers and stopwords utilities are used to index fulltext contents elements.
-This package requires downloading and configuration of several elements which are done as follow:
+Some NLTK Collections like **tokenizers** and **stopwords** utilities are used to index fulltext contents
+elements. You can enhanced NTKL indexation according to your own needs. This package requires downloading and
+configuration of several elements which are done as follow:
 
 
 *1. Run the Python shell with PyAMS environment:*
@@ -118,12 +118,24 @@
 
 *2. In the Python shell:*
 
-.. code-block:: python
+.. code-block:: pycon
 
     >>> import nltk
     >>> nltk.download()
 
-.. code-block:: python
+
+*3. Configuration installation directory:*
+
+.. tip::
+
+    On Debian GNU/Linux, you can choose any directory between '*~/nltk_data*' (where '~' is the homedir of user running
+    Pyramid application), '*/usr/share/nltk_data*', '*/usr/local/share/nltk_data*', '*/usr/lib/nltk_data*' and
+    '*/usr/local/lib/nltk_data*'
+
+    Please check if you have permission to write to this directory
+
+
+.. code-block:: shell
 
     NLTK Downloader
     ---------------------------------------------------------------------------
@@ -138,33 +150,44 @@
 
     Local Machine:
       - Data directory: /home/tflorac/nltk_data
-    ---------------------------------------------------------------------------
-        s) Show Config   u) Set Server URL   d) Set Data Dir   m) Main Menu
-    ---------------------------------------------------------------------------
+
     Config> d
       New directory> /usr/local/lib/nltk_data
 
+
+*4. Return to the main menu:*
+
+.. code-block:: shell
+
+        ---------------------------------------------------------------------------
+            s) Show Config   u) Set Server URL   d) Set Data Dir   m) Main Menu
+        ---------------------------------------------------------------------------
+        Config> m
+
+
+*5. Download utilities:*
+
+    punkt
+        Punkt Tokenizer Models
+    stopwords
+        Stopwords Corpus
+
+
+.. code-block:: shell
+
+        ---------------------------------------------------------------------------
+            d) Download   l) List    u) Update   c) Config   h) Help   q) Quit
+        ---------------------------------------------------------------------------
+        Downloader> d
+        Download which package (l=list; x=cancel)?
+          Identifier> punkt
+            Downloading package punkt to /usr/local/lib/nltk_data...
+        Downloader> d
+        Download which package (l=list; x=cancel)?
+          Identifier> stopwords
+            Downloading package stopwords to /usr/local/lib/nltk_data...
+
+
 .. tip::
 
-    On Debian GNU/Linux, you can choose any directory between '*~/nltk_data*' (where '~' is the homedir of user running
-    Pyramid application), '*/usr/share/nltk_data*', '*/usr/local/share/nltk_data*', '*/usr/lib/nltk_data*' and
-    '*/usr/local/lib/nltk_data*'
-
-
-.. code-block:: pycon
-
-    Config> m
-    ---------------------------------------------------------------------------
-        d) Download   l) List    u) Update   c) Config   h) Help   q) Quit
-    ---------------------------------------------------------------------------
-    Downloader> d
-
-    Download which package (l=list; x=cancel)?
-      Identifier> punkt
-        Downloading package punkt to /usr/local/lib/nltk_data...
-
-    Downloader> d
-
-    Download which package (l=list; x=cancel)?
-      Identifier> stopwords
-        Downloading package stopwords to /usr/local/lib/nltk_data...
+    The full list of NTLK Collection are displayable with the ``l) list`` option