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.jsonutils import json, unjson 19 from Products.ZenUtils.extdirect.zope.router import ZopeDirectRouter 20 from Products.ZenUtils.extdirect.router import DirectResponse23 """ 24 Builds a response for an Ext form. 25 """ 26 _errors = None 27 _redirect = None 284730 return bool(self._errors)31 34 39 40 @json42 return { 43 'success': not self.has_errors(), 44 'redirect': self._redirect, 45 'errors': self._errors or {} 46 }50 """ 51 Decorator for methods that are the targets of Ext form submission. 52 53 Provides transaction rollback, so methods can be used as their own 54 validation without harm. 55 """ 56 def inner(*args, **kwargs): 57 savepoint = transaction.savepoint() 58 result = f(*args, **kwargs) 59 if isinstance(result, FormResponse): 60 if result.has_errors(): 61 savepoint.rollback() 62 return result.get_response() 63 return result64 return inner 65 76
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Jul 14 12:07:30 2010 | http://epydoc.sourceforge.net |