[FIX] res_users: side-effect of virtual groups prevented users from saving their...
[odoo/odoo.git] / openerp / report / render / render.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #    
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
19 #
20 ##############################################################################
21
22 # Why doing some multi-thread instead of using OSE capabilities ?
23 # For progress bar.
24
25 #
26 # Add a transparant multi-thread layer to all report rendering layers
27 #
28
29 # TODO: method to stock on the disk
30 class render(object):
31     """ Represents a report job being rendered.
32     
33     @param bin_datas a dictionary of name:<binary content> of images etc.
34     @param path the path in which binary files can be discovered, useful
35             for components (images) of the report. It can be:
36                - a string, relative or absolute path to images
37                - a list, containing strings of paths.
38             If a string is absolute path, it will be opened as such, else
39             it will be passed to tools.file_open() which also considers zip
40             addons.
41
42     Reporting classes must subclass this class and redefine the __init__ and
43     _render methods (not the other methods).
44
45     """
46     def __init__(self, bin_datas=None, path='.'):
47         self.done = False
48         if bin_datas is None:
49             self.bin_datas = {}
50         else:
51             self.bin_datas = bin_datas
52         self.path = path
53     
54     def _render(self):
55         return None
56
57     def render(self):
58         self.done = False
59         self._result = self._render()
60         self.done = True
61         return True
62     
63     def is_done(self):
64         return self.done
65
66     def get(self):
67         if self.is_done():
68             return self._result
69         else:
70             return None
71
72
73 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
74