Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation for SubstanceD initial params (the "substanced.*" in configfile.ini) #284

Open
enkidulan opened this issue Jul 7, 2016 · 0 comments

Comments

@enkidulan
Copy link
Contributor

In case if someone didn't fill the initial params in config file, in this particular case it was substanced.initial_login, he/she will get quite confusing traceback. I guess it would be great to add validation for config file values with more sane error messages. Also may have sense to add some validation on user creation as well in case if someone try to pass.

The traceback looks like this, and its not that clear that issue is with not setted config values:

Traceback (most recent call last):
  File "bin/pserve", line 81, in <module>
    sys.exit(pyramid.scripts.pserve.main())
  File "/home/mshalenyi/.buildout/eggs/pyramid-1.7-py3.5.egg/pyramid/scripts/pserve.py", line 60, in main
    return command.run()
  File "/home/mshalenyi/.buildout/eggs/pyramid-1.7-py3.5.egg/pyramid/scripts/pserve.py", line 371, in run
    global_conf=vars)
  File "/home/mshalenyi/.buildout/eggs/pyramid-1.7-py3.5.egg/pyramid/scripts/pserve.py", line 406, in loadapp
    return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
  File "/home/mshalenyi/.buildout/eggs/PasteDeploy-1.5.2-py3.5.egg/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/home/mshalenyi/.buildout/eggs/PasteDeploy-1.5.2-py3.5.egg/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/home/mshalenyi/.buildout/eggs/PasteDeploy-1.5.2-py3.5.egg/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/home/mshalenyi/.buildout/eggs/PasteDeploy-1.5.2-py3.5.egg/paste/deploy/loadwsgi.py", line 146, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/home/mshalenyi/.buildout/eggs/PasteDeploy-1.5.2-py3.5.egg/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/home/mshalenyi/projects/enkiblog/enkiblog/__init__.py", line 15, in main
    return config.make_wsgi_app()
  File "/home/mshalenyi/.buildout/eggs/pyramid-1.7-py3.5.egg/pyramid/config/__init__.py", line 997, in make_wsgi_app
    self.registry.notify(ApplicationCreated(app))
  File "/home/mshalenyi/.buildout/eggs/pyramid-1.7-py3.5.egg/pyramid/registry.py", line 91, in notify
    [ _ for _ in self.subscribers(events, None) ]
  File "/home/mshalenyi/.buildout/eggs/zope.interface-4.2.0-py3.5-linux-x86_64.egg/zope/interface/registry.py", line 328, in subscribers
    return self.adapters.subscribers(objects, provided)
  File "/home/mshalenyi/.buildout/eggs/zope.interface-4.2.0-py3.5-linux-x86_64.egg/zope/interface/adapter.py", line 596, in subscribers
    subscription(*objects)
  File "/home/mshalenyi/.buildout/eggs/pyramid-1.7-py3.5.egg/pyramid/config/adapters.py", line 103, in derived_subscriber
    return subscriber(arg[0])
  File "/home/mshalenyi/.buildout/eggs/substanced-1.0a1-py3.5.egg/substanced/catalog/subscribers.py", line 138, in on_startup
    root = app.root_factory(request)
  File "/home/mshalenyi/.buildout/eggs/substanced-1.0a1-py3.5.egg/substanced/db/__init__.py", line 22, in root_factory
    app_root = registry.content.create('Root')
  File "/home/mshalenyi/.buildout/eggs/substanced-1.0a1-py3.5.egg/substanced/content/__init__.py", line 62, in create
    callback(inst, self.registry)
  File "/home/mshalenyi/.buildout/eggs/substanced-1.0a1-py3.5.egg/substanced/root/__init__.py", line 88, in after_create
    user = principals.add_user(login, password, email, registry=registry)
  File "/home/mshalenyi/.buildout/eggs/substanced-1.0a1-py3.5.egg/substanced/principal/__init__.py", line 128, in add_user
    self['users'][login] = user
  File "/home/mshalenyi/.buildout/eggs/substanced-1.0a1-py3.5.egg/substanced/folder/__init__.py", line 373, in __setitem__
    return self.add(name, other)
  File "/home/mshalenyi/.buildout/eggs/substanced-1.0a1-py3.5.egg/substanced/folder/__init__.py", line 452, in add
    name = self.check_name(name, reserved_names)
  File "/home/mshalenyi/.buildout/eggs/substanced-1.0a1-py3.5.egg/substanced/folder/__init__.py", line 423, in check_name
    name = self.validate_name(name, reserved_names=reserved_names)
  File "/home/mshalenyi/.buildout/eggs/substanced-1.0a1-py3.5.egg/substanced/folder/__init__.py", line 397, in validate_name
    raise ValueError("Name must not be empty")
ValueError: Name must not be empty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant