Archive pour la catégorie ‘english’

Django-registration : Why my activation e-mail is not translated ?

Mercredi 16 février 2011

That was the question a few minutes ago. Just don’t forget that makemessages only looks for .html templates so tell it to look for .txt files too :

./manage.py makemessages -a -e html,txt

Run Django tests automatically before committing on Git

Mercredi 16 février 2011

Since I often forget to run unit tests before committing, I spend a lot of time looking for the bad commit when I find regressions 3 commits later.

However it’s really easy to automatically run tests before each commit. In .git/hooks/pre-commit, put :

python manage.py test
exit $?

then chmod 755 this file and it’s done. I really love git :-)

Do not forget to source your virtualenv before committing.

Note that tests are run on your working tree and not the commit itself, so if you commit only a part of your working tree, it may fail while your commit passes tests.

MySQL memo

Lundi 7 juin 2010

During my last job, I’ve had to migrate queries from Sybase to MySQL, and thus, I’ve noticed some important things which weren’t obvious at first in MySQL 5.1 :

  • concat function returns null if any of its argument is null. This leads to do things like concat(coalesce(f1, »), coalesce(f2, »), coalesce(f3, »)) which is a bit annoying.
  • you can’t reference a temporary table more than once in a query
  • if you define a write lock on a table, you can’t update or insert any other table without locking it before.

I’ve not checked if these issues/behaviors have changed in recent versions.

Sessions not working on IE6

Dimanche 2 mai 2010

I was working on integrating the Auth component of CakePHP with a legacy database and while it was working on Firefox, I noticed that it wasn’t on IE6, the customer target platform. By looking at the database log, I was sure that the authentication process was ok but Internet Explorer seemed to have a problem with the session cookie, disconnecting as soon as the redirect after authentication was done.

I quickly suspected a problem with cookie, and talking about cookie, I thought to a domain name issue. After googling a bit, I found that underscore « _ » in a host name was an invalid character. So if you need to define local host names while developing, use only [a-z0-9] and « - » to avoid troubles.

Reference : http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names

Finally solved ssl_error_rx_record_too_long

Mercredi 28 avril 2010

I’ll write in english for this article since it’s technical and may be very usefull for many people.

So I had this error for days on all my apache ssl virtualhosts. I guess it came from the last dist-upgrade I’ve made. I’ve googled for hours without finding any working solution. Everything was working well before and I’ve made no related changes.

Listen 443 was set in ports.conf, I removed the « if » statement to be sure, as in mods-enabled/ssl.conf. I checked that I’ve had no virtualhost without port 80 or 443 defined. I’ve checked that there’s no default virtual host with *.

I also tried to add my ip in Listen statement and « https » at the end.

SSLEngine was set to « On », SSLCertificateFile .cert file was defined and ok, so as SSLCertificateKeyFile (I was pretty sure since everything was ok before).

Finally, I’ve disabled all my ssl vhosts, just keeping the one I wanted for the moment, and it worked. After enabling the others one by one, I found the bad one : in one vhost, instead of doing :

<VirtualHost ip:80>
  ServerName domain.tld
  ServerAlias domain.tld
  redirect / https://domain.tld
</VirtualHost>

I was doing the opposite (I guess I didn’t want any SSL on this site) :

<VirtualHost ip:443>
  ServerName domain.tld
  ServerAlias domain.tld
  redirect / http://domain.tld
</VirtualHost>

I don’t know why, but after removing this part, everything was back to normal. It was not really important for me, but if you have any explaination, I’ll be glad to hear it.

I hope this could help someone ;-)

EDIT : adding

SSLEngine On
SSLCertificateFile    /path/to.cert
SSLCertificateKeyFile /path/to.key

in my ssl vhost redirecting to non-ssl vhost solved the problem too (it seems logical, but it was working without before).