Dne 30.6.2015 v 12:29 Simo Sorce napsal(a):
On Tue, 2015-06-30 at 11:47 +0200, Jan Cholasta wrote:
Dne 27.6.2015 v 00:21 Simo Sorce napsal(a):
If I try to create a custom api with something like:
myapi = create_api(mode=None)
myapi.finalize()

I get back a stacktrace in the aci plugin.

The aci plugin assumes the general 'api' has been already inizialized
and dereferences directly api.env.container_user and other stuff.

Do I always have to api.finalize() before creating new api objects ?
Is there a way to load only the env (all I am really interested in)
without loading any plugin ?

The bootstrap method initializes env:

myapi = create_api(mode=None)
myapi.bootstrap()


That's not what I am saying.

What I am saying is that if you *do not* finalize "api", then when you
try to finalize any other myownapi thing you built via create_api() it
blows up, because (at least) the aci module references directly "api",
but "api" is not finalized yet and does not have the env attributes the
aci plugin tries to use.


Try this:

python
from ipalib import api, create_api
myapi = create_api()
myapi.finalize()

This ^^^ breaks.

However if you do:
from ipalib import api, create_api
myapi = create_api()
api.finalize()
myapi.finalize()

This works, as "api" has been finalized.

I see. Unfortunately, this is a limitation that has not been removed yet - there is a lot of old code that references ipalib.api directly which needs to be fixed.

--
Jan Cholasta

--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to