View allAll Photos Tagged python2
Hissing Sid and some rainy bokeh !! he was an excellent subject, didnt move, didnt blink, the down side is, snakes are always in fish-tanks with thousands of sticky fingers marks on them..why dont zoo's ever clean them ?
Please don't use this image on websites, blogs or other media without
my explicit permission. © All rights reserved
Morning tea, anzac biscuit & milo.
Python references
If you are using python then here's the order of reading ...
*google 'python foo'
Programming Python 3
The image beneath the anzac biscuit in the shape of Australia, is Programming Python 2nd Edition.
Mark Lutz is releasing the next version Programming Python 3rd Edition later this year (2006AUG) . It's time to save up your bikkies... a new version is in the works.
New material
I've got Editions 1 & 2. Everytime I have a problem (C integration with python - SWIG for instance, parsing text - NLP) there is usually a solution. As good as 1st & 2nd versions are, Python the language, is moving. So edition 3 is welcome. I noticed the new material when edition 2 replaced edition 1. So I wonder what the new changes / additions are?
Of course you don't have to buy it. Theres always options 1 & 3.
PyXPCOM
A long time ago a company called ActiveState created a bridge PyXPCOM to allow Python to talk to Mozilla. The developer responsible was Mark Hammond. I stumbled into PyXPCOM again today. (Sure its been around for a long time but not in a usable form - unless you count compiling Mozilla yourself.)
It's getting there. Soon you will be able to create Moz apps with Python instead of Javascript. For a more in depth look, go to the Mozilla PyXPCOM, the PyXPCOM list. Background in XPCOM is here.
Webpy Howto
For the moment I'm going to try using Webpy. Why?
Well I like the fact that Aaron could get an app up quickly without having to make lots of adjustments to existing code. I'm not so sure this is the case with django. Which bits can you use? What bits are being left out?
I suppose the biggest problem I have with django is the size of the codebase you have to upload. More code, more moving parts and the greater chance for something to go wrong. Plus the fact you have to use a hack to even start (django_bootstrap.py). I don't think this is the real problem though. The real problem starts when you have to set up your local application and try to get it to run on appengine. There is a couple of little tricks & problems I've found. The approach is far from seamless and prone to error that will compound adding large frameworks. Not a show stopper but annoying enough to slow you down. The google developers are really pulling the stops out for django support so don't assume not choosing django now will stop me using it in the future.
Problems
The following solutions below should give you enough information to get webpy up and running. If you have an questions thow a question to this google app-engine thread, twitter.com/bootload or email me. Below is a list of the problems you will encounter.
1) Cannot run webpy locally:
I've encountered a few problems. The first is "how do you run webpy locally?" The problem is you may have webpy installed, the webpy code (web tree) in your current directory. But how does your local code find it? [1] Hidden in the documentation is a hint to make a symbolic link to the code you wish to use. Here is how:
* We wish to use Webpy and "import web"
* make sure you have a copy of "bzr" (debian/ubuntu): "apt-get install bzr"
* download the latest (0.3) webpy install version (0.3): "bzr get webpy.org/bzr/webpy.dev/;
* install the latest webpy, cd into webpy.dev & install: "python setup.py install"
* in the directory you have installed your app-engine client, create a symbolic link to a newly created directory called "web" to your webpy installation.
* ln -s /usr/lib/python2.5/site-packages/web web
The result is something like this with the app-engine code, your code (helloworld & hellowebpy).
drwxr-xr-x 12 fb fb 4096 2008-04-18 20:09 .
drwxr-xr-x 18 fb fb 4096 2008-04-14 21:23 ..
-r-xr-xr-x 1 fb fb 1595 2008-04-03 11:05 appcfg.py
-r--r--r-- 1 fb fb 154 2008-04-03 11:05 BUGS
drwxr-xr-x 4 fb fb 4096 2008-04-16 22:16 demos
-r-xr-xr-x 1 fb fb 1713 2008-04-16 16:59 dev_appserver.py
drwxr-xr-x 5 fb fb 4096 2008-04-14 22:05 google
drwxr-xr-x 8 fb fb 4096 2008-04-03 11:05 google_appengine
drwxr-xr-x 6 fb fb 4096 2008-04-18 11:47 hellowebpy
drwxr-xr-x 6 fb fb 4096 2008-04-16 15:57 helloworld
drwxr-xr-x 5 fb fb 4096 2008-04-03 11:05 lib
-r--r--r-- 1 fb fb 4348 2008-04-03 11:05 LICENSE
drwxr-xr-x 2 fb fb 4096 2008-04-09 13:55 new_project_template
-r--r--r-- 1 fb fb 3476 2008-04-03 11:05 README
drwxr-xr-x 2 fb fb 4096 2008-04-09 13:55 templates
drwxr-xr-x 2 fb fb 4096 2008-04-09 13:55 tools
-r--r--r-- 1 fb fb 57 2008-04-03 11:05 VERSION
lrwxrwxrwx 1 fb fb 36 2008-04-16 23:11 web -> /usr/lib/python2.5/site-packages/web
This now allows you to run your webpy code on the development machine.
2) Run webpy remotely :
In your source code directory (in my case, hellowebpy) take a copy of the webpy.dev/web directory and paste it into hellowebpy/. The result is something like this:
drwxr-xr-x 6 fb fb 4096 2008-04-18 20:24 .
drwxr-xr-x 12 fb fb 4096 2008-04-18 20:09 ..
-rw-r--r-- 1 fb fb 223 2008-04-18 11:05 app.yaml
-rwxr--r-- 1 fb fb 844 2008-04-13 23:23 favicon.ico
-rw-r--r-- 1 fb fb 448 2008-04-18 11:47 hello.py
drwxr-xr-x 2 fb fb 4096 2008-04-18 11:07 images
-rw-r--r-- 1 fb fb 471 2008-04-18 11:47 index.yaml
drwxr-xr-x 2 fb fb 4096 2008-04-18 11:07 styles
drwxr-xr-x 2 fb fb 4096 2008-04-18 10:57 templates
drwxr-xr-x 4 fb fb 4096 2008-04-18 11:08 web
* cd up to the root directory with appcfg.py
* upload your code + the webpy "web" code using appcfg.py: "./appcfg --noisy -e foo@bar.com update hellowebpy/" (remember to use your email address)
3) Problems with errors and c-based code :
If you have installed code like Cheetah you will get an error saying you cannot run c-based code. The reason is the dev_appserver.py code assumes the Cheetah code you have is trying to make a call to some cPython code, strop (a C based, string library optomised for speed). [3] The solution is to un-install Cheetah from your system. The google app-engine code base has a modified version of Cheetah removing all C code based routines. Be warned.
4) Problems uploading new code? :
I've had problems updating code sometimes. I suspect caching is the problem. So go to your root directory in your account and search for ".app*". You should see the following files, .appcfg_cookies and .appcfg_nag. Delete them both. Create a new directory, delete the index.yaml and copy your old code into the new directory. Then re-run the upload sequence ... "./appcfg --noisy -e foo@bar.com update new_directory_with_your_code/"
Following these steps should allow you to run webpy. Remember the example Aaron shows is for version 0.3. It was mentioned in the google-appengine webpy post others managed to get 0.23 to work. Try what they suggest. The example code works as shown for 0.3.
Have fun.
Reference
[1] Google App Engine, Pure Python, "... You can include other pure Python libraries with your application by putting the code in your application directory. If you make a symbolic link to a module's directory in your application directory, appcfg.py will follow the link and include the module in your app ..."
code.google.com/appengine/docs/python/purepython.html
[2] Python docs, "common string manipulations, optimized for speed called by "import string" /usr/local/lib/python2.4/lib-dynload/strop.so"
<<< start
Owl Vision Eyewear ltd.
Ready Readers fashion line
Photographer: Matteo Blandford
With special thanks for the making to: Emanuele Todisco, Yvonne DeCotiis, Anita Roncoroni, Marcello, Matteo Congregalli, Luca Bernasconi, Ilaria Rigamonti, Alice Bruni, Francesca Pellegrini, Valentina Fusilla, Federico Casati
Small black headed python at the Warrego Police Residence, July 1989, Warrego was the last single member station in the NT, closed in 1990 when member transferred.
Update:
Next >>> ... webpys longterm future
Next >>>... installed svn, apache2 reconfigured, webpy works again
Next >>> ... reinstalling webpy stack
Next >>> ... raising my blood pressure
www.flickr.com/photos/bootload/102536597/ ... Forms working.
Next >>> ... Rudimentary forms working.
Next >>> .... Templates working.
Next >>> ... Bugs in using Cheetah templates
hello world
finally got installed again. The server died, requiring a re-install with associated problems, my prior install would not work (even following my previous install notes.)
It turns out the big nasty bug was a simple string in the .htaccess file (exclusion of 'wsgi' string in last line of top paragraph).
setup, mkII
Setting up webpy is pretty easy on Ubuntu. But the packages.debian.org/unstable/python/python-webpy file is catch 22. The installer requires python version to be b/w 2.3 & <= 2.4. Ubantu 5.10 ships with 2.4.2, so the debian install barfs. You cant uninstall python 2.4 as Gnome requires python2.4.2. So much for progress. A manual install is required.
code
So what you see here is the mod_python test code to see if mod_python works & the .htaccess code (blocked/commented out). Graham Dumpletom has a great article explaining how to test if mod_python is working. So read this before you even try setting up web.py.
Finally underneath is the hello.py code you see running in the browser. The hello world was replaced with the .htacess code.
webpy questions
*No installer, ie: python setup.py install?
*Why do I need to add an extra slash in webpy but not mod_python?
*Why is debian install Knobbled with the gui?
-ie: for Ubuntu gnome uses pythno2.4.2 but webpy requires python <= 4/2
is the grass greener?
Finally. It wasn't necessary to change from mandriva to ubantu to get it to work. doh!!!!!!!
The grass is only a little bit greener :)
Update:
http://www.flickr.com/photos/bootload/115246692/ ... Forms working.
Next >>> ... Rudimentary forms working.
Next >>> .... Templates working.
Next >>> ... Bugs in using Cheetah templates
@#%$$!@@#$! ... webpy, mod_python & apache.
config blues
The error above usually means you havent included the apache-devel source. Whoever wrote the makefile for mod_python installer has a sense of humour. I've been re-installing apache2, mod_python, webpy without much luck mainly due to mandriva`s insistance of changing around the packages.
mandriva crap
Their current 2006 install mod_python setup uses python2.3 (unless I`m wrong). So its back to source ... or maybe ubantu. This is the trade offs you make using linux as server & desktop. I'll have to correct this. Its a waste of time.
its the little things
Aside from that, stacks of little things are also causing annoyances:
*kvm switch sending erroronious extra console characters causing the mouse to jump everywhere.
*lots of apache,mod_python setup with mandriva changes
*webpy stack problems that result in wsgi weirdness (causing errors before I even start coding). I know I got mod_python working becuase I can get your stock standard python examples to work with apache. And why does webpy require trailing slashes?
*firefox releases without bloody installers!@#$
*crappy groups.google.com which change the layout all the time (next buttons, replies etc)
So I see the humour in the mod_python comments & dont take it too seriously :)
Medtoxin Laboratories, Deland, FL--a non-venomous juvenile pie-bald ball python. Non-venomous species are kept for educational handling.
Final example. This code allows me to do the following:
*use apache2, mod_python, web.py0.123, python2.4.1
*use Cheetah templates
*set template paths anywhere
*use any template extension
*gracefully see whats going on if it crashes without resorting to logs (hopefully)
You can follow the discussion in more detail at groups.google.com/group/webpy/browse_thread/thread/d8c9f2...
update
2006JAN241039 - working but with html validation problems.
2006JAN240904 - solved error in L13, remove '(.*)' - still problems, but fixable.
form.py
Latest code for wbForm.py (test.py) - code barfs on Index.GET(). This is the most amount of code I can run before apache barfs. So to recap,
*import form is OK
*myform code works
*failure is on 'class Index'
*remember this code is for apache2, mod_python2, python241 etc running web.py v0125.
*apache log reports error in and around web.py, L 380
-on 'def handle(mapping, fvars=None):'
*after the result (match) is made & returning the 'tocall' func
-return tocall(*[urllib.unquote(x) for x in args])
*GET function should have returned 1 arg (bug in web.py)
or 2 args (bug in sample app).
The above vim console shows the web.py code that breaks, L380. The bottom console shows the maximum code I can add before it breaks. The code is barfing on the 'def Index.GET' method.
Is the bug in the supplied test code? Or is it in web.py? Not really sure what the 'def handle' method is doing.
You can read more about this at groups.google.com/group/webpy - form.py: first draft up now.
Apollon vainqueur du serpent Python (Apollo Slaying the Serpent Python), marouflaged onto the ceiling of the Galerie d’Apollon in the Denon Wing, by French painter Eugène Delacroix (1798–1863), dates to 1850–1851.
Executed in oil on canvas, this Romantic composition captures Apollo’s triumph over the serpent Python, a foundational myth celebrating the god’s dominion over the arts and the sun. Commissioned in 1850 during the reign of Louis-Philippe, at 8 by 7.5 meters, it was intended as the centerpiece of the gallery, complementing the grand 17th-century stuccowork of Charles Le Brun’s era, and reflecting the enduring cultural prestige of the French monarchy and nation.
The Galerie d’Apollon (Apollo Gallery), located on the first floor of the Denon Wing of the Louvre, was commissioned by Louis XIV after a 1661 fire destroyed the Petite Galerie. Originally designed by Louis Le Vau and decorated by Charles Le Brun, it was conceived as a royal gallery to glorify the Sun King, symbolized by Apollo. Though Louis XIV shifted his court to Versailles, whose Hall of Mirrors was influenced by the gallery, the decoration was completed two centuries later in 1850 under Félix Duban with Eugène Delacroix adding Apollo Slaying the Serpent Python for the central ceiling, a landmark of French Romanticism. Restored and reopened in the early 2000s, the gallery now houses the French Crown Jewels and other major decorative art treasures.
The Louvre is the world’s most visited museum and one of its largest, housing over 35,000 works of art from prehistory to the 19th century. Originally built as a fortress under Philippe Auguste in the late 12th century, it was transformed into a royal palace and later into a public museum during the French Revolution in 1793. Its collections span eight departments, including Egyptian antiquities, Greek and Roman art, Islamic art, sculpture, decorative arts, paintings, prints, and drawings. The museum is organized across three wings—Denon, Sully, and Richelieu—surrounding the Cour Napoléon. The modern glass Pyramid entrance, designed by architect I. M. Pei and inaugurated in 1989, unifies the historic palace complex while serving as a symbol of the museum’s global identity.
Default Python Path setting is "/usr/bin/python2.5".
a symbolic link has made from "/usr/bin/python2.5" to "/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python".
I want to change the path to "
/opt/local/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5".
In terminal:
sudo ln -s /opt/local/Library/Frameworks/Python.framework/Versions/2.5/bin/python2.5 /usr/bin/python2.5
but...
ln: /usr/bin/python2.5: File exists
to remove simlink.
sudo rm /usr/bin/python2.5
try again.
www.itelearn.com/events/python-live/
#Python #LiveTraining Session on April 30th at 6:30 p PST/9:30p EST / 1th May at 7am IST. Opportunity is right before you! Join this Expert PYTHON session to advance your #career. Register to save your spot.