Show More
@@ -22,6 +22,7 b'' | |||
|
22 | 22 | Authentication modules |
|
23 | 23 | """ |
|
24 | 24 | |
|
25 | import colander | |
|
25 | 26 | import logging |
|
26 | 27 | import time |
|
27 | 28 | import traceback |
@@ -97,11 +98,10 b' class RhodeCodeAuthPluginBase(object):' | |||
|
97 | 98 | # Mapping of python to DB settings model types. Plugins may override or |
|
98 | 99 | # extend this mapping. |
|
99 | 100 | _settings_type_map = { |
|
100 | str: 'str', | |
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 | list: 'list', | |
|
101 | colander.String: 'unicode', | |
|
102 | colander.Integer: 'int', | |
|
103 | colander.Boolean: 'bool', | |
|
104 | colander.List: 'list', | |
|
105 | 105 | } |
|
106 | 106 | |
|
107 | 107 | def __init__(self, plugin_id): |
@@ -119,16 +119,19 b' class RhodeCodeAuthPluginBase(object):' | |||
|
119 | 119 | # PluginSetting or to use the plugin id here. |
|
120 | 120 | return 'auth_{}_{}'.format(self.name, name) |
|
121 | 121 | |
|
122 |
def _get_setting_type(self, name |
|
|
122 | def _get_setting_type(self, name): | |
|
123 | """ | |
|
124 | Return the type of a setting. This type is defined by the SettingsModel | |
|
125 | and determines how the setting is stored in DB. Optionally the suffix | |
|
126 | `.encrypted` is appended to instruct SettingsModel to store it | |
|
127 | encrypted. | |
|
123 | 128 |
|
|
124 | Get the type as used by the SettingsModel accordingly to type of passed | |
|
125 | value. Optionally the suffix `.encrypted` is appended to instruct | |
|
126 | SettingsModel to store it encrypted. | |
|
127 | """ | |
|
128 | type_ = self._settings_type_map.get(type(value), 'unicode') | |
|
129 | schema_node = self.get_settings_schema().get(name) | |
|
130 | db_type = self._settings_type_map.get( | |
|
131 | schema_node.typ.__class__, 'unicode') | |
|
129 | 132 | if name in self._settings_encrypted: |
|
130 |
type |
|
|
131 |
return type |
|
|
133 | db_type = '{}.encrypted'.format(db_type) | |
|
134 | return db_type | |
|
132 | 135 | |
|
133 | 136 | def is_enabled(self): |
|
134 | 137 | """ |
@@ -177,7 +180,7 b' class RhodeCodeAuthPluginBase(object):' | |||
|
177 | 180 | Create or update a setting for this plugin in the persistent storage. |
|
178 | 181 | """ |
|
179 | 182 | full_name = self._get_setting_full_name(name) |
|
180 |
type_ = self._get_setting_type(name |
|
|
183 | type_ = self._get_setting_type(name) | |
|
181 | 184 | db_setting = SettingsModel().create_or_update_setting( |
|
182 | 185 | full_name, value, type_) |
|
183 | 186 | return db_setting.app_settings_value |
General Comments 0
You need to be logged in to leave comments.
Login now