OLD | NEW |
1 # This file is part of flask_tryton. The COPYRIGHT file at the top level of | 1 # This file is part of flask_tryton. The COPYRIGHT file at the top level of |
2 # this repository contains the full copyright notices and license terms. | 2 # this repository contains the full copyright notices and license terms. |
3 | 3 |
4 from functools import wraps | 4 from functools import wraps |
5 | 5 |
6 from flask import request, current_app | 6 from flask import request, current_app |
7 from werkzeug.routing import BaseConverter | 7 from werkzeug.routing import BaseConverter |
8 from werkzeug.exceptions import BadRequest | 8 from werkzeug.exceptions import BadRequest |
9 | 9 |
10 from trytond import __version__ as trytond_version | 10 from trytond import __version__ as trytond_version |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 tryton_transaction = Tryton.transaction | 226 tryton_transaction = Tryton.transaction |
227 | 227 |
228 | 228 |
229 class _BaseProxy(object): | 229 class _BaseProxy(object): |
230 pass | 230 pass |
231 | 231 |
232 | 232 |
233 class _RecordsProxy(_BaseProxy): | 233 class _RecordsProxy(_BaseProxy): |
234 def __init__(self, model, ids): | 234 def __init__(self, model, ids): |
235 self.model = model | 235 self.model = model |
236 self.ids = ids | 236 self.ids = list(ids) |
237 | 237 |
238 def __iter__(self): | 238 def __iter__(self): |
239 return iter(self.ids) | 239 return iter(self.ids) |
240 | 240 |
241 def __call__(self): | 241 def __call__(self): |
242 tryton = current_app.extensions['Tryton'] | 242 tryton = current_app.extensions['Tryton'] |
243 Model = tryton.pool.get(self.model) | 243 Model = tryton.pool.get(self.model) |
244 return Model.browse(self.ids) | 244 return Model.browse(self.ids) |
245 | 245 |
246 | 246 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 280 |
281 def __init__(self, map, model): | 281 def __init__(self, map, model): |
282 super(RecordsConverter, self).__init__(map) | 282 super(RecordsConverter, self).__init__(map) |
283 self.model = model | 283 self.model = model |
284 | 284 |
285 def to_python(self, value): | 285 def to_python(self, value): |
286 return _RecordsProxy(self.model, map(int, value.split(','))) | 286 return _RecordsProxy(self.model, map(int, value.split(','))) |
287 | 287 |
288 def to_url(self, value): | 288 def to_url(self, value): |
289 return ','.join(map(str, map(int, value))) | 289 return ','.join(map(str, map(int, value))) |
OLD | NEW |