[Radiant] Caches and environment - or: how to add extension configuration?

Sean Cribbs seancribbs at gmail.com
Tue Mar 25 14:05:50 CDT 2008


Are you running in development mode?  If so, that filter will be 
reloaded on each request, but your configuration in environment.rb 
won't.  In general, it's better to put configuration in Radiant::Config 
if possible, which stores its values in the database.

Sean

Svoop wrote:
> Hi 
>
> I'd like to add some site-wide configuration to the mediawiki_filter
> extension, however, the cache mechanism is not too happy about it. Here's
> what happens:
>
> In environment.rb I add the following:
> MediawikiFilter::config[:images_directory] = '/assets/images'
>
> This should overwrite the defaults in the mediawiki_filter.rb which looks as
> follows (stripped down testing code):
>
> class MediawikiFilter < TextFilter
>
>   @@config = {
>     :images_directory => 'default'
>   }
>   cattr_accessor :config
>
>   def filter(text)
>     @@config.inspect
>   end
>
> end
>
> I clear the cache and restart the server - and voilà, the output is just
> right:
>
> { :images_directory => '/assets/images' }
>
> But once I clear the cache in the backend, the output changes to the default
> value:
>
> { :images_directory => 'default' }
>
> Is this a bug or a feature? Or is there a better pattern to implement such
> configurations? (I've been thinking about a config part, but it doesn't seem
> right for such general extension settings.
>
> Thanks...    -sven
>   




More information about the Radiant mailing list