Firstly, apologies if this is not too bright a question. I''m at the baby-steps stage with Ruby. I''ve made a Deplate (http://deplate.sourceforge.net) formatter available in my installation of Instiki. My aims were (1) to have deplate available as my instiki markup, as it''s what I write my docs in, and (2) to start learning some Ruby. I''ve hardly done the latter, as it all proved too easy: - add a new AbstractEngine subclass in engines.rb, calling on the deplate html formatting class - add a *_help.rhtml view for the new formatter - hook this into edit_web.rhtml So far so good. The problem came when I renamed my new class from ''Test'' to ''Deplate'' (also editing edit_web.rhtml accordingly, and creating deplate_help.rhtml). Now when I start Instwiki I get the following error: -- 8< -- %programfiles%/ruby/lib/ruby/gems/1.8/gems/madeleine-0.7.1/lib/madeleine/automatic.rb:230:in `load'': undefined class/odule Engines::Test (ArgumentError) -- 8< -- Madeleine is presumably persisting some of the app state here, and still has a reference to the old Test class. So my question is: if I want to rename the class, is there some way I can prevent this error without having to set up an entirely new wiki? (I do want to retain my data).
> The problem came when I renamed my new class from ''Test'' to ''Deplate'' > (also editing edit_web.rhtml accordingly, and creating > deplate_help.rhtml). Now when I start Instwiki I get the following error: > > -- 8< -- > %programfiles%/ruby/lib/ruby/gems/1.8/gems/madeleine-0.7.1/lib/madeleine/automatic.rb:230:in > `load'': undefined class/odule Engines::Test (ArgumentError) > -- 8< -- > > Madeleine is presumably persisting some of the app state here, and still > has a reference to the old Test class.Madeleine is a (binary) storage, it persists all objects in the object graph. When it comes to load those objects next time, it tries to match the objects to their classes. If you''ve renamed the class than madeleine can''t find it when it loads the snapshot and stops.> So my question is: if I want to rename the class, is there some way I > can prevent this error without having to set up an entirely new wiki? (I > do want to retain my data).First backup your data (always a good idea :). You can try Alexey''s script for poking in the snapshot files (http://svn.instiki.org/instiki/trunk/script/debug_storage - look at the list archives), or you can export the web contents and recreate it later. Importing is currently disabled in Instiki, but should be easy to uncomment the relevant sections to enable it back. I have not tried any of these methods yet, but am sure i''ll need them soon ;-) HTH, Assaph
Assaph Mehr wrote:> > >First backup your data (always a good idea :). > >Oh yes. Backups of backups.>You can try Alexey''s script for poking in the snapshot files >(http://svn.instiki.org/instiki/trunk/script/debug_storage - look at >the list archives), or you can export the web contents and recreate it >later. Importing is currently disabled in Instiki, but should be easy >to uncomment the relevant sections to enable it back. >I have not tried any of these methods yet, but am sure i''ll need them soon ;-) > >OK, thanks. All this must make *using* instiki to keep & hold information a bit of a pain for anyone who''s simultaneously hacking it? I guess if the import works OK then it should solve the problem.
> All this must make *using* instiki to keep & hold information a bit of a > pain for anyone who''s simultaneously hacking it? I guess if the import > works OK then it should solve the problem.I have been bitten before :-) One other thing to watch out for is if you add persistent attributes to the web (or similar classes). You should manually provide the getter if nil is not a valid option, as the objects loaded from the previous snapshot will not have the new instance variable. e.g. attr_reader :funk_level def funk_level @funk_level ||= ''groovy'' end Of course, this is not a problem if nil is a valid value. <d''oh moment> Of course I once had a bunch of such things, so I mechanically added getters for all new stuff, including a bollean property that was true by default: def bool_stuff @bool_stuff ||= true end :-) </d''oh moment> Cheers, Assaph Cheers, Assaph