[entity] ensure the .related(entities=False) parameter is honored all the way down (closes #2755994)
As of today, such a call will always fill the relation cache by
calling .entities() on every single related rset entry.
As a consequence, the `limit` parameter handling also had to be fixed.
It was bogus in the following ways:
* not used in the related_rql, hence potentially huge database
requests, but also actually
* foolishly used in the .entities()-calling cache routine we now
bypass (this changeset ticket's main topic)
Now:
* we set a limit on the rql expression, and
* forbid caching if given a non-None limit (as we don't want to make
the cache handling code more complicated than it is already)
With this, entity.unrelated gets a better limit implementation (so the
code in related/unrelated is nice and symmetric)
Risk:
* _cw_relation_cache disappears completely, which is good, but this is
Python, so you never know ...
from cubicweb.devtools import DEFAULT_SOURCES
LOGIN, PASSWORD = DEFAULT_SOURCES['admin'].itervalues()
# Generated by the windmill services transformer
from windmill.authoring import WindmillTestClient
def test_connect():
client = WindmillTestClient(__name__)
client.open(url=u'/')
client.waits.forPageLoad(timeout=u'20000')
client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
client.type(text=LOGIN, id=u'__login')
client.type(text=PASSWORD, id=u'__password')
client.execJS(js=u"$('#loginForm').submit()")
client.waits.forPageLoad(timeout=u'20000')
client.waits.sleep(milliseconds=u'5000')
client.asserts.assertJS(js=u'$(\'.message\').text() == "welcome %s !"' % LOGIN)
client.open(url=u'/logout')
client.waits.forPageLoad(timeout=u'20000')
client.open(url=u'/')
client.waits.forPageLoad(timeout=u'20000')
client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
def test_wrong_connect():
client = WindmillTestClient(__name__)
client.open(url=u'/')
# XXX windmill wants to use its proxy internally on 403 :-(
#client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
#client.type(text=LOGIN, id=u'__login')
#client.type(text=u'novalidpassword', id=u'__password')
#client.click(value=u'log in')
client.open(url=u'/?__login=user&__password=nopassword')
client.waits.forPageLoad(timeout=u'20000')
client.asserts.assertTextIn(validator=u'authentication failure', id=u'loginBox')
client.open(url=u'/')
client.waits.forPageLoad(timeout=u'20000')
client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")