Package lxml :: Module pyclasslookup :: Class PythonElementClassLookup

[hide private]
[frames] | no frames]

# Class PythonElementClassLookup

source code

                      object --+
                               |
        etree.ElementClassLookup --+
                                   |
    etree.FallbackElementClassLookup --+
                                       |
                                      PythonElementClassLookup

PythonElementClassLookup(self, fallback=None) Element class lookup based on a subclass method.

To use it, inherit from this class and override the lookup method to lookup the element class for a node:

    lookup(self, document, node_proxy)

The first argument is the opaque document instance that contains the Element. The second arguments is a lightweight Element proxy implementation that is only valid during the lookup. Do not try to keep a reference to it. Once the lookup is done, the proxy will be invalid.

If you return None from this method, the fallback will be called.

Instance Methods | [hide private]

__init__(self, fallback=None) x.__init__(...) initializes x; see x.__class__.__doc__ for signature | source code

a new object with type S, a subtype of T

__new__(T, S, ...) | source code

lookup(self, doc, element) Override this method to implement your own lookup scheme. | source code

Inherited from `etree.FallbackElementClassLookup`: `set_fallback` Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Properties | [hide private]

Inherited from `etree.FallbackElementClassLookup`: `fallback` Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, fallback=None)
(Constructor)

source code

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__

### __new__(T, S, ...)

source code

Returns: a new object with type S, a subtype of T
Overrides: object.__new__