Skip to content

Instantly share code, notes, and snippets.

@amcgregor
Created January 27, 2010 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amcgregor/287670 to your computer and use it in GitHub Desktop.
Save amcgregor/287670 to your computer and use it in GitHub Desktop.
TurboGears installation script.
#!/bin/bash
# This script installs a TurboCMF-viable version of TurboGears and related utilities.
# This... is just dumb. Mostly because of all of the warnings I had to add…
echo "Updating setuptools and installing virtualenv globally."
sudo easy_install -U setuptools
sudo easy_install virtualenv
virtualenv --no-site-packages $1
cd $1
. bin/activate
echo "While the packages are installing, move your project's files into the venv."
echo -e "The setup.py file should be at the root level of the venv.\n"
echo "Installing non-core packages first."
echo -e "If you see any ld: warning lines, you will need to re-install mysql-python:\n"
echo " rm lib/python2.?/site-packages/MySQL_python*"
echo -e " ARCHFLAGS='-arch x86_64' easy_install mysql-python\n"
easy_install boto TurboMail mysql-python ipython
echo -e "\nInstalling TurboGears core packages.\nThere's about 40 of them, so this could take a while.\n"
easy_install -f http://files.turbogears.org/ http://svn.turbogears.org/tags/2.0b3/
echo -e "\nInstalling TurboGears development packages.\nThis could also take some time.\n"
easy_install -f http://files.turbogears.org/ http://svn.turbogears.org/projects/tg.devtools/tags/2.0b1/
echo -e "\nInstalling the Python Image Library (PIL)."
echo -e "If you see 'JPEG support not available', see:\n"
echo -e " http://jetfar.com/libjpeg-and-python-imaging-pil-on-snow-leopard/\n"
easy_install http://effbot.org/downloads/Imaging-1.1.7.tar.gz
echo -en "\nPatching TurboGears to resolve a feature regression in the url() function... "
CWD="$(pwd)"
cd lib/python2.?/site-packages/TurboGears2-2.0b3*
patch -s -p0 < ${CWD}/url-fix.patch
cd $CWD
echo -e "done.\nInstalling webapp in development mode."
python setup.py develop
--- tg/controllers.py 2010-01-26 23:08:07.000000000 -0800
+++ tg/controllers.py 2009-04-15 21:11:05.000000000 -0700
@@ -672,7 +672,7 @@ class WSGIAppController(TGController):
return self.app(environ, start_response)
-def url(*args, **kwargs):
+def url(components=None, *args, **kwargs):
"""Generate an absolute URL that's specific to this application.
The URL function takes a string, appends the SCRIPT_NAME and adds url
@@ -686,17 +686,20 @@ def url(*args, **kwargs):
passed in we support a params dictionary in additon to the standard
keyword arguments.
"""
- args = list(args)
+
+ if isinstance(components, list):
+ args = ['/'.join(components)] + list(args)
+
+ else:
+ args = [components] + list(args)
+
if args and isinstance(args[0], basestring):
#First we handle the possibility that the user passed in params
if isinstance(kwargs.get('params'), dict):
params = kwargs['params'].copy()
del kwargs['params']
-# print "kwargs:", kwargs
params.update(kwargs)
-# print "updated params:", params
kwargs = params
-# print "final kwargs:", kwargs
if len(args) >= 2 and isinstance(args[1], dict):
params = args[1].copy()
@@ -707,6 +710,7 @@ def url(*args, **kwargs):
if isinstance(args[0], unicode):
args[0] = args[0].encode('utf8')
+
return pylons_url(*args, **kwargs)
def redirect(*args, **kwargs):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment