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

modpython throws an AttributeError when trying to read web request headers #1225

Open
prawnsalad opened this issue Jan 4, 2016 · 2 comments

Comments

@prawnsalad
Copy link

prawnsalad commented Jan 4, 2016

Python module snippet:

    def OnWebPreRequest(self, WebSock, sPageName):
        http_headers = WebSock.m_msHeaders

First line of that function causes this traceback:

modpython: <no user>/httpadmin/OnWebPreRequest failed: Traceback (most recent call last):
  File "/home/darren/.znc/modules/httpadmin.py", line 91, in OnWebPreRequest
    http_headers = WebSock.m_msHeaders
  File "/usr/lib/znc/modpython/znc_core.py", line 6569, in <lambda>
    __getattr__ = lambda self, name: _swig_getattr(self, CWebSock, name)
  File "/usr/lib/znc/modpython/znc_core.py", line 74, in _swig_getattr
    return _swig_getattr_nondynamic(self, class_type, name, 0)
  File "/usr/lib/znc/modpython/znc_core.py", line 69, in _swig_getattr_nondynamic
    return object.__getattr__(self, name)
AttributeError: type object 'object' has no attribute '__getattr__'

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/29561929-modpython-throws-an-attributeerror-when-trying-to-read-web-request-headers?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github).
@lrstanley
Copy link

I'm seeing the same issue on my end. Code to replicate the issue:

class api(znc.Module):
    def OnWebPreRequest(self, WebSock, sPageName):
        users = dict(znc.CZNC.Get().GetUserMap())

        for name in users:
            # blockuser module
            mod_blockuser = znc.CZNC.Get().GetModules().FindModule('blockuser')

            if mod_blockuser:
                if mod_blockuser.HasNV(users[name].GetUserName()):
                    # ....
        # ....

Here is the exception from the original script, but alas the same issue it looks like:

Traceback (most recent call last):
  File "/home/znc/.znc/modules/api.py", line 98, in OnWebPreRequest
    if mod_blockuser.HasNV(users[name].GetUserName()):
  File "/home/znc/znc/modules/modpython/znc_core.py", line 3689, in <lambda>
    __getattr__ = lambda self, name: _swig_getattr(self, CModule, name)
  File "/home/znc/znc/modules/modpython/znc_core.py", line 74, in _swig_getattr
    return _swig_getattr_nondynamic(self, class_type, name, 0)
  File "/home/znc/znc/modules/modpython/znc_core.py", line 69, in _swig_getattr_nondynamic
    return object.__getattr__(self, name)
AttributeError: type object 'object' has no attribute '__getattr__'

I'm receiving this as of the latest 1.6.3 source tar.gz, manually compiled.

@lrstanley
Copy link

Looks like my issue may not be 100% related. I was able to track down that it looks like CModule::HasNV was removed sometime before and/or up to 1.6.3, and now CModule::ExistsNV has taken it's place. I am not seeing that the documentation on this matter has been properly updated, as I had to scramble through the c++ source to find it.

Still not quite sure if it's related, but...

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

2 participants