Infinite recursion when POSTing Dictionary

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
25 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Infinite recursion when POSTing Dictionary

Sebastian Nozzi-2
Hello guys,

let me start by saying that this is a very promising project, with huge potential and can't wait for it to take over the world :-))

I'm stuck at the following problem. I'm sending a POST-Ajax request, and JQuery seems to enter in an infinite recursion. My suspicion is that this happens while JQuery tries to make sense of the dictionary. If this is wrong, what's the correct way to post a JSON-dictionary of my data?

By the way, I'm doing this in order to POST categories to a PHP "committer" script... Did anyone implement something like that?

Many thanks in advance!!

Sebastian



postData := #{
  'filePath' -> 'NameOfCategory.js'.
  'contents' -> 'ContentsOfCategory' }.

options := #{
   'type' -> 'POST'.
   'data' -> postData.
   'error' -> [window alert: 'Commit of JS failed!'] }.

jQuery ajax: 'commit.php' options: options.

= HANGS = It works when 'data' -> 'isAString'.

Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Nicolas Petton
I'll take a look at the issue. It might very well be because of
dictionaries. Would you mind add an issue to the bug tracker?
https://github.com/NicolasPetton/amber/issues

Thanks,
Nico

On Tue, 2011-10-25 at 20:22 +0200, Sebastian Nozzi wrote:

> Hello guys,
>
> let me start by saying that this is a very promising project, with huge potential and can't wait for it to take over the world :-))
>
> I'm stuck at the following problem. I'm sending a POST-Ajax request, and JQuery seems to enter in an infinite recursion. My suspicion is that this happens while JQuery tries to make sense of the dictionary. If this is wrong, what's the correct way to post a JSON-dictionary of my data?
>
> By the way, I'm doing this in order to POST categories to a PHP "committer" script... Did anyone implement something like that?
>
> Many thanks in advance!!
>
> Sebastian
>
>
>
> postData := #{
>   'filePath' -> 'NameOfCategory.js'.
>   'contents' -> 'ContentsOfCategory' }.
>
> options := #{
>    'type' -> 'POST'.
>    'data' -> postData.
>    'error' -> [window alert: 'Commit of JS failed!'] }.
>
> jQuery ajax: 'commit.php' options: options.
>
> = HANGS = It works when 'data' -> 'isAString'.
>


Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Amber Milan Eskridge
I ran into the same issue. 
I suppose it is because of the way JSProxy and Object>>#asJSONObject is implemented. Object>>#instVarAt: returns the JSProxy's subject, that then gets packed into a JSProxy which then receives asJSONObject when it is serialized:

Object>>#asJSONObject
| object |
object := Object new.
self class instanceVariableNames do: [:each |
object basicAt: each put: (self instVarAt: each) asJSONObject].
^object


On Tue, Oct 25, 2011 at 11:24 PM, Nicolas Petton <[hidden email]> wrote:
I'll take a look at the issue. It might very well be because of
dictionaries. Would you mind add an issue to the bug tracker?
https://github.com/NicolasPetton/amber/issues

Thanks,
Nico

On Tue, 2011-10-25 at 20:22 +0200, Sebastian Nozzi wrote:
> Hello guys,
>
> let me start by saying that this is a very promising project, with huge potential and can't wait for it to take over the world :-))
>
> I'm stuck at the following problem. I'm sending a POST-Ajax request, and JQuery seems to enter in an infinite recursion. My suspicion is that this happens while JQuery tries to make sense of the dictionary. If this is wrong, what's the correct way to post a JSON-dictionary of my data?
>
> By the way, I'm doing this in order to POST categories to a PHP "committer" script... Did anyone implement something like that?
>
> Many thanks in advance!!
>
> Sebastian
>
>
>
> postData := #{
>   'filePath' -> 'NameOfCategory.js'.
>   'contents' -> 'ContentsOfCategory' }.
>
> options := #{
>    'type' -> 'POST'.
>    'data' -> postData.
>    'error' -> [window alert: 'Commit of JS failed!'] }.
>
> jQuery ajax: 'commit.php' options: options.
>
> = HANGS = It works when 'data' -> 'isAString'.
>



Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Sebastian Nozzi-2
In reply to this post by Nicolas Petton
Cool. Thank you!

(I created an issue for it).

On 25 oct, 23:24, Nicolas Petton <[hidden email]> wrote:
> I'll take a look at the issue. It might very well be because of
> dictionaries. Would you mind add an issue to the bug tracker?
Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Sebastian Nozzi-2
In reply to this post by Amber Milan Eskridge
What do you guys then suggest is the correct way to send JSON key/
values through a POST request?

On 26 oct, 10:24, Amber Milan Eskridge <[hidden email]>
wrote:
> I ran into the same issue.
> I suppose it is because of the way JSProxy and Object>>#asJSONObject is
> implemented. Object>>#instVarAt: returns the JSProxy's subject, that then
> gets packed into a JSProxy which then receives asJSONObject when it is
> serialized[...]
Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Stefan Krecher-2

iirc i simply used aDict asJASON

--
sent from my android-phone

Am 01.11.2011 00:39 schrieb "Sebastian Nozzi" <[hidden email]>:
What do you guys then suggest is the correct way to send JSON key/
values through a POST request?

On 26 oct, 10:24, Amber Milan Eskridge <[hidden email]>
wrote:
> I ran into the same issue.
> I suppose it is because of the way JSProxy and Object>>#asJSONObject is
> implemented. Object>>#instVarAt: returns the JSProxy's subject, that then
> gets packed into a JSProxy which then receives asJSONObject when it is
> serialized[...]
Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Sebastian Nozzi-2
Thanks, I tried this.
But it doesn't seem to work for me:

js := #{#hello -> 'amber'} asJSONObject.

<js['hello']>. "nil"
<js.hello>. "nil"

"And with this, no 'data' comes to the server in the request, as if
'js' was empty"

jQuery
  ajax: 'http://localhost:8080/projects/ajaxTest/'
  options: #{
    'type' -> 'POST'.
    'data' -> js.
    'error' -> [window alert: 'Commit failed!']
}.

On 1 nov, 06:48, Stefan Krecher <[hidden email]> wrote:

> iirc i simply used aDict asJASON
>
> --
> sent from my android-phone
> Am 01.11.2011 00:39 schrieb "Sebastian Nozzi" <[hidden email]>:
>
>
>
>
>
>
>
> > What do you guys then suggest is the correct way to send JSON key/
> > values through a POST request?
>
> > On 26 oct, 10:24, Amber Milan Eskridge <[hidden email]>
> > wrote:
> > > I ran into the same issue.
> > > I suppose it is because of the way JSProxy and Object>>#asJSONObject is
> > > implemented. Object>>#instVarAt: returns the JSProxy's subject, that then
> > > gets packed into a JSProxy which then receives asJSONObject when it is
> > > serialized[...]
Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Sebastian Nozzi-2
My apologies. I had changed something in the implementation of
#asJSONObject.

Now askin for the value works, but when sending the ajax-request I
also run into the infinite recursion (which crashes Firefox).

So, corrected:

js := #{#hello -> 'amber'} asJSONObject.

<js['hello']>. "amber"
<js.hello>. "amber"

"Now browser/JQuery enters in infinite recursion... request is never
sent"

jQuery
  ajax: 'http://localhost:8080/projects/ajaxTest/'  
  options: #{
     'type' -> 'POST'.
     'data' -> js.
     'error' -> [window alert: 'Commit failed!']
  }.
Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Nicolas Petton
In reply to this post by Sebastian Nozzi-2
I'm gonna rewrite Dictionary anyway, I hope it will fix it.

Cheers,
Nico

On Mon, 2011-10-31 at 16:39 -0700, Sebastian Nozzi wrote:

> What do you guys then suggest is the correct way to send JSON key/
> values through a POST request?
>
> On 26 oct, 10:24, Amber Milan Eskridge <[hidden email]>
> wrote:
> > I ran into the same issue.
> > I suppose it is because of the way JSProxy and Object>>#asJSONObject is
> > implemented. Object>>#instVarAt: returns the JSProxy's subject, that then
> > gets packed into a JSProxy which then receives asJSONObject when it is
> > serialized[...]


Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Stefan Krecher-2
In reply to this post by Sebastian Nozzi-2
This is what i do:

jQuery 
ajax: ('FileServer?commitPackage:')
options: #{
'type' -> 'POST'.
'success' -> [ :message | window alert: message. ].
'data' -> (dict asJSON).
'error' -> [ :ex | window alert: (ex responseText) ]
}.

where dict is a Dictionary containing Package-Meta-Information and Amber-Sourcecode.
I communicate with serverside amber running on node.js

regards,
Stefan


2011/11/1 Sebastian Nozzi <[hidden email]>
My apologies. I had changed something in the implementation of
#asJSONObject.

Now askin for the value works, but when sending the ajax-request I
also run into the infinite recursion (which crashes Firefox).

So, corrected:

js := #{#hello -> 'amber'} asJSONObject.

<js['hello']>. "amber"
<js.hello>. "amber"

"Now browser/JQuery enters in infinite recursion... request is never
sent"

jQuery
  ajax: 'http://localhost:8080/projects/ajaxTest/'  
 options: #{
     'type' -> 'POST'.
     'data' -> js.
     'error' -> [window alert: 'Commit failed!']
 }.



--
Dipl.-Wirtsch.-Inf. Stefan Krecher
Neulander Str. 17, 27374 Visselhövede
Tel +49(0)4262 958848
mobil +49(0)172 3608616
http://krecher.com
Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Nicolas Petton
Hi,

I pushed a new implementation of Dictionary and removed #asJSONObject as
it was needed to Dictionary only.

Cheers,
Nico

On Tue, 2011-11-01 at 14:01 +0100, Stefan Krecher wrote:

> This is what i do:
>
>
> jQuery
> ajax: ('FileServer?commitPackage:')
> options: #{
> 'type' -> 'POST'.
> 'success' -> [ :message | window alert: message. ].
> 'data' -> (dict asJSON).
> 'error' -> [ :ex | window alert: (ex responseText) ]
> }.
>
>
> where dict is a Dictionary containing Package-Meta-Information and
> Amber-Sourcecode.
> I communicate with serverside amber running on node.js
>
>
> regards,
> Stefan
>
>
>
> 2011/11/1 Sebastian Nozzi <[hidden email]>
>         My apologies. I had changed something in the implementation of
>         #asJSONObject.
>        
>         Now askin for the value works, but when sending the
>         ajax-request I
>         also run into the infinite recursion (which crashes Firefox).
>        
>         So, corrected:
>        
>         js := #{#hello -> 'amber'} asJSONObject.
>        
>        
>         <js['hello']>. "amber"
>         <js.hello>. "amber"
>        
>         "Now browser/JQuery enters in infinite recursion... request is
>         never
>         sent"
>        
>        
>         jQuery
>           ajax: 'http://localhost:8080/projects/ajaxTest/' 
>          options: #{
>              'type' -> 'POST'.
>              'data' -> js.
>              'error' -> [window alert: 'Commit failed!']
>          }.
>
>
>
>
> --
> Dipl.-Wirtsch.-Inf. Stefan Krecher
> Neulander Str. 17, 27374 Visselhövede
> Tel +49(0)4262 958848
> mobil +49(0)172 3608616
> http://krecher.com
>


Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Sebastian Nozzi-2
Thank you!!! Thanks a lot, thank you Nicolas, thank you Stefan!

I must admit, I oversaw the #asJSON method. I was always using
#asJSONObject.
Sorry for this. But apparently a new implementation of Dictionary was
needed anyways?

Whatever. It works perfectly.

Now, since sending a string and not a real JavaScript/JSON object
confuses the server I do a prior step:

dict := Dictionary new.

dict at: ... put: ... .

jsStr := dict asJSON.
js := <eval('('+jsStr+')')>.

... and then I use the evauluated "js" as a parameter, instead of the
String version.

Cheers,

Sebastian
Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Nicolas Petton
On Tue, 2011-11-01 at 09:59 -0700, Sebastian Nozzi wrote:
> dict := Dictionary new.
>
> dict at: ... put: ... .
>
> jsStr := dict asJSON.
> js := <eval('('+jsStr+')')>.

Do you blindly eval request contents on the server-side? If so, that's
very dangerous, and JSON contents should be parsed instead.

Cheers,
Nico

Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Nicolas Petton
In reply to this post by Sebastian Nozzi-2
Sorry, I misread your answer.

I pushed another improvement. Now you can convert an Amber objec to a
JSON object with: #asJSON or to a JSON string with: #asJSONString

Note that they don't use eval() but the native JSON object.

Cheers,
Nico

On Tue, 2011-11-01 at 09:59 -0700, Sebastian Nozzi wrote:

> Thank you!!! Thanks a lot, thank you Nicolas, thank you Stefan!
>
> I must admit, I oversaw the #asJSON method. I was always using
> #asJSONObject.
> Sorry for this. But apparently a new implementation of Dictionary was
> needed anyways?
>
> Whatever. It works perfectly.
>
> Now, since sending a string and not a real JavaScript/JSON object
> confuses the server I do a prior step:
>
> dict := Dictionary new.
>
> dict at: ... put: ... .
>
> jsStr := dict asJSON.
> js := <eval('('+jsStr+')')>.
>
> ... and then I use the evauluated "js" as a parameter, instead of the
> String version.
>
> Cheers,
>
> Sebastian


Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Amber Milan Eskridge
In reply to this post by Nicolas Petton
Hello

Did this drop the support for using non-String keys? 

If so, that would reduce the compatibility with other existing Smalltalk-implementations as well as breaking already existing Amber-code I've written. Also, that would make Amber (a little) less interesting for me, because I think using complexer objects as keys is an advantage over JS and Objective-J I would rather like to keep than loose for whatever reasons.





On Tue, Nov 1, 2011 at 3:59 PM, Nicolas Petton <[hidden email]> wrote:
Hi,

I pushed a new implementation of Dictionary and removed #asJSONObject as
it was needed to Dictionary only.

Cheers,
Nico

On Tue, 2011-11-01 at 14:01 +0100, Stefan Krecher wrote:
> This is what i do:
>
>
> jQuery
> ajax: ('FileServer?commitPackage:')
> options: #{
> 'type' -> 'POST'.
> 'success' -> [ :message | window alert: message. ].
> 'data' -> (dict asJSON).
> 'error' -> [ :ex | window alert: (ex responseText) ]
> }.
>
>
> where dict is a Dictionary containing Package-Meta-Information and
> Amber-Sourcecode.
> I communicate with serverside amber running on node.js
>
>
> regards,
> Stefan
>
>
>
> 2011/11/1 Sebastian Nozzi <[hidden email]>
>         My apologies. I had changed something in the implementation of
>         #asJSONObject.
>
>         Now askin for the value works, but when sending the
>         ajax-request I
>         also run into the infinite recursion (which crashes Firefox).
>
>         So, corrected:
>
>         js := #{#hello -> 'amber'} asJSONObject.
>
>
>         <js['hello']>. "amber"
>         <js.hello>. "amber"
>
>         "Now browser/JQuery enters in infinite recursion... request is
>         never
>         sent"
>
>
>         jQuery
>           ajax: 'http://localhost:8080/projects/ajaxTest/'
>          options: #{
>              'type' -> 'POST'.
>              'data' -> js.
>              'error' -> [window alert: 'Commit failed!']
>          }.
>
>
>
>
> --
> Dipl.-Wirtsch.-Inf. Stefan Krecher
> Neulander Str. 17, 27374 Visselhövede
> Tel <a href="tel:%2B49%280%294262%20958848" value="+494262958848">+49(0)4262 958848
> mobil <a href="tel:%2B49%280%29172%203608616" value="+491723608616">+49(0)172 3608616
> http://krecher.com
>



Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Nicolas Petton
On Tue, 2011-11-01 at 23:19 +0100, Amber Milan Eskridge wrote:
> Hello
>
>
> Did this drop the support for using non-String keys?

There was no support for non-string keys in the past either.

That may come in the future though, together with missing collection
classes like OrderedCollection and SortedCollection.

Cheers,
Nico

>
>
> If so, that would reduce the compatibility with other existing
> Smalltalk-implementations as well as breaking already existing
> Amber-code I've written. Also, that would make Amber (a little) less
> interesting for me, because I think using complexer objects as keys is
> an advantage over JS and Objective-J I would rather like to keep than
> loose for whatever reasons.
>
>
>
>
>
>
>
>
> On Tue, Nov 1, 2011 at 3:59 PM, Nicolas Petton
> <[hidden email]> wrote:
>         Hi,
>        
>         I pushed a new implementation of Dictionary and removed
>         #asJSONObject as
>         it was needed to Dictionary only.
>        
>         Cheers,
>         Nico
>        
>        
>         On Tue, 2011-11-01 at 14:01 +0100, Stefan Krecher wrote:
>         > This is what i do:
>         >
>         >
>         > jQuery
>         > ajax: ('FileServer?commitPackage:')
>         > options: #{
>         > 'type' -> 'POST'.
>         > 'success' -> [ :message | window alert: message. ].
>         > 'data' -> (dict asJSON).
>         > 'error' -> [ :ex | window alert: (ex responseText) ]
>         > }.
>         >
>         >
>         > where dict is a Dictionary containing
>         Package-Meta-Information and
>         > Amber-Sourcecode.
>         > I communicate with serverside amber running on node.js
>         >
>         >
>         > regards,
>         > Stefan
>         >
>         >
>         >
>         > 2011/11/1 Sebastian Nozzi <[hidden email]>
>         >         My apologies. I had changed something in the
>         implementation of
>         >         #asJSONObject.
>         >
>         >         Now askin for the value works, but when sending the
>         >         ajax-request I
>         >         also run into the infinite recursion (which crashes
>         Firefox).
>         >
>         >         So, corrected:
>         >
>         >         js := #{#hello -> 'amber'} asJSONObject.
>         >
>         >
>         >         <js['hello']>. "amber"
>         >         <js.hello>. "amber"
>         >
>         >         "Now browser/JQuery enters in infinite recursion...
>         request is
>         >         never
>         >         sent"
>         >
>         >
>         >         jQuery
>         >           ajax: 'http://localhost:8080/projects/ajaxTest/'
>         >          options: #{
>         >              'type' -> 'POST'.
>         >              'data' -> js.
>         >              'error' -> [window alert: 'Commit failed!']
>         >          }.
>         >
>         >
>         >
>         >
>         > --
>         > Dipl.-Wirtsch.-Inf. Stefan Krecher
>         > Neulander Str. 17, 27374 Visselhövede
>         > Tel +49(0)4262 958848
>         > mobil +49(0)172 3608616
>         > http://krecher.com
>         >
>        
>        
>        
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Amber Milan Eskridge
huh?

| dict |
dict := Dictionary new.
dict add: (20@20) -> 'Landmark'.
dict at: (20@20). "Landmark" 
dict keys first inspect. "a Point"


On Tue, Nov 1, 2011 at 11:34 PM, Nicolas Petton <[hidden email]> wrote:
On Tue, 2011-11-01 at 23:19 +0100, Amber Milan Eskridge wrote:
> Hello
>
>
> Did this drop the support for using non-String keys?

There was no support for non-string keys in the past either.

That may come in the future though, together with missing collection
classes like OrderedCollection and SortedCollection.

Cheers,
Nico

>
>
> If so, that would reduce the compatibility with other existing
> Smalltalk-implementations as well as breaking already existing
> Amber-code I've written. Also, that would make Amber (a little) less
> interesting for me, because I think using complexer objects as keys is
> an advantage over JS and Objective-J I would rather like to keep than
> loose for whatever reasons.
>
>
>
>
>
>
>
>
> On Tue, Nov 1, 2011 at 3:59 PM, Nicolas Petton
> <[hidden email]> wrote:
>         Hi,
>
>         I pushed a new implementation of Dictionary and removed
>         #asJSONObject as
>         it was needed to Dictionary only.
>
>         Cheers,
>         Nico
>
>
>         On Tue, 2011-11-01 at 14:01 +0100, Stefan Krecher wrote:
>         > This is what i do:
>         >
>         >
>         > jQuery
>         > ajax: ('FileServer?commitPackage:')
>         > options: #{
>         > 'type' -> 'POST'.
>         > 'success' -> [ :message | window alert: message. ].
>         > 'data' -> (dict asJSON).
>         > 'error' -> [ :ex | window alert: (ex responseText) ]
>         > }.
>         >
>         >
>         > where dict is a Dictionary containing
>         Package-Meta-Information and
>         > Amber-Sourcecode.
>         > I communicate with serverside amber running on node.js
>         >
>         >
>         > regards,
>         > Stefan
>         >
>         >
>         >
>         > 2011/11/1 Sebastian Nozzi <[hidden email]>
>         >         My apologies. I had changed something in the
>         implementation of
>         >         #asJSONObject.
>         >
>         >         Now askin for the value works, but when sending the
>         >         ajax-request I
>         >         also run into the infinite recursion (which crashes
>         Firefox).
>         >
>         >         So, corrected:
>         >
>         >         js := #{#hello -> 'amber'} asJSONObject.
>         >
>         >
>         >         <js['hello']>. "amber"
>         >         <js.hello>. "amber"
>         >
>         >         "Now browser/JQuery enters in infinite recursion...
>         request is
>         >         never
>         >         sent"
>         >
>         >
>         >         jQuery
>         >           ajax: 'http://localhost:8080/projects/ajaxTest/'
>         >          options: #{
>         >              'type' -> 'POST'.
>         >              'data' -> js.
>         >              'error' -> [window alert: 'Commit failed!']
>         >          }.
>         >
>         >
>         >
>         >
>         > --
>         > Dipl.-Wirtsch.-Inf. Stefan Krecher
>         > Neulander Str. 17, 27374 Visselhövede
>         > Tel <a href="tel:%2B49%280%294262%20958848" value="+494262958848">+49(0)4262 958848
>         > mobil <a href="tel:%2B49%280%29172%203608616" value="+491723608616">+49(0)172 3608616
>         > http://krecher.com
>         >
>
>
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Amber Milan Eskridge
I just tested the new implementation. You're right, it silently converts and still works sometimes. My mistake. 

Well, an added "real" Dictionary would be very appreciated! :)

On Tue, Nov 1, 2011 at 11:41 PM, Amber Milan Eskridge <[hidden email]> wrote:
huh?

| dict |
dict := Dictionary new.
dict add: (20@20) -> 'Landmark'.
dict at: (20@20). "Landmark" 
dict keys first inspect. "a Point"


On Tue, Nov 1, 2011 at 11:34 PM, Nicolas Petton <[hidden email]> wrote:
On Tue, 2011-11-01 at 23:19 +0100, Amber Milan Eskridge wrote:
> Hello
>
>
> Did this drop the support for using non-String keys?

There was no support for non-string keys in the past either.

That may come in the future though, together with missing collection
classes like OrderedCollection and SortedCollection.

Cheers,
Nico

>
>
> If so, that would reduce the compatibility with other existing
> Smalltalk-implementations as well as breaking already existing
> Amber-code I've written. Also, that would make Amber (a little) less
> interesting for me, because I think using complexer objects as keys is
> an advantage over JS and Objective-J I would rather like to keep than
> loose for whatever reasons.
>
>
>
>
>
>
>
>
> On Tue, Nov 1, 2011 at 3:59 PM, Nicolas Petton
> <[hidden email]> wrote:
>         Hi,
>
>         I pushed a new implementation of Dictionary and removed
>         #asJSONObject as
>         it was needed to Dictionary only.
>
>         Cheers,
>         Nico
>
>
>         On Tue, 2011-11-01 at 14:01 +0100, Stefan Krecher wrote:
>         > This is what i do:
>         >
>         >
>         > jQuery
>         > ajax: ('FileServer?commitPackage:')
>         > options: #{
>         > 'type' -> 'POST'.
>         > 'success' -> [ :message | window alert: message. ].
>         > 'data' -> (dict asJSON).
>         > 'error' -> [ :ex | window alert: (ex responseText) ]
>         > }.
>         >
>         >
>         > where dict is a Dictionary containing
>         Package-Meta-Information and
>         > Amber-Sourcecode.
>         > I communicate with serverside amber running on node.js
>         >
>         >
>         > regards,
>         > Stefan
>         >
>         >
>         >
>         > 2011/11/1 Sebastian Nozzi <[hidden email]>
>         >         My apologies. I had changed something in the
>         implementation of
>         >         #asJSONObject.
>         >
>         >         Now askin for the value works, but when sending the
>         >         ajax-request I
>         >         also run into the infinite recursion (which crashes
>         Firefox).
>         >
>         >         So, corrected:
>         >
>         >         js := #{#hello -> 'amber'} asJSONObject.
>         >
>         >
>         >         <js['hello']>. "amber"
>         >         <js.hello>. "amber"
>         >
>         >         "Now browser/JQuery enters in infinite recursion...
>         request is
>         >         never
>         >         sent"
>         >
>         >
>         >         jQuery
>         >           ajax: 'http://localhost:8080/projects/ajaxTest/'
>         >          options: #{
>         >              'type' -> 'POST'.
>         >              'data' -> js.
>         >              'error' -> [window alert: 'Commit failed!']
>         >          }.
>         >
>         >
>         >
>         >
>         > --
>         > Dipl.-Wirtsch.-Inf. Stefan Krecher
>         > Neulander Str. 17, 27374 Visselhövede
>         > Tel <a href="tel:%2B49%280%294262%20958848" value="+494262958848" target="_blank">+49(0)4262 958848
>         > mobil <a href="tel:%2B49%280%29172%203608616" value="+491723608616" target="_blank">+49(0)172 3608616
>         > http://krecher.com
>         >
>
>
>
>
>




Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Nicolas Petton
In reply to this post by Amber Milan Eskridge
On Tue, 2011-11-01 at 23:41 +0100, Amber Milan Eskridge wrote:
> huh?
>
>
> | dict |
> dict := Dictionary new.
> dict add: (20@20) -> 'Landmark'.
> dict at: (20@20). "Landmark"
> dict keys first inspect. "a Point"

dict at: 1 put: 'hello world'.
dict at: '1' -> 'hello world'

You thought it worked because the dictionary kept a copy of the keys in
an array. Still, it stored them as JS object attributes, eg as strings.

Cheers,
Nico

>
>
> On Tue, Nov 1, 2011 at 11:34 PM, Nicolas Petton
> <[hidden email]> wrote:
>         On Tue, 2011-11-01 at 23:19 +0100, Amber Milan Eskridge wrote:
>         > Hello
>         >
>         >
>         > Did this drop the support for using non-String keys?
>        
>        
>         There was no support for non-string keys in the past either.
>        
>         That may come in the future though, together with missing
>         collection
>         classes like OrderedCollection and SortedCollection.
>        
>         Cheers,
>         Nico
>        
>        
>         >
>         >
>         > If so, that would reduce the compatibility with other
>         existing
>         > Smalltalk-implementations as well as breaking already
>         existing
>         > Amber-code I've written. Also, that would make Amber (a
>         little) less
>         > interesting for me, because I think using complexer objects
>         as keys is
>         > an advantage over JS and Objective-J I would rather like to
>         keep than
>         > loose for whatever reasons.
>         >
>         >
>         >
>         >
>         >
>         >
>         >
>         >
>         > On Tue, Nov 1, 2011 at 3:59 PM, Nicolas Petton
>         > <[hidden email]> wrote:
>         >         Hi,
>         >
>         >         I pushed a new implementation of Dictionary and
>         removed
>         >         #asJSONObject as
>         >         it was needed to Dictionary only.
>         >
>         >         Cheers,
>         >         Nico
>         >
>         >
>         >         On Tue, 2011-11-01 at 14:01 +0100, Stefan Krecher
>         wrote:
>         >         > This is what i do:
>         >         >
>         >         >
>         >         > jQuery
>         >         > ajax: ('FileServer?commitPackage:')
>         >         > options: #{
>         >         > 'type' -> 'POST'.
>         >         > 'success' -> [ :message | window alert: message.
>         ].
>         >         > 'data' -> (dict asJSON).
>         >         > 'error' -> [ :ex | window alert: (ex responseText)
>         ]
>         >         > }.
>         >         >
>         >         >
>         >         > where dict is a Dictionary containing
>         >         Package-Meta-Information and
>         >         > Amber-Sourcecode.
>         >         > I communicate with serverside amber running on
>         node.js
>         >         >
>         >         >
>         >         > regards,
>         >         > Stefan
>         >         >
>         >         >
>         >         >
>         >         > 2011/11/1 Sebastian Nozzi
>         <[hidden email]>
>         >         >         My apologies. I had changed something in
>         the
>         >         implementation of
>         >         >         #asJSONObject.
>         >         >
>         >         >         Now askin for the value works, but when
>         sending the
>         >         >         ajax-request I
>         >         >         also run into the infinite recursion
>         (which crashes
>         >         Firefox).
>         >         >
>         >         >         So, corrected:
>         >         >
>         >         >         js := #{#hello -> 'amber'} asJSONObject.
>         >         >
>         >         >
>         >         >         <js['hello']>. "amber"
>         >         >         <js.hello>. "amber"
>         >         >
>         >         >         "Now browser/JQuery enters in infinite
>         recursion...
>         >         request is
>         >         >         never
>         >         >         sent"
>         >         >
>         >         >
>         >         >         jQuery
>         >         >           ajax:
>         'http://localhost:8080/projects/ajaxTest/'
>         >         >          options: #{
>         >         >              'type' -> 'POST'.
>         >         >              'data' -> js.
>         >         >              'error' -> [window alert: 'Commit
>         failed!']
>         >         >          }.
>         >         >
>         >         >
>         >         >
>         >         >
>         >         > --
>         >         > Dipl.-Wirtsch.-Inf. Stefan Krecher
>         >         > Neulander Str. 17, 27374 Visselhövede
>         >         > Tel +49(0)4262 958848
>         >         > mobil +49(0)172 3608616
>         >         > http://krecher.com
>         >         >
>         >
>         >
>         >
>         >
>         >
>        
>        
>        
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Infinite recursion when POSTing Dictionary

Nicolas Petton
In reply to this post by Amber Milan Eskridge
On Tue, 2011-11-01 at 23:48 +0100, Amber Milan Eskridge wrote:
> Well, an added "real" Dictionary would be very appreciated! :)

Yes, I know. The problem is speed, compared using to native JS object
properties.

A dictionary with 2 arrays, one for keys and one for values would work,
but it would also be slower.

Cheers,
Nico

12