method __getattr__ is not inherited from parent class

Posted by ?????? on Stack Overflow See other posts from Stack Overflow or by ??????
Published on 2011-02-03T15:17:40Z Indexed on 2011/02/03 15:25 UTC
Read the original article Hit count: 289

Filed under:
|
|
|
|

Trying to subclass mechanize.Browser class:

from mechanize import Browser

class LLManager(Browser, object):
    IS_AUTHORIZED = False
    def __init__(self, login = "", passw = "", *args, **kwargs):
        super(LLManager, self).__init__(*args, **kwargs)
        self.set_handle_robots(False)

But when I make something like this:

lm["Widget[LinksList]_link_1_title"] = anc

then I get an error:

Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    lm["Widget[LinksList]_link_1_title"] = anc
TypeError: 'LLManager' object does not support item assignment

Browser class have overridden method __getattr__ as shown:

def __getattr__(self, name):
    # pass through _form.HTMLForm methods and attributes
    form = self.__dict__.get("form")
    if form is None:
        raise AttributeError(
            "%s instance has no attribute %s (perhaps you forgot to "
            ".select_form()?)" % (self.__class__, name))
    return getattr(form, name)

Why my class or instance don't get this method as in parent class?

© Stack Overflow or respective owner

Related posts about python

Related posts about class