Choice()'s can take a string for their vocabulary, but lazr.restful can't handle this
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lazr.restful |
Triaged
|
Low
|
Unassigned |
Bug Description
I have the following field defined in my IMessageApproval interface:
status = exported(Choice(
Zope has no problem with this, but lazr.restful cannot find the
PostedMessageStatus enum:
...
File "/home/
ComponentLo
However, if I change the field to use the actual enum, it works fine:
status = exported(Choice(
Output from my test...
disposal_
disposed_
mailing_
message_id: u'<aardvark>'
posted_
posted_date: u'2000-
resource_
self_link: u'http://
status: u'New status'
In this particular case, it's fine to change the vocabulary argument from the
string to the enum, but this won't always be the case due to circular
references.
Changed in lazr.restful: | |
status: | New → Triaged |
importance: | Undecided → Low |
Full traceback
pprint_ collection( messages) barry/projects/ launchpad/ pristine/ lib/zope/ testing/ doctest. py", line 1360, in __run holds.txt[ 17]>", line 1, in ? barry/projects/ launchpad/ 385180- mmapi/lib/ lazr/restful/ testing/ webservice. py", line 132, in pprint_collection jsonBody( ) barry/projects/ launchpad/ 385180- mmapi/lib/ lazr/restful/ testing/ webservice. py", line 435, in jsonBody self.getOutput( ))
Exception raised:
Traceback (most recent call last):
File "/home/
save_stdout = sys.stdout
File "<doctest xx-message-
File "/home/
collection = collection.
File "/home/
raise ValueError(
ValueError: HTTP/1.1 500 Internal Server Error
Content-Length: 2990
Content-Type: text/plain
X-Lazr-Oopsid: OOPS-1320T17
(<Interface Class zope.schema. interfaces. IVocabularyFact ory>, 'PostedMessageS tatus')
Traceback (most recent call last): barry/projects/ launchpad/ pristine/ lib/zope/ publisher/ publish. py", line 133, in publish barry/projects/ launchpad/ 385180- mmapi/lib/ lazr/restful/ publisher. py", line 154, in callObject barry/projects/ launchpad/ 385180- mmapi/lib/ canonical/ launchpad/ webapp/ publication. py", line 373, in callObject getPositionalAr guments( ), request) barry/projects/ launchpad/ pristine/ lib/zope/ publisher/ publish. py", line 108, in mapply barry/projects/ launchpad/ pristine/ lib/zope/ publisher/ publish. py", line 114, in debug_call barry/projects/ launchpad/ devel/lib/ lazr/restful/ _resource. py", line 820, in __call__ barry/projects/ launchpad/ devel/lib/ lazr/restful/ _resource. py", line 1294, in do_GET omGET(operation _name) barry/projects/ launchpad/ devel/lib/ lazr/restful/ _resource. py", line 628, in handleCustomGET barry/projects/ launchpad/ pristine/ lib/lazr/ restful/ _operation. py", line 59, in __call__ barry/projects/ launchpad/ pristine/ lib/lazr/ restful/ declarations. py", line 833, in call barry/projects/ launchpad/ pristine/ lib/lazr/ restful/ _operation. py", line 94, in encodeResult barry/projects/ launchpad/ eggs/simplejson -2.0.9- py2.4-linux- i686.egg/ simplejson/ __init_ _.py", line 236, in dumps
separators= separators, encoding=encoding, default=default, barry/projects/ launchpad/ eggs/simplejson -2.0.9- py2.4-linux- i686.egg/ simplejson/ encoder. py", line 200, in encode barry/projects/ launchpad/ eggs/simplejson -2.0.9- py2.4-linux- i686.egg/ simplejson/ encoder. py", line 260, in iterencode barry/projects/ launchpad/ devel/lib/ lazr/restful/ _resource. py", line 131, in default e(obj). toDataForJSON( ) barry/projects/ launchpad/ devel/lib/ lazr/restful/ _resource. py", line 1227, in toDataForJSON cture(self. JSON_TYPE) barry/projects/ launchp. ..
File "/home/
File "/home/
value = super(
File "/home/
return mapply(ob, request.
File "/home/
File "/home/
File "/home/
result = self.do_GET()
File "/home/
result = self.handleCust
File "/home/
return operation()
File "/home/
File "/home/
File "/home/
File "/home/
File "/home/
chunks = self.iterencode(o, _one_shot=True)
File "/home/
return _iterencode(o, 0)
File "/home/
return IJSONPublishabl
File "/home/
return self.toDataStru
File "/home/