[Launchpad-dev] Heads Up: Possible errors from exporting Choice

2010-04-09 Thread James Westby
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


___
Mailing list: https://launchpad.net/~launchpad-dev
Post to : launchpad-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-dev
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-dev] Heads Up: Possible errors from exporting Choice

2010-04-09 Thread Francis J. Lacoste
On April 9, 2010, James Westby wrote:
 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.
 

Wow, thanks a lot James for cleaning this up!


-- 
Francis J. Lacoste
francis.laco...@canonical.com


signature.asc
Description: This is a digitally signed message part.
___
Mailing list: https://launchpad.net/~launchpad-dev
Post to : launchpad-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-dev
More help   : https://help.launchpad.net/ListHelp