.. $ more README *.py ui/portal/*.xml > all.txt; a2ps all.txt -o all.ps
.. $ rest2html --stylesheet-path=../main.css README a.html 
.. $ rest2latex README a.latex; pdflatex a.latex; acroread a.pdf

==========================
Portal 1, 2 and 3 together 
==========================

Here we put together all the element we learn in portal 1 2 and 3.
We obtain an usable portal with a powerfull backoffice with only 202 lines of
python code. 

We illustrate the adventage of using the object oriented programming, and at the
end of this document we add an  `iKaaro and itools API used in portals`_
`Howto`_.

Tree
=====
::

  .
  |-- Root.py
  |-- Skins.py
  |-- __init__.py
  `-- ui
      `-- portal
          |-- Base_view.xml
          |-- Document_view.xml
          |-- FrontOffice1_template.xhtml
          |-- images
          |   |-- Document16.png
          |   |-- Document48.png
          |   |-- Folder16.png
          |   |-- Folder48.png
          |   `-- px.gif
          `-- main.css


App.py
=========

We have the classe Base to factoring the ``views`` and the ``switch_skin``
methods who are common to the **Root**, **Document** and the **PortalFolder**.

.. figure:: ../images/class_diagram.png
   :align: center 
   :scale: 90 
 

__init__.py
============

The same as **portal3**

Skins.py
==========

The same as **portal3**


iKaaro and itools API used in portals
======================================

class variables
-----------------
::

    class_id = 'PortalFolder'
    class_title = u'Our Portal Folder'
    class_description = u'Here the description of our Portal Folder'
    class_version = '20041106'
    class_icon48 = 'portal/images/Folder48.png'
    class_icon16 = 'portal/images/Folder16.png'

class method
-------------

We control the tab/sub_tab available in the backoffice with the ``get_views``
method::

    def get_views(self):
        return ['name_of_a_method']

The ``get_document`` method is used to configure the aggregation diagram::
     
    class MyFolder(...):
        ...

        def get_document_types(self):
             return [Document, MyFolder]

To select the skin we use the ``get_skin_name`` method::

  class Root(...):
      ...
      def get_skin_name(self):
          ...

To register a class **Document** we use the ``register_handler_class`` method
of one of the class **Document** inherit, here **ikaaroHTML**::

  ikaaroHTML.register_handler_class(Document)

In the init.py module we register a skin with the ``register_skin`` method::

  ...
  frontoffice1 = FrontOffice1(resource)
  ui.register_skin('frontoffice1', frontoffice1)

Howto
======

1. To get an handler instance ?.

   Most of the time when we are writing code inside an Handler class (for
   exemple **PortalFolder**, **Document** or **Root**) *self* IS the handler
   instance.
  
   But if we are not in an Handler class (for exemple **Base** or
   **FrontOffice1**) we can get the handler instance of the URL with the
   *handler* attribute of the context object returned by ``get_context``.
   
   For exemple if we want to take an instance of the **Document** class in the
   case of the this Zope URL::

     http://localhost:8080/portal/f1/doc1/;view
   
   we can take the *handler* from the context like this::
     
     class FrontOffice1(ikaaroSkin):
         ...
         def template(self, content):
             context = get_context()
             here = context.handler
             # here is for the above URL an instance of doc1

2. Who to get the handler instance of the root of our iKaaro based portal ?.

   The context object has the *root* handler has an attribute::

      context = get_context()
      root = context.root

3. Who to get the parent of an handler ?.  
  
  Every handler as a parent attribute::

    parent = handler.parent

4. Who to get the HTTP *request* ?. 

  The context object has the *request* has an attribute::

    context = get_context()
    request = context.request
      
5. Who to get all the handlers inside a folder hanlder ?.

  We use the ``get_handlers`` method. In the following exemple 
  we gate in handlers a list of all the **PortalFolder** handlers::

    handlers = folder.get_handlers(format='PortalFolder')


