Issue #109 open

Infinite loop. 'model' should be in Emitter.RESERVED_FIELDS

Khalid Goudeaux
created an issue

The method field lookup on handlers in Emitter returns Handler.model instead of Instance.model when 'model' is specified in fields.

Given this mapper for Django's ContentType {{{ class ContentTypeHandler(BaseHandler): model = ContentType fields = ('name', 'app_label', 'model') }}}

the Emitter won't access the CharField field 'model' on the ContentType instance. Rather it will use the ContentType class, check if it's callable (it is) and start an infinite loop attempting to resolve 'model'.

If you look at the code below, you can see that Handler.model is considered a valid field because it's not in RESERVED_FIELDS and is callable.

{{{ RESERVED_FIELDS = set([ 'read', 'update', 'create', 'delete', 'model', 'anonymous', 'allowed_methods', 'fields', 'exclude' ])

def method_fields(self, handler, fields): if not handler: return { }

ret = dict()

for field in fields - Emitter.RESERVED_FIELDS:
    t = getattr(handler, str(field), None)

    if t and callable(t):
        ret[field] = t

return ret

}}}

Comments (2)

  1. Log in to comment