﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18538	type(SimpleLazyObject) returns SimpleLazyObject rather than type(_wrapped)	Jeremy Dunck	nobody	"In 1.4 we introduced request.user as a SimpleLazyObject.  This has caused some [[https://code.djangoproject.com/ticket/16563|bugs]] caused by abstraction leakage.

Today we ran across another - I'm expecting Router.allow_relation to be called with model instances (https://docs.djangoproject.com/en/1.4/topics/db/multi-db/#allow_relation) and using type() to get to the Model subclass.  

type(obj1)._meta fails because type(obj1) returns SimpleLazyObject.

I've worked around by calling obj1.__class__ (which is specifically proxied), but I'm noting the leakage here.  I think there's nothing to be done (type is implemented in C (PyObject_Type) and reaches into the python object structure) but I am noting in here in case someone else has a bright idea for fixing it.

At least this ticket can serve as a workaround to others coming across this surprise. :)

Tough call on ""component"", could be ORM (since router in this case) or .auth (since that's what's Lazy'd)."	Bug	new	Database layer (models, ORM)	1.4	Normal				Unreviewed	0	0	0	0	0	0
