Pages

2011-01-09

RewriteBase takes one argument

Staying in Denver, CO, away from my family, and far from the development databases at work I decided I had time to work on a pet project of mine.

Knowing there will be a few hours on airports and in the plane on my way home I decided to get the project running correctly on my laptop before I continued work.

Then I ran into this:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, you@example.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Log file:

[Sun Jan 09 14:16:56 2011] [alert] [client ::1] /Users/Sites/web/.htaccess: RewriteBase takes one argument, the base URL of the per-directory context

After browsing through the first two pages of google results withouth finding anything useful I suddenly realized maybe the config files doesn't accept comments at the end of the lines. Turns out to be true. See http://httpd.apache.org/docs/1.3/configuring.html#syntax

2010-10-17

Configuring Mac Snow Leopard for Symfony development

If you want to develop symfony applications using the built in Apache web server in Mac OS X here are my notes. Keep in mind, this is not a production configuration but just the necessary steps to get a developer workstation up and running.
  1. Activate Web Sharing
    System Preferences -> Sharing -> Web Sharing
  2. Change your UserDir settings. In a terminal window, edit the file with your userdir configuration.
    vim /etc/apache2/users/username.conf
    Remove or comment the contents. Paste the following information:
    UserDir Sites/web


    <Directory "/Users/username/Sites/web">
        Options Indexes MultiViews
        AllowOverride All AuthConfig
        Order allow,deny
        Allow from all
    </Directory>

    Alias /~username/sf /Users/username/Sites/lib/vendor/symfony/data/web/sf

    <Directory "/Users/username/Sites/lib/vendor/symfony/data/web/sf">
      AllowOverride All
      Allow from All
    </Directory>
  3. Substitute the text username for you username.
  4. Enable php (and mysql if you want). See http://stackoverflow.com/questions/1293484/easiest-way-to-activate-php-and-mysql-on-mac-os-10-6-snow-leopard
  5. Now you can either install
    • the sandbox
    • the svn version,
    • the tar.gz version
    • or you can check out your existing project from source control.
  6. After you've installed symfony, edit the .htaccess file in the symfony web folder
    • Enable RewriteBase by uncommenting it
    • Change the RewriteBase directive  to RewriteBase /~username/
  7. Restart apache
    sudo apachectl restart

BTW: I wrote a more detailed post back in 2008. It hasn't been updated since then, but there might still be a few useful hints there: http://techinorg.blogspot.com/2008/07/ubuntu-post-install-customization.html

2010-10-01

The web2py ide

The web2py ide is Firefox. Or Chrome, or Opera, or Safari (or Internet Explorer).

Just create a good old frameset and you can have split view between models and controller, documentation and even a preview running in one browser tab. Running the browser in full screen and the built in code editors in "full screen" (which fills the whole assigned frame), this turned out to work really well.

Example frameset:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>web2py ide - 0.1 beta :)</title>
</head>
<FRAMESET ROWS="75%, *" COLS="*, 40%">
<FRAME SRC="http://127.0.0.1:8000/admin/default/peek/yourapp/models/db.py">
<FRAME SRC="http://127.0.0.1:8000/admin/default/design/yourapp">
<FRAME SRC="http://127.0.0.1:8000/yourapp/default/index">
<FRAME SRC="http://127.0.0.1:8000/yourapp/appadmin/index">
</FRAMESET>
</html>

Can you see some quick improvements? Post them in the comments!

2010-09-29

Quick hack to develop web2py on a different machine

For security reasons web2py will not allow you to log in as administrator unless you are logging in from the same workstation. (There are exceptions, but they are cumbersome: See the official book for full details.)

However, there is a quick hack that allows you develop from any machine: Just set up a ssh tunnel:

ssh username@ip_address_or_dns_name -L 8000:127.0.0.1:8000 -N

As usually, I didn't come up with this myself. This time I found it here: http://www.revsys.com/writings/quicktips/ssh-tunnel.html

(However, if you read a few of the samples available on the internet, you'll see that may of them miss the point that in the local_port:ip_address:remote_port part you can and should use 127.0.0.1 instead of the external ip address. The reason is that this is the address that the request seems to come from in the server program at the remote computer.)

Using web2py, first impressions

I've had the opportunity to do some quick prototyping in web2py in my spare time over the last few weeks. Here are some very quick notes about what to like and what not to like:

Good:
  • Works out of the box. Just download, open, choose password, press start. Your default browser starts automatically.
  • Automatic updates (beta warning, bur works.)
  • Built in editor and version control.
  • Built in user registration and management.
  • Automagic migrations (connecting to legacy databases are supported and documented, too)
  • Built in support for multiple databases, including distributed transactions.
  • Built in sqlite database, and postgres, mysql and even mssql seems to be just one config setting away.
  • The whole official book is available online.
  • Author intends to keep the api stable. (For anybody who has had the joy of supporting an application over multiple years and multiple versions of the same framework.)
  • Bonus point 1: Nice default look and feel, and it is easily customizable. It's just html with placeholders.
  •  Bonus point 2: Applications built on top of web2py can be packed, downloaded and installed on another instance.

Needs improvement:
  • The documentation. There is lots of official documentation, but the search engine is next to useless, and google picks up old, outdated blog post before the official documentation.
  •  Routing: From the official documetation: The url http://127.0.0.1:8000/examples/default/status/x/y/z?p=1&q=2 will presented to the controller as:
    • request.args ['x', 'y', 'z']
    • request.get_vars <Storage {'p': 1, 'q': 2}>
      Why you'd like to separate between those are beyond my understanding. I always thought unifying those was one of the features of modern web frameworks.

Preliminary conclusion:


web2py is production ready and is already used a few public facing sites. To me it seems like a perfect match for small "intranet applications" but it is in no way limited to this.

Although I've not programmed apex myself, it often comes to mind because of features like online editing and redistributable applications built on top of it.

2010-05-30

Getting ipythonx to work with Mac OS X

If you're trying to get ipythonx to work under Mac OS X 10.6 Snow Leopard you might get and error message like this:
ImportError: /System/Library/Frameworks/Python.framework/
Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode/wx/
_core_.so: no appropriate 64-bit architecture (see "man 
python" for running in 32-bit mode)
Here's a couple of hints:
  1. Use standard ipython instead. Unless there was something I didn't catch, ipython seems to better than ipythonx.
  2. If you want to try anyway here's the easiest way I found: In a terminal session:
    1. export VERSIONER_PYTHON_PREFER_32_BIT=yes
    2. python `which ipythonx`

2010-05-25

Copy OpenVPN settings from Tunnelblick on Mac OS X to Windows 7

I forgot the charger for my job laptop in the office today. So I spent the last few minutes of battery copying the configuration files to the pc at home.
Below is what I ended up doing:
  1. Install OpenVPN software. You can find it on the official OpenVPN site.
  2. Copy all the config files from the job laptop to C:\Program Files (x86)\OpenVPN\config. The job laptop uses tunnelblick, so the files was located under
    ~/Library/Application Support/Tunnelblick/Configurations
  3. Added .opvpn to the file name for the main configuration file (the one that is not .crt, .csr or .key)
  4. Change to Windows style line endings. I did this by opening the files in WordPad, copying the contents to a Notepad window and saving.
  5. Starting the client software.
Of course: There was a lot of trial and error. I guess I ended up using 30 minutes tinkering and 30 minutes blogging.
Gotchas:
  • Make sure all line endings are corrrect. You can see this easily by opening the files in Notepad.
  • Make sure you run the OpenVPN program as administrator.