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

AttributeError: 'dict' object has no attribute 'root' #124

Closed
michaelkuty opened this issue Mar 18, 2016 · 8 comments
Closed

AttributeError: 'dict' object has no attribute 'root' #124

michaelkuty opened this issue Mar 18, 2016 · 8 comments
Assignees
Labels
Milestone

Comments

@michaelkuty
Copy link

Hello i have worker 1.0.0 version but get this error in 1.1+

Traceback (most recent call last):
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
    worker.init_process()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
    self.load_wsgi()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 63, in load
    return self.load_pasteapp()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 59, in load_pasteapp
    return load_pasteapp(self.cfgurl, self.relpath, global_conf=None)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/pasterapp.py", line 69, in load_pasteapp
    global_conf=global_conf)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 144, in invoke
    **context.loc    Traceback (most recent call last):
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
    worker.init_process()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
    self.load_wsgi()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 63, in load
    return self.load_pasteapp()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 59, in load_pasteapp
    return load_pasteapp(self.cfgurl, self.relpath, global_conf=None)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/pasterapp.py", line 69, in load_pasteapp
    global_conf=global_conf)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 144, in invoke
    **context.local_conf)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/urlmap.py", line 31, in urlmap_factory
    app = loader.get_app(app_name, global_conf=global_conf)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 350, in get_app
    name=name, global_conf=global_conf).create()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/pypiserver/__init__.py", line 152, in paste_app_factory
    c.root = [_make_root(x) for x in root.split("\n") if x.strip()]
AttributeError: 'dict' object has no attribute 'root'
[2016-03-19 00:54:19 +0000] [31393] [INFO] Worker exiting (pid: 31393)
[2016-03-19 00:54:19 +0000] [31388] [INFO] Shutting down: Master
[2016-03-19 00:54:19 +0000] [31388] [INFO] Reason: Worker failed to boot.

al_conf)
File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call
val = callable(_args, *_kw)
File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/urlmap.py", line 31, in urlmap_factory
app = loader.get_app(app_name, global_conf=global_conf)
File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 350, in get_app
name=name, global_conf=global_conf).create()
File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf, *_context.local_conf)
File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call
val = callable(_args, **kw)
File "/srv/pypiserver/local/lib/python2.7/site-packages/pypiserver/init.py", line 152, in paste_app_factory
c.root = [_make_root(x) for x in root.split("\n") if x.strip()]
AttributeError: 'dict' object has no attribute 'root'
[2016-03-19 00:54:19 +0000] [31393] [INFO] Worker exiting (pid: 31393)
[2016-03-19 00:54:19 +0000] [31388] [INFO] Shutting down: Master
[2016-03-19 00:54:19 +0000] [31388] [INFO] Reason: Worker failed to boot.

@ankostis ankostis self-assigned this Mar 20, 2016
@ankostis ankostis added this to the Next 1.2.x Release milestone Mar 20, 2016
@ankostis
Copy link
Member

@michaelkuty can you check the latest commit fixes the problem?
I don't have any experience with paste.

@michaelkuty
Copy link
Author

Yes, this was first thing which I tried before issuing

(pypiserver)root@leonardo-multi:/srv/pypiserver# gunicorn --paste paste.ini 
[2016-03-21 18:41:00 +0000] [14252] [INFO] Starting gunicorn 19.4.5
[2016-03-21 18:41:00 +0000] [14252] [INFO] Listening at: http://0.0.0.0:9000 (14252)
[2016-03-21 18:41:00 +0000] [14252] [INFO] Using worker: sync
[2016-03-21 18:41:00 +0000] [14257] [INFO] Booting worker with pid: 14257
[2016-03-21 18:41:01 +0000] [14258] [INFO] Booting worker with pid: 14258
[2016-03-21 18:41:01 +0000] [14257] [ERROR] Exception in worker process:
Traceback (most recent call last):
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
    worker.init_process()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
    self.load_wsgi()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 63, in load
    return self.load_pasteapp()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 59, in load_pasteapp
    return load_pasteapp(self.cfgurl, self.relpath, global_conf=None)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/pasterapp.py", line 69, in load_pasteapp
    global_conf=global_conf)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 144, in invoke
    **context.local_conf)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/urlmap.py", line 31, in urlmap_factory
    app = loader.get_app(app_name, global_conf=global_conf)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 350, in get_app
    name=name, global_conf=global_conf).create()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/srv/pypiserver/src/pypiserver/pypiserver/__init__.py", line 154, in paste_app_factory
    upd_bool_attr_from_dict_str_item(c, 'redirect_to_fallback', local_conf)
  File "/srv/pypiserver/src/pypiserver/pypiserver/__init__.py", line 140, in upd_bool_attr_from_dict_str_item
    setattr(conf, attr, str2bool(sdict.pop(attr, None), getattr(conf, attr)))
AttributeError: 'dict' object has no attribute 'redirect_to_fallback'

I use gunicorn + paste

[composite:main]
use = egg:Paste#urlmap
/unstable/ = unstable
/ = stable

[app:stable]
use = egg:pypiserver#main
root = /srv/pypiserver/stable
authenticated = update,download
password_file = /srv/pypiserver/htpasswd.txt

[app:unstable]
use = egg:pypiserver#main
root = /srv/pypiserver/unstable
htpasswd=/srv/pypiserver/htpasswd.txt

[server:main]
use = egg:gunicorn#main
host = 0.0.0.0
port = 9000
workers = 2
accesslog = -

   gunicorn==19.4.5
   passlib==1.6.5
   Paste==2.0.3
   PasteDeploy==1.5.2

ankostis added a commit to ankostis/pypiserver that referenced this issue Mar 21, 2016
@michaelkuty
Copy link
Author

@ankostis with your no2

Traceback (most recent call last):
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
    worker.init_process()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
    self.load_wsgi()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 63, in load
    return self.load_pasteapp()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 59, in load_pasteapp
    return load_pasteapp(self.cfgurl, self.relpath, global_conf=None)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/gunicorn/app/pasterapp.py", line 69, in load_pasteapp
    global_conf=global_conf)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 144, in invoke
    **context.local_conf)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/util.py", line 58, in fix_call
    reraise(*exc_info)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/compat.py", line 23, in reraise
    exec('raise t, e, tb', dict(t=t, e=e, tb=tb))
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/urlmap.py", line 31, in urlmap_factory
    app = loader.get_app(app_name, global_conf=global_conf)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 350, in get_app
    name=name, global_conf=global_conf).create()
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/util.py", line 58, in fix_call
    reraise(*exc_info)
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/compat.py", line 23, in reraise
    exec('raise t, e, tb', dict(t=t, e=e, tb=tb))
  File "/srv/pypiserver/local/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/srv/pypiserver/src/pypiserver/pypiserver/__init__.py", line 157, in paste_app_factory
    return app(**vars(c))
TypeError: vars() argument must have __dict__ attribute

@michaelkuty
Copy link
Author

i have suggestion to use simple dictionaray object with dot access

class Config(dict):

    def __getattr__(self, attr):
        return self.get(attr, None)

    __setattr__ = dict.__setitem__
    __delattr__ = dict.__delitem__

for me is this solution number one which works

ankostis added a commit to ankostis/pypiserver that referenced this issue Mar 21, 2016
@ankostis
Copy link
Member

Your suggestion works well for preserving conf as an class-instance.
But currently conf is a dict, so the code must be simpler.

Check the last one, and it would be great if you could come up with some test; any test is better than nothing, even described in words.

@michaelkuty
Copy link
Author

this is standard dictionary which allows
conf = Config({'mykey': value})
conf['mykey']
conf.mykey

also supports conf.mykey = value or conf['mykey'] = value
this is why i love this simple magic

@michaelkuty
Copy link
Author

Last one works well. Thanks a lot !

@ankostis
Copy link
Member

Your conf-suggestion is really terse - I will use it in my code, thanks (but note that it contains 2 dict instances)

ankostis added a commit that referenced this issue Mar 22, 2016
FIX #124: Convert forgotten attr-access-->dict-access & TCs for paste-factory
michaelkuty pushed a commit to michaelkuty/pypiserver that referenced this issue Jun 27, 2016
- Obviously a TC is needed there.
michaelkuty pushed a commit to michaelkuty/pypiserver that referenced this issue Jun 27, 2016
michaelkuty pushed a commit to michaelkuty/pypiserver that referenced this issue Jun 27, 2016
michaelkuty pushed a commit to michaelkuty/pypiserver that referenced this issue Jun 27, 2016
FIX pypiserver#124: Convert forgotten attr-access-->dict-access & TCs for paste-factory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants