Trees | Indices | Help |
|
---|
|
1 ############################################################################## 2 # 3 # Copyright (C) Zenoss, Inc. 2007, all rights reserved. 4 # 5 # This content is made available according to terms specified in 6 # License.zenoss under the directory where your Zenoss product is installed. 7 # 8 ############################################################################## 9 10 11 # Functions to simplify form submission return values. 12 13 import transaction 14 15 from Products.ZenUtils.jsonutils import json, unjson 16 from Products.ZenUtils.extdirect.zope.router import ZopeDirectRouter as DirectRouter 17 from Products.ZenUtils.extdirect.router import DirectResponse20 """ 21 Builds a response for an Ext form. 22 """ 23 _errors = None 24 _redirect = None 254427 return bool(self._errors)28 31 36 37 @json39 return { 40 'success': not self.has_errors(), 41 'redirect': self._redirect, 42 'errors': self._errors or {} 43 }47 """ 48 Decorator for methods that are the targets of Ext form submission. 49 50 Provides transaction rollback, so methods can be used as their own 51 validation without harm. 52 """ 53 def inner(*args, **kwargs): 54 savepoint = transaction.savepoint() 55 result = f(*args, **kwargs) 56 if isinstance(result, FormResponse): 57 if result.has_errors(): 58 savepoint.rollback() 59 return result.get_response() 60 return result61 return inner 62
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1.1812 on Mon Jul 30 17:11:27 2012 | http://epydoc.sourceforge.net |