accept backends name with only letters and digits

This commit is contained in:
Romain Bignon 2010-11-14 22:18:56 +01:00
commit 0746942e02
2 changed files with 7 additions and 1 deletions

View file

@ -21,6 +21,7 @@ from PyQt4.QtGui import QDialog, QTreeWidgetItem, QLabel, QFormLayout, \
QDialogButtonBox QDialogButtonBox
from PyQt4.QtCore import SIGNAL, Qt, QVariant, QUrl from PyQt4.QtCore import SIGNAL, Qt, QVariant, QUrl
import re
from logging import warning from logging import warning
from weboob.capabilities.account import ICapAccount, Account, AccountRegisterError from weboob.capabilities.account import ICapAccount, Account, AccountRegisterError
@ -206,6 +207,11 @@ class BackendCfg(QDialog):
self.tr('Please specify a backend name')) self.tr('Please specify a backend name'))
return return
if self.ui.nameEdit.isEnabled() and not re.match(r'^[\w\-_]+$', bname):
QMessageBox.critical(self, self.tr('Invalid value'),
self.tr('The backend name can only contain letters and digits'))
return
if self.ui.proxyBox.isChecked(): if self.ui.proxyBox.isChecked():
params['_proxy'] = unicode(self.ui.proxyEdit.text()) params['_proxy'] = unicode(self.ui.proxyEdit.text())
if not params['_proxy']: if not params['_proxy']:

View file

@ -241,7 +241,7 @@ class ReplApplication(Cmd, BaseApplication):
except BackendAlreadyExists: except BackendAlreadyExists:
print 'Backend "%s" is already configured in file "%s"' % (name, self.weboob.backends_config.confpath) print 'Backend "%s" is already configured in file "%s"' % (name, self.weboob.backends_config.confpath)
while self.ask('Add new instance of "%s" backend?' % name, default=False): while self.ask('Add new instance of "%s" backend?' % name, default=False):
new_name = self.ask('Please give new instance name (could be "%s_1")' % name, regexp=u'^[\d\w_-]+$') new_name = self.ask('Please give new instance name (could be "%s_1")' % name, regexp=r'^[\w\-_]+$')
try: try:
self.weboob.backends_config.add_backend(new_name, name, params) self.weboob.backends_config.add_backend(new_name, name, params)
print 'Backend "%s" successfully added.' % new_name print 'Backend "%s" successfully added.' % new_name