Trees | Indices | Help |
|
---|
|
1 ########################################################################### 2 # 3 # This program is part of Zenoss Core, an open source monitoring platform. 4 # Copyright (C) 2007, Zenoss Inc. 5 # 6 # This program is free software; you can redistribute it and/or modify it 7 # under the terms of the GNU General Public License version 2 as published by 8 # the Free Software Foundation. 9 # 10 # For complete information please visit: http://www.zenoss.com/oss/ 11 # 12 ########################################################################### 13 14 # Functions to simplify form submission return values. 15 16 import transaction 17 18 from Products.ZenUtils.json import json 1921 """ 22 Builds a response for an Ext form. 23 """ 24 _errors = None 25 _redirect = None 2645 4628 return bool(self._errors)29 32 37 38 @json40 return { 41 'success': not self.has_errors(), 42 'redirect': self._redirect, 43 'errors': self._errors or {} 44 }48 """ 49 Decorator for methods that are the targets of Ext form submission. 50 51 Provides transaction rollback, so methods can be used as their own 52 validation without harm. 53 """ 54 def inner(*args, **kwargs): 55 savepoint = transaction.savepoint() 56 result = f(*args, **kwargs) 57 if isinstance(result, FormResponse): 58 if result.has_errors(): 59 savepoint.rollback() 60 return result.get_response() 61 return result62 return inner 63
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu May 7 11:46:45 2009 | http://epydoc.sourceforge.net |