launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #03164
Heads Up: Possible errors from exporting Choice
Hi,
Just a heads up that might save you a few minutes of head-scratching.
I have a branch playing in ec2 right now to catch problems with
exporting Choices. If you do this then you can't actually use the
attributes through the API, but the normal way that webservice tests
are written doesn't catch it.
If you are doing something like:
some_person = exported(Choice(vocabulary=SomeGroupOfPeople))
then you will now see
AssertionError: You exported some_person as an IChoice based
on an SQLObjectVocabularyBase, you should use
lazr.restful.fields.ReferenceChoice instead.
which is trying to be helpful and telling you that you instead
need to do
from lazr.restful.fields import ReferenceChoice
some_person = exported(ReferenceChoice(vocabulary=SomeGroupOfPeople,
schem=IPerson))
All users of the broken way in the current tree should be fixed
(anything that isn't is really broken), but you may find this as you
export something new.
Thanks,
James
Follow ups