[Seaside] Pharo 2.0 scriptaculous does not work
Sven Van Caekenberghe
sven at stfx.eu
Fri Jun 7 09:23:26 UTC 2013
Sabine,
On 07 Jun 2013, at 10:44, Sabine Knöfel <sabine.knoefel at gmail.com> wrote:
> Another Point: I use this to get exchange rates from openexchangerates:
>
> (ZnClient new
> systemPolicy;
> http;
> host: 'openexchangerates.org'
> )
> path: 'api/latest.json?app_id=2ddac6f47cf74936a920beb22ac55704' ;
> get
>
> in 1.4 -> this works fine: {
> "disclaimer": "E..../",
> "license": "Data source....se/",
> "timestamp": 1370592069,
> "base": "USD",
> "rates": {
> "AED": 3.672719,
> "AFN": 54.766067,
> "ALL": 106.609251,
> "AMD": 418.215,
> ...
>
> in 2.0 -> the result is a byte array. #[123 10 32 32 34 100 105 115 99
> 108 97 105
>
> Do I have to change something here?
> Sabine
That is indeed a bug. Here is the fix (not yet in any config):
===
Name: Zinc-Resource-Meta-Core-SvenVanCaekenberghe.15
Author: SvenVanCaekenberghe
Time: 7 June 2013, 11:18:29.493 am
UUID: b1059f61-d7a1-44b0-bb0a-f558fbbec3c8
Ancestors: Zinc-Resource-Meta-Core-SvenVanCaekenberghe.14
Fixed a bug in ZnMimeType>>#isBinary (thx Sabine K for reporting this)
==
I would write your example as follows:
ZnClient new
systemPolicy;
http;
host: 'openexchangerates.org';
path: 'api/latest.json';
queryAt: 'app_id' put: '2ddac6f47cf74936a920beb22ac55704';
accept: ZnMimeType applicationJson;
contentReader: [ :entity | NeoJSONReader fromString: entity contents ];
get.
It integrates the JSON parsing step so you get a nice dictionary back. The systemPolicy with the accept makes sure you only do the parsing when application/json comes back. You can also add an #ifFail: block for general error handling should the request fail.
Sven
More information about the seaside
mailing list