Commit 99377ede authored by Clovis NZOUENDJOU's avatar Clovis NZOUENDJOU
Browse files

adding technical documentation

parent 3442e87fb37b
# -*- coding: utf-8 -*-
from osv import osv, fields
from kombu import Connection
import socket
from tools.translate import _
class anybusConnection(osv.Model):
"""
Class used to establish the connection between your ERP and server RabbitMQ
.. Note::
The BrokerConnection class supports additional keyword arguments,
these are: hostname: Default host name if not provided in the URL.
userid: Default user name if not provided in the URL. password: Default password
if not provided in the URL. virtual_host: Default virtual host if not provided in the
URL. port: Default port if not provided in the URL. transport: Default transport if
not provided in the URL. Can be a string specifying the path to the class.
(e.g. kombu.transport.pyamqplib. Transport), or one of the aliases: amqplib, pika,
redis, memory, and so on. ssl: Use SSL to connect to the server. Default is False.
Only supported by the amqp transport. insist: Insist on connecting to a server. In a
configuration with multiple load-sharing servers, the insist option tells the server
that the client is insisting on a connection to the specified server. Default is
False. Only supported by the amqp and pika transports, and not by AMQP 0-9-1.
connect_timeout: Timeout in seconds for connecting to the server. May not be
supported by the specified transport. transport_options: A dict of additional
connection arguments to pass to alternate kombu channel implementations. Consult the
transport
documentation for available options.
"""
_name = 'anybus.connection'
_description = 'anybus connection'
_columns = {
'name': fields.char('Name', size=64, required=True),
'uri': fields.char(
'URI', size=255, required=True, help='Define the connection URI '
'for the AMQP broker (ex: RabbitMQ)'),
'state': fields.selection(
[('draft', 'Draft'), ('declared', 'Declared')], 'State',
readonly=True, help='Define the state of the connection'),
'exchange_ids': fields.one2many(
'anybus.entity.exchange', 'connection_id', 'Exchanges',
readonly=True),
'queue_ids': fields.one2many('anybus.entity.queue', 'connection_id',
'Queues', readonly=True),
}
_defaults = {
'uri': lambda *a: 'amqp://guest:guest@localhost:5672//%(dbname)s',
'state': lambda *a: 'draft',
}
def _get_uri(self, cr, uid, connection, context=None):
"""
return the uri of the connexion
"""
return connection.uri % {'dbname': cr.dbname}
def action_declare(self, cr, uid, ids, context=None):
"""
Function to declare a connection. When a connection is declared,
then you are connected to the RabbitMQ server.
"""
for connection in self.browse(cr, uid, ids, context=context):
try:
uri = self._get_uri(cr, uid, connection, context=context)
conn = Connection(uri)
conn.connect()
conn.close()
conn.release()
connection.write({'state': 'declared'})
except socket.error, e:
raise osv.except_osv(
_('Anybus Connection error'), e.args[1].decode('utf-8'))
except IOError, e:
error = "No vhost found for %r" % uri
raise osv.except_osv(_('Anybus Connection error'),
_(error))
return {}
def action_redraft(self, cr, uid, ids, context=None):
"""
This function searches all exchanges and queues that are reported
and changes their state in ``draft``
"""
exchange_obj = self.pool.get('anybus.entity.exchange')
exchange_ids = exchange_obj.search(
cr, uid, [('state', '=', 'declared')], context=context)
exchange_obj.action_redraft(cr, uid, exchange_ids, context=context)
queue_obj = self.pool.get('anybus.entity.queue')
queue_ids = queue_obj.search(
cr, uid, [('state', '=', 'declared')], context=context)
queue_obj.action_redraft(cr, uid, queue_ids, context=context)
self.write(cr, uid, ids, {'state': 'draft'}, context=context)
return {}
def action_declare_all(self, cr, uid, ids, context=None):
"""
This function searches all exchanges and queues which are at the draft state
and ``declare`` it.
"""
exchange_obj = self.pool.get('anybus.entity.exchange')
exchange_ids = exchange_obj.search(
cr, uid, [('state', '=', 'draft')], context=context)
exchange_obj.action_declare(cr, uid, exchange_ids, context=context)
queue_obj = self.pool.get('anybus.entity.queue')
queue_ids = queue_obj.search(
cr, uid, [('state', '=', 'draft')], context=context)
queue_obj.action_declare(cr, uid, queue_ids, context=context)
return {}
def action_purge_all(self, cr, uid, ids, context=None):
"""
Purge all queues which are at the draft state
"""
queue_obj = self.pool.get('anybus.entity.queue')
queue_ids = queue_obj.search(
cr, uid, [('state', '=', 'draft')], context=context)
queue_obj.action_purge(cr, uid, queue_ids, context=context)
return {}
def get_actions(self, cr, uid, ids, model, context=None):
"""
"""
model_ids = self.pool.get(model).search(cr, uid, [], context=context)
res = {}
for id in ids:
res[id] = model_ids
return res
## vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
clean:
-rm -rf $(BUILDDIR)/*
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Anybus.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Anybus.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/Anybus"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Anybus"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
.consumer module
================
.. automodule:: .consumer
:members:
:undoc-members:
:show-inheritance:
anybus package
==============
Subpackages
-----------
.. toctree::
anybus.tests
anybus.wizard
Submodules
----------
anybus.connection module
------------------------
.. automodule:: openerp.addons.anybus.connection
:members:
:undoc-members:
:show-inheritance:
anybus.entity module
--------------------
.. automodule:: openerp.addons.anybus.entity
:members:
:undoc-members:
:show-inheritance:
anybus.exchange module
----------------------
.. automodule:: openerp.addons.anybus.exchange
:members:
:undoc-members:
:show-inheritance:
anybus.message module
---------------------
.. automodule:: openerp.addons.anybus.message
:members:
:undoc-members:
:show-inheritance:
anybus.process module
---------------------
.. automodule:: openerp.addons.anybus.process
:members:
:undoc-members:
:show-inheritance:
anybus.queue module
-------------------
.. automodule:: openerp.addons.anybus.queue
:members:
:undoc-members:
:show-inheritance:
anybus.trigger module
---------------------
.. automodule:: openerp.addons.anybus.trigger
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: openerp.addons.anybus
:members:
:undoc-members:
:show-inheritance:
anybus.tests package
====================
Submodules
----------
anybus.tests.test_anybus module
-------------------------------
.. automodule:: openerp.addons.anybus.tests.test_anybus
:members:
:undoc-members:
:show-inheritance:
anybus.tests.test_anybus_model module
-------------------------------------
.. automodule:: openerp.addons.anybus.tests.test_anybus_model
:members:
:undoc-members:
:show-inheritance:
anybus.tests.test_simple_connection module
------------------------------------------
.. automodule:: openerp.addons.anybus.tests.test_simple_connection
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: openerp.addons.anybus.tests
:members:
:undoc-members:
:show-inheritance:
anybus.wizard package
=====================
Submodules
----------
anybus.wizard.anybus_installer module
-------------------------------------
.. automodule:: openerp.addons.anybus.wizard.anybus_installer
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: openerp.addons.anybus.wizard
:members:
:undoc-members:
:show-inheritance:
anybus_consumer package
=======================
Subpackages
-----------
.. toctree::
anybus_consumer.tests
Submodules
----------
anybus_consumer.connection module
---------------------------------
.. automodule:: openerp.addons.anybus_consumer.connection
:members:
:undoc-members:
:show-inheritance:
anybus_consumer.consumer module
-------------------------------
.. automodule:: openerp.addons.anybus_consumer.consumer
:members:
:undoc-members:
:show-inheritance:
anybus_consumer.message module
------------------------------
.. automodule:: openerp.addons.anybus_consumer.message
:members:
:undoc-members:
:show-inheritance:
anybus_consumer.noop module
---------------------------
.. automodule:: openerp.addons.anybus_consumer.noop
:members:
:undoc-members:
:show-inheritance:
anybus_consumer.process module
------------------------------
.. automodule:: openerp.addons.anybus_consumer.process
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: openerp.addons.anybus_consumer
:members:
:undoc-members:
:show-inheritance:
anybus_consumer.tests package
=============================
Submodules
----------
anybus_consumer.tests.test_anybus_model module
----------------------------------------------
.. automodule:: openerp.addons.anybus_consumer.tests.test_anybus_model
:members:
:undoc-members:
:show-inheritance:
anybus_consumer.tests.test_consum module
----------------------------------------
.. automodule:: openerp.addons.anybus_consumer.tests.test_consum
:members:
:undoc-members:
:show-inheritance:
anybus_consumer.tests.test_noop module
--------------------------------------
.. automodule:: openerp.addons.anybus_consumer.tests.test_noop
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: openerp.addons.anybus_consumer.tests
:members:
:undoc-members:
:show-inheritance:
anybus_fields_selection package
===============================
Submodules
----------
anybus_fields_selection.fields_selection module
-----------------------------------------------
.. automodule:: openerp.addons.anybus_fields_selection.fields_selection
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: openerp.addons.anybus_fields_selection
:members:
:undoc-members:
:show-inheritance:
anybus_incoming_function package
================================
Submodules
----------
anybus_incoming_function.process module
---------------------------------------
.. automodule:: openerp.addons.anybus_incoming_function.process
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: openerp.addons.anybus_incoming_function
:members:
:undoc-members:
:show-inheritance:
anybus_incoming_importcsv package
=================================
Submodules
----------
anybus_incoming_importcsv.process module
----------------------------------------
.. automodule:: openerp.addons.anybus_incoming_importcsv.process
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: openerp.addons.anybus_incoming_importcsv
:members:
:undoc-members:
:show-inheritance:
anybus_outgoing_exportcsv package
=================================
Submodules
----------
anybus_outgoing_exportcsv.process module
----------------------------------------
.. automodule:: openerp.addons.anybus_outgoing_exportcsv.process
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: openerp.addons.anybus_outgoing_exportcsv
:members:
:undoc-members:
:show-inheritance:
anybus_outgoing_function package
================================
Submodules
----------
anybus_outgoing_function.process module
---------------------------------------