Archive for April, 2009

Setting up Plone to show Dubai time

As a short introduction, Plone is an excellent content and document management system. I would not insist on its features and installation as it installs as a normal Mac OS X application. For this, you may find more visiting Plone.org website.

In exchange, I will present the issue I had with the timezone for Dubai and the workaround…

For some reason, the default Plone installation doesn’t pick the right time for Asia/Dubai.

So I googled back and forward but couldn’t find the correct answer.

In fact, those tips will work for something like Europe/Berlin (eg setting up TZ variable to Europe/Berlin), but setting up TZ environment variable to Asia/Dubai will give me something like GMT+10? Obviously wrong.

So, the workaround is to set up the TZ environment variable to something more general, like Etc/GMT+4. We don’t care about daylight saving issues, so it should work all year round.

Enough words, let me know show you some code. Let’s suppose that you downloaded version 3.2.2 from http://plone.org/products/plone for Mac OS X and used the Stand Alone installation, then, edit /Applications/Plone/zinstance/buildout.cfg file and locate the following lines under [instance] section:

# You may also control the environment variables for the instance.
environment-vars =
    PYTHON_EGG_CACHE ${buildout:directory}/var/.python-eggs

Now add the TZ environment variable to point to Etc/GMT+4:

# You may also control the environment variables for the instance.
environment-vars =
    PYTHON_EGG_CACHE ${buildout:directory}/var/.python-eggs
    TZ Etc/GMT+4

Save the file, then run from your Terminal:

cd /Applications/Plone/zinstance/
./bin/plonectl stop
./bin/buildout
./bin/plonectl start

Now, back in your favourite browser and launch http://localhost:8080/Plone.

You would see now, that Plone will report the correct time.

Keeping session data across subdomains in Rails 2.3.2

Upgrading to Rails 2.3.2 I came across with the error of not keeping the session data between subdomains. That meant I had to authenticate each time I would change the subdomain.

The fix is simple.

Prior to version 2.3.2, I have had something like this in environments/development.rb file:

ActionController::Base.session_options[:session_domain] = '.w2task.local'

In Rails 2.3.2, I had to change this line into:

config.action_controller.session = { 
  :domain => ".w2task.local" 
}

Of course, same principle applies to development.rb, where:

config.action_controller.session = { 
  :domain => ".w2task.com" 
}

I’ve lost some hours in researching this solution, so I hope this will help others in need. too. As usual, I will be more than happy to hear comments from you.

Happy coding!


Ruby on Rails application could not be started

This is the error message, on my local machine after I upgraded to rails 2.3.2. Well, it was not an instant error, but it appeared after a while, to be more exact after I rebooted my computer.

The error:

no such file to load -- application.rb (MissingSourceFile)

As the new rails renamed application.rb to application_controller.rb, I have immediately sensed the root of the problem, so I’ve tried to

./script/server

and it worked. That means it has something to do with the Phusion Passenger.

But what? I’ve updated all the gems, and passenger was updated too.

Well, yes, but not the apache module, and not the configuration…

This is to remember: Every time, after getting a new version of Phusion Passenger via sudo gem update, I have to:

sudo passenger-install-apache2-module

and go through the setup, than edit the httpd.conf file (in my case: /private/etc/apache2/httpd.conf) and replace the old passenger configuration lines with these new ones:

LoadModule passenger_module /Library/Ruby/Gems/1.8/gems/passenger-2.1.3/ext/apache2/mod_passenger.so
PassengerRoot /Library/Ruby/Gems/1.8/gems/passenger-2.1.3
PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

Last step is, of course, to restart the apache server:

sudo apachectl restart

Now we are set to go.

I have post this article as a reminder to myself in case something similar would happen in future, and as well I hope to be useful to the readers of my blog whom might struggle with the same type of issues.

For any other tips and comments, it would be a pleasure to see you replying to this post.

Coding is fun!