Morten
2007-Jan-31 01:40 UTC
Troubleshooting "can''t modify frozen object" in tzinfo_timezone
Hi. Off and on I get a "can''t modify frozen object" when working with the tzinfo_timezone plugin. I''ve added some debugging in the code to try and track down what goes wrong: def tzinfo RAILS_DEFAULT_LOGGER.debug("TZINFO STATE ''#{@tzinfo}'' class #{@tzinfo.class} frozen? #{@tzinfo.frozen?}") return @tzinfo if @tzinfo RAILS_DEFAULT_LOGGER.debug("TZINFO ASSIGN TO #{MAPPING[name]}") begin @tzinfo = MAPPING[name] rescue TypeError => type_error RAILS_DEFAULT_LOGGER.debug("TZINFO TYPE ERROR #{type_error}") raise type_error end RAILS_DEFAULT_LOGGER.debug("TZINFO ASSIGNED TO #{@tzinfo}") if String === @tzinfo @tzinfo = TZInfo::Timezone.get(@tzinfo) MAPPING[name] = @tzinfo end @tzinfo end When the error occurs, the following makes it to the log: TZINFO STATE '''' class NilClass frozen? false TZINFO ASSIGN TO Europe/Amsterdam TZINFO TYPE ERROR can''t modify frozen object Which means, that @tzinfo is nil, and yet, the line @tzinfo = MAPPING[name] Causes a TypeError. MAPPING is a hash. I''m mildly confused. Anyone able to shed some light on what might be the issue or how to dig further into the problem? ruby 1.8.4 (2005-12-24) [x86_64-linux] Thanks. Morten --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Zack Chandler
2007-Jan-31 04:47 UTC
Re: Troubleshooting "can''t modify frozen object" in tzinfo_timezone
On 1/30/07, Morten <usenet-Mr43XxmkdKzQT0dZR+AlfA@public.gmane.org> wrote:> > Hi. Off and on I get a "can''t modify frozen object" when working with > the tzinfo_timezone plugin. I''ve added some debugging in the code to > try and track down what goes wrong: > > def tzinfo > RAILS_DEFAULT_LOGGER.debug("TZINFO STATE ''#{@tzinfo}'' class > #{@tzinfo.class} frozen? #{@tzinfo.frozen?}") > return @tzinfo if @tzinfo > RAILS_DEFAULT_LOGGER.debug("TZINFO ASSIGN TO #{MAPPING[name]}") > begin > @tzinfo = MAPPING[name] > rescue TypeError => type_error > RAILS_DEFAULT_LOGGER.debug("TZINFO TYPE ERROR #{type_error}") > raise type_error > end > RAILS_DEFAULT_LOGGER.debug("TZINFO ASSIGNED TO #{@tzinfo}") > if String === @tzinfo > @tzinfo = TZInfo::Timezone.get(@tzinfo) > MAPPING[name] = @tzinfo > end > @tzinfo > end > > > When the error occurs, the following makes it to the log: > > TZINFO STATE '''' class NilClass frozen? false > TZINFO ASSIGN TO Europe/Amsterdam > TZINFO TYPE ERROR can''t modify frozen object > > Which means, that @tzinfo is nil, and yet, the line > > @tzinfo = MAPPING[name] > > Causes a TypeError. MAPPING is a hash. I''m mildly confused. Anyone > able to shed some light on what might be the issue or how to dig > further into the problem? > > ruby 1.8.4 (2005-12-24) [x86_64-linux] > > Thanks. > > Morten > > > > >Morten, Not sure what''s causing this exactly. Why are you trying to load the tzinfo from a MAPPING hash? Check out the timezone code in mephisto for a really slick way to handle timezones. It helped me quite a bit. Hope this helps. -- Zack Chandler http://depixelate.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Morten
2007-Jan-31 17:22 UTC
Re: Troubleshooting "can''t modify frozen object" in tzinfo_timezone
Zack,> Morten, > > Not sure what''s causing this exactly. Why are you trying to load the > tzinfo from a MAPPING hash?The code I''m trying to debug is actually tzinfo_timezone.rb, so the error occurs within the plugin. I just use it like: In my user model: composed_of :tz, :class_name => ''TimeZone'', :mapping => %w(time_zone name) In my view: <%= format_date(@current_user.tz.utc_to_local(entry.created_at)) %> The hash is part of tzinfo_timezone.rb''s way of associating time zones with locations. Thanks for the tip on Mephisto, I''ll look into their way og handling time zones. Br, Morten --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Zack Chandler
2007-Jan-31 17:44 UTC
Re: Troubleshooting "can''t modify frozen object" in tzinfo_timezone
On 1/31/07, Morten <usenet-Mr43XxmkdKzQT0dZR+AlfA@public.gmane.org> wrote:> > > Zack, > > > Morten, > > > > Not sure what''s causing this exactly. Why are you trying to load the > > tzinfo from a MAPPING hash? > > The code I''m trying to debug is actually tzinfo_timezone.rb, so the > error occurs within the plugin. I just use it like: > > In my user model: > > composed_of :tz, :class_name => ''TimeZone'', :mapping => %w(time_zone > name) > > In my view: > > <%= format_date(@current_user.tz.utc_to_local(entry.created_at)) %> > > The hash is part of tzinfo_timezone.rb''s way of associating time zones > with locations. > > Thanks for the tip on Mephisto, I''ll look into their way og handling > time zones.This line should be: composed_of :tz, :class_name => ''TzinfoTimezone'', :mapping => %w(time_zone name) I think the mappings are slightly different between the two which would explain the intermittent crashes. -- Zack Chandler http://depixelate.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Tieg
2007-Feb-12 01:18 UTC
Re: Troubleshooting "can''t modify frozen object" in tzinfo_timezone
The tzinfo_timezone plugin, in the init.rb script, actually replaces Rails'' TimeZone class with TzinfoTimezone, so using either one of those should work as the :class_name (I think?), -tieg On Jan 31, 10:44 am, "Zack Chandler" <zackchand...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 1/31/07, Morten <use...-Mr43XxmkdKzQT0dZR+AlfA@public.gmane.org> wrote: > > > > > > > Zack, > > > > Morten, > > > > Not sure what''s causing this exactly. Why are you trying to load the > > > tzinfo from a MAPPING hash? > > > The code I''m trying to debug is actually tzinfo_timezone.rb, so the > > error occurs within the plugin. I just use it like: > > > In my user model: > > > composed_of :tz, :class_name => ''TimeZone'', :mapping => %w(time_zone > > name) > > > In my view: > > > <%= format_date(@current_user.tz.utc_to_local(entry.created_at)) %> > > > The hash is part of tzinfo_timezone.rb''s way of associating time zones > > with locations. > > > Thanks for the tip on Mephisto, I''ll look into their way og handling > > time zones. > > This line should be: > > composed_of :tz, :class_name => ''TzinfoTimezone'', :mapping => %w(time_zone name) > > I think the mappings are slightly different between the two which > would explain the intermittent crashes. > > -- > Zack Chandlerhttp://depixelate.com--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Morten wrote:> Hi. Off and on I get a "can''t modify frozen object" when working with > the tzinfo_timezone plugin. I''ve added some debugging in the code to > try and track down what goes wrong: > > ..... > > Thanks. > > MortenHas anybody figured out why this occurs and how to fix it? It''s odd that the error only occurs sporadically. Thanks, Andrew -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---