DottedNameResolver and other stuff lifted from pyramid.path