Passage à la newSubmitBranch, suffisamment fonctionnelle que pour passer les
tests web. fields est encore utilisé dans la majeure partie des widgets, ça se nettoiera petit à petit. Avec des kinds/widgets ou certaines combinaisons, il peut y avoir un NotImplementedError, c'est contournable en éditant shared/web/things.py et en supprimant les commentaires des lignes 363 et 364.
This commit is contained in:
parent
50aa959c2f
commit
7721abd085
|
@ -63,5 +63,3 @@ import common.context as context
|
|||
context.clear()
|
||||
context.push()
|
||||
|
||||
newSubmitBranch = 0
|
||||
|
||||
|
|
|
@ -70,13 +70,8 @@ class AtomsWeb(ObjectsWebMixin, AtomsProxy):
|
|||
except faults.DuplicateValue, f:
|
||||
keywords['again'] = '1'
|
||||
keywords['error'] = '1'
|
||||
if glasnost.newSubmitBranch:
|
||||
object.setError('self.name', f)
|
||||
return self.edit(object = object, **keywords)
|
||||
keywords['name_error'] = 'valueAlreadyUsed'
|
||||
uri = X.actionUrl('edit')
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
object.setError('self.name', f)
|
||||
return self.edit(object = object, **keywords)
|
||||
|
||||
def submitModifyObject(self, object, **keywords):
|
||||
try:
|
||||
|
@ -84,11 +79,6 @@ class AtomsWeb(ObjectsWebMixin, AtomsProxy):
|
|||
except faults.DuplicateValue, f:
|
||||
keywords['again'] = '1'
|
||||
keywords['error'] = '1'
|
||||
if glasnost.newSubmitBranch:
|
||||
object.setError('self.name', f)
|
||||
return self.edit(object = object, **keywords)
|
||||
keywords['name_error'] = 'valueAlreadyUsed'
|
||||
uri = X.actionUrl('edit')
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
object.setError('self.name', f)
|
||||
return self.edit(object = object, **keywords)
|
||||
|
||||
|
|
|
@ -150,25 +150,13 @@ class AuthenticationLdapWeb(AdministrableWebMixin, AuthenticationLdapProxy):
|
|||
except faults.WrongLogin, f:
|
||||
keywords['again'] = '1'
|
||||
keywords['error'] = '1'
|
||||
if glasnost.newSubmitBranch:
|
||||
authObject.setError('self.login', f)
|
||||
return self.login(object = authObject, **keywords)
|
||||
keywords['login_error'] = 'wrongValue'
|
||||
uri = X.roleUrl(self.serverRole, 'login')
|
||||
uri.add('nextUri', nextUri)
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
authObject.setError('self.login', f)
|
||||
return self.login(object = authObject, **keywords)
|
||||
except faults.WrongPassword:
|
||||
keywords['again'] = '1'
|
||||
keywords['error'] = '1'
|
||||
if glasnost.newSubmitBranch:
|
||||
authObject.setError('self.password', f)
|
||||
return self.login(object = authObject, **keywords)
|
||||
keywords['password_error'] = 'wrongValue'
|
||||
uri = X.roleUrl(self.serverRole, 'login')
|
||||
uri.add('nextUri', nextUri)
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
authObject.setError('self.password', f)
|
||||
return self.login(object = authObject, **keywords)
|
||||
except:
|
||||
if context.getVar('debug'):
|
||||
raise
|
||||
|
|
|
@ -469,11 +469,7 @@ class AuthenticationLoginPasswordWeb(AdministrableWebMixin,
|
|||
authObject.submitFields(keywords)
|
||||
if keywords.has_key('again') and keywords['again']:
|
||||
uri = X.roleUrl(self.serverRole, 'login')
|
||||
if glasnost.newSubmitBranch:
|
||||
return self.login(object = authObject, **keywords)
|
||||
uri.add('nextUri', nextUri)
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
return self.login(object = authObject, **keywords)
|
||||
if sendPasswordByEmail:
|
||||
try:
|
||||
self.emailPassword(authObject)
|
||||
|
@ -488,25 +484,13 @@ class AuthenticationLoginPasswordWeb(AdministrableWebMixin,
|
|||
except faults.WrongLogin, f:
|
||||
keywords['again'] = '1'
|
||||
keywords['error'] = '1'
|
||||
if glasnost.newSubmitBranch:
|
||||
authObject.setError('self.login', f)
|
||||
return self.login(object = authObject, **keywords)
|
||||
keywords['login_error'] = 'wrongValue'
|
||||
uri = X.roleUrl(self.serverRole, 'login')
|
||||
uri.add('nextUri', nextUri)
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
authObject.setError('self.login', f)
|
||||
return self.login(object = authObject, **keywords)
|
||||
except faults.WrongPassword, f:
|
||||
keywords['again'] = '1'
|
||||
keywords['error'] = '1'
|
||||
if glasnost.newSubmitBranch:
|
||||
authObject.setError('self.password', f)
|
||||
return self.login(object = authObject, **keywords)
|
||||
keywords['password_error'] = 'wrongValue'
|
||||
uri = X.roleUrl(self.serverRole, 'login')
|
||||
uri.add('nextUri', nextUri)
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
authObject.setError('self.password', f)
|
||||
return self.login(object = authObject, **keywords)
|
||||
except:
|
||||
if context.getVar('debug'):
|
||||
raise
|
||||
|
@ -522,9 +506,9 @@ class AuthenticationLoginPasswordWeb(AdministrableWebMixin,
|
|||
if keywords is None:
|
||||
keywords = {}
|
||||
userCardObject = usercardWeb.newObject(None)
|
||||
if glasnost.newSubmitBranch and \
|
||||
keywords.has_key('userCardObject') and \
|
||||
isinstance(keywords['userCardObject'], userCardObject.__class__):
|
||||
if keywords.has_key('userCardObject') and \
|
||||
isinstance(keywords['userCardObject'],
|
||||
userCardObject.__class__):
|
||||
userCardObject = keywords['userCardObject']
|
||||
del keywords['userCardObject']
|
||||
userCardSlot = slots.Root(userCardObject, name = 'userCard')
|
||||
|
@ -533,8 +517,7 @@ class AuthenticationLoginPasswordWeb(AdministrableWebMixin,
|
|||
userCardObject.repairFields(keywords, parentSlot = userCardSlot)
|
||||
|
||||
authObject = self.newAuthenticationObject()
|
||||
if glasnost.newSubmitBranch and \
|
||||
keywords.has_key('authObject') and \
|
||||
if keywords.has_key('authObject') and \
|
||||
isinstance(keywords['authObject'], authObject.__class__):
|
||||
authObject = keywords['authObject']
|
||||
del keywords['authObject']
|
||||
|
@ -580,14 +563,10 @@ class AuthenticationLoginPasswordWeb(AdministrableWebMixin,
|
|||
authObject.submitFields(keywords)
|
||||
|
||||
if keywords.has_key('again') and keywords['again']:
|
||||
if glasnost.newSubmitBranch:
|
||||
return self.newAccount(
|
||||
return self.newAccount(
|
||||
userCardObject = userCardObject,
|
||||
authObject = authObject,
|
||||
**keywords)
|
||||
uri = X.actionUrl('newAccount')
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
|
||||
userId = usercardWeb.addObject(userCardObject)
|
||||
try:
|
||||
|
|
|
@ -228,8 +228,7 @@ class AdministrableWebMixin(WebMixin):
|
|||
return accessForbidden()
|
||||
admin = self.getAdmin()
|
||||
|
||||
if glasnost.newSubmitBranch and \
|
||||
keywords.has_key('adminObject') and \
|
||||
if keywords.has_key('adminObject') and \
|
||||
isinstance(keywords['adminObject'], admin.__class__):
|
||||
admin = keywords['adminObject']
|
||||
del keywords['adminObject']
|
||||
|
@ -274,12 +273,7 @@ class AdministrableWebMixin(WebMixin):
|
|||
admin = self.newAdmin(keywords)
|
||||
admin.submitFields(keywords)
|
||||
if keywords.has_key('again') and keywords['again']:
|
||||
if glasnost.newSubmitBranch:
|
||||
return self.adminEdit(adminObject = admin, **keywords)
|
||||
uri = X.actionUrl('adminEdit')
|
||||
uri.addKeywords(keywords)
|
||||
return # The redirect(uri) will be returned by the finally
|
||||
# instruction.
|
||||
return self.adminEdit(adminObject = admin, **keywords)
|
||||
try:
|
||||
self.modifyAdmin(admin)
|
||||
except faults.WrongVersion:
|
||||
|
@ -413,8 +407,7 @@ class ObjectsWebMixin(AdministrableWebMixin):
|
|||
return accessForbidden()
|
||||
object = self.newObject(keywords)
|
||||
|
||||
if glasnost.newSubmitBranch and \
|
||||
keywords.has_key('object') and \
|
||||
if keywords.has_key('object') and \
|
||||
isinstance(keywords['object'], object.__class__):
|
||||
object = keywords['object']
|
||||
del keywords['object']
|
||||
|
@ -892,11 +885,7 @@ class ObjectsWebMixin(AdministrableWebMixin):
|
|||
object.submitFields(keywords)
|
||||
|
||||
if keywords.has_key('again') and keywords['again']:
|
||||
if glasnost.newSubmitBranch:
|
||||
return self.edit(object = object, **keywords)
|
||||
uri = X.idUrl(id, 'edit')
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
return self.edit(object = object, **keywords)
|
||||
|
||||
if not id:
|
||||
result = self.submitAddObject(object, **keywords)
|
||||
|
|
|
@ -76,13 +76,8 @@ class PageNamesWeb(ObjectsWebMixin, PageNamesProxy):
|
|||
except faults.DuplicateValue:
|
||||
keywords['again'] = '1'
|
||||
keywords['error'] = '1'
|
||||
if glasnost.newSubmitBranch:
|
||||
object.setError('self.name', f)
|
||||
return self.edit(object = object, **keywords)
|
||||
keywords['name_error'] = 'valueAlreadyUsed'
|
||||
uri = X.actionUrl('edit')
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
object.setError('self.name', f)
|
||||
return self.edit(object = object, **keywords)
|
||||
|
||||
def submitModifyObject(self, object, **keywords):
|
||||
try:
|
||||
|
@ -90,10 +85,6 @@ class PageNamesWeb(ObjectsWebMixin, PageNamesProxy):
|
|||
except faults.DuplicateValue:
|
||||
keywords['again'] = '1'
|
||||
keywords['error'] = '1'
|
||||
if glasnost.newSubmitBranch:
|
||||
object.setError('self.name', f)
|
||||
return self.edit(object = object, **keywords)
|
||||
uri = X.actionUrl('edit')
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
object.setError('self.name', f)
|
||||
return self.edit(object = object, **keywords)
|
||||
|
||||
|
|
|
@ -244,11 +244,7 @@ class PeopleWeb(ObjectsWebMixin, PeopleProxy):
|
|||
object.submitFields(keywords)
|
||||
|
||||
if keywords.has_key('again') and keywords['again']:
|
||||
if glasnost.newSubmitBranch:
|
||||
return self.edit(object = object, **keywords)
|
||||
uri = X.idUrl(id, 'edit')
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
return self.edit(object = object, **keywords)
|
||||
if not id:
|
||||
try:
|
||||
id = self.addObject(object)
|
||||
|
@ -271,10 +267,7 @@ class PeopleWeb(ObjectsWebMixin, PeopleProxy):
|
|||
keywords['again'] = '1'
|
||||
keywords['error'] = '1'
|
||||
uri = X.idUrl(id, 'edit')
|
||||
if glasnost.newSubmitBranch:
|
||||
return self.edit(object = object, **keywords)
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
return self.edit(object = object, **keywords)
|
||||
### if object.email:
|
||||
### return success(
|
||||
### _("""\
|
||||
|
@ -306,10 +299,7 @@ class PeopleWeb(ObjectsWebMixin, PeopleProxy):
|
|||
keywords['again'] = '1'
|
||||
keywords['error'] = '1'
|
||||
uri = X.idUrl(id, 'edit')
|
||||
if glasnost.newSubmitBranch:
|
||||
return self.edit(object = object, **keywords)
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
return self.edit(object = object, **keywords)
|
||||
return redirect(X.idUrl(id))
|
||||
submit.isPublicForWeb = 1
|
||||
|
||||
|
|
|
@ -617,14 +617,7 @@ class TranslationsWeb(ObjectsWebMixin, TranslationsProxy):
|
|||
else:
|
||||
localization.submitFields(keywords)
|
||||
if keywords.has_key('again') and keywords['again']:
|
||||
if glasnost.newSubmitBranch:
|
||||
return self.edit(localization = localization, **keywords)
|
||||
uri = X.actionUrl(
|
||||
'edit/%s/%s' % (localizationKey, sourceStringDigest))
|
||||
del(keywords['localizationKey'])
|
||||
del(keywords['sourceStringDigest'])
|
||||
uri.addKeywords(keywords)
|
||||
return redirect(uri)
|
||||
return self.edit(localization = localization, **keywords)
|
||||
try:
|
||||
self.modifyLocalization(localization)
|
||||
except faults.WrongVersion:
|
||||
|
|
|
@ -348,27 +348,23 @@ Please backup your changes and redo the edition.\
|
|||
kind = slot.getKind()
|
||||
if (kind.isRequiredInEditMode or kind.isExportable()) \
|
||||
and kind.hasToSubmitField:
|
||||
import glasnost
|
||||
if glasnost.newSubmitBranch:
|
||||
try:
|
||||
valueKind, value = widget.submit(slot, fields)
|
||||
if valueKind is not None:
|
||||
value = kind.convertValue(value, valueKind)
|
||||
else:
|
||||
value = kind.defaultValue
|
||||
kind.checkModelValue(slot, value)
|
||||
except faults.BaseFault, f:
|
||||
self.setError(slot.getPath(), f)
|
||||
fields['again'] = '1'
|
||||
fields['error'] = '1'
|
||||
continue
|
||||
#except NotImplementedError:
|
||||
# kind.submitField(slot, fields)
|
||||
try:
|
||||
valueKind, value = widget.submit(slot, fields)
|
||||
if valueKind is not None:
|
||||
value = kind.convertValue(value, valueKind)
|
||||
else:
|
||||
value = kind.defaultValue
|
||||
kind.checkModelValue(slot, value)
|
||||
except faults.BaseFault, f:
|
||||
self.setError(slot.getPath(), f)
|
||||
fields['again'] = '1'
|
||||
fields['error'] = '1'
|
||||
continue
|
||||
#except NotImplementedError:
|
||||
# kind.submitField(slot, fields)
|
||||
|
||||
if not slot.hasValue() or value != slot.getValue():
|
||||
slot.setValue(value)
|
||||
else:
|
||||
kind.submitField(slot, fields)
|
||||
if not slot.hasValue() or value != slot.getValue():
|
||||
slot.setValue(value)
|
||||
|
||||
|
||||
class BaseThing(ThingMixin, proxyThings.BaseThing):
|
||||
|
|
|
@ -100,8 +100,7 @@ class WidgetMixin(things.ThingMixin):
|
|||
label.setAttribute('class', ' '.join(
|
||||
[label.getAttribute('class'), 'fullwidth']))
|
||||
|
||||
if (glasnost.newSubmitBranch and
|
||||
slot.getObject().getError(slot.getPath()) or
|
||||
if slot.getObject().getError(slot.getPath() or
|
||||
slot.getFieldOption(fields, 'error')) and \
|
||||
not fields.has_key('hideErrors'):
|
||||
layout.setAttribute('class', ' '.join(
|
||||
|
@ -210,14 +209,13 @@ class WidgetMixin(things.ThingMixin):
|
|||
if fields.has_key('hideErrors'):
|
||||
return None
|
||||
|
||||
if glasnost.newSubmitBranch:
|
||||
try:
|
||||
error = slot.getObject().getError(slot.getPath())
|
||||
except:
|
||||
raise repr(slot)
|
||||
if error:
|
||||
return X.span(_class = 'error-message')(
|
||||
_(error.uiFaultString))
|
||||
try:
|
||||
error = slot.getObject().getError(slot.getPath())
|
||||
except:
|
||||
raise repr(slot)
|
||||
if error:
|
||||
return X.span(_class = 'error-message')(
|
||||
_(error.uiFaultString))
|
||||
|
||||
errorCode = slot.getFieldOption(fields, 'error')
|
||||
if errorCode:
|
||||
|
@ -1053,7 +1051,7 @@ register(Multi)
|
|||
|
||||
|
||||
class MultiCheck(WidgetMixin, proxyWidgets.MultiCheck):
|
||||
### this widget only works within newSubmitBranch
|
||||
|
||||
def getHtmlViewValue(self, slot, fields, **keywords):
|
||||
kind = slot.getKind()
|
||||
layout = X.ul()
|
||||
|
|
Reference in New Issue