leon breedt
2005-Aug-10 21:21 UTC
Re: utf-8 string return types in action web services AND association loading
On 8/11/05, Simen Brekken <simen-qaH4BmqzZooOvCyXmLEu7A@public.gmane.org> wrote:> It''s been an uphill battle but I now have the definitive answer to the > life, the universe and everything - all neatly formatted in UTF-8:Thanks for this, your struggles have been noted. I assume you were the person who filed the report on AWS not loading AR associations? I have a draft patch that works for simple cases, but will fall apart if you declare circular associations (i.e. go into a loop). Say you have: class Customer has_many :accounts end class Account belongs_to :customer end When AWS now tries to walk the associations for serializing to a SOAP representation, the following happens: 1. Have customer instance, see we need to get a list of accounts. Call the "accounts" method to return them. 2. Have account instance, see we have an association for a single :customer, call the "customer" method to retrieve it. However, since the Customer instance returned in (2) is a different instance, and AWS'' serialization is recursive to handle arbitrarily nested structures, you see we''ll go into a loop. Eager loading isn''t going to save us here. So, what I was thinking, was to just rely on a Class:PK key to confer identity for the purposes of serialization. That way, we can keep track of "seen" records in a temporary graph while serializing, and not travel items we''ve visited before. Does this sound like a reasonable approach to you? Regards Leon