1 ##############################################################################
3 # Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
5 # WARNING: This program as such is intended to be used by professional
6 # programmers who take the whole responsibility of assessing all potential
7 # consequences resulting from its eventual inadequacies and bugs
8 # End users who are looking for a ready-to-use solution with commercial
9 # guarantees and support are strongly adviced to contract a Free Software
12 # This program is Free Software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 3
15 # of the License, or (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 ##############################################################################
28 from slapos
.recipe
.librecipe
import wrap
29 from slapos
.recipe
.librecipe
import GenericSlapRecipe
31 CONNECTION_PARAMETER_STRING
= 'connection-'
33 class Recipe(GenericSlapRecipe
):
36 options
= self
.options
.copy()
38 slave_reference
= options
.pop('-slave-reference', None)
39 for k
, v
in options
.iteritems():
43 self
._setConnectionDict(publish_dict
, slave_reference
)
46 def _setConnectionDict(self
, publish_dict
, slave_reference
=None):
47 return self
.setConnectionDict(publish_dict
, slave_reference
)
49 SERIALISED_MAGIC_KEY
= '_'
51 class Serialised(Recipe
):
52 def _setConnectionDict(self
, publish_dict
, slave_reference
=None):
53 return super(Serialised
, self
)._setConnectionDict(wrap(publish_dict
), slave_reference
)
57 class PublishSection(GenericSlapRecipe
):
59 Take a list of "request" sections, and publish every connection parameter.
62 section-list: String, representing the list of sections to fetch
63 parameters to publish, in order, separated by a space.
67 for section
in self
.options
['section-list'].strip().split():
68 section
= section
.strip()
69 options
= self
.buildout
[section
].copy()
70 for k
, v
in options
.iteritems():
71 if k
.startswith(CONNECTION_PARAMETER_STRING
):
73 publish_dict
[k
.lstrip(CONNECTION_PARAMETER_STRING
)] = v
74 self
.setConnectionDict(publish_dict
)