Wednesday, October 24, 2012
New release of App Engine SDK 1.7.3 with full Django 1.4 on Python 2.7
It's good to hear that now the latest release version 1.4.x of Django can run on Python 2.7, and not lagging much on the support for the latest Python 2.x family. This is what I've been waiting for!
The full release notes is at here.
I am going to try get my hands on it!
Wednesday, August 1, 2012
Python 2.6 on Google App Engine local environment
Python 2.4 for Installation Scripting of Tomcat-based Application
The approach with this client is a bit different from the rest, as we work together for almost one year to close the gap between the application and the business requirements through iteration. In the methodology that we use (Scrum) it is called "sprint". After each 2 sprints we need to deliver a working application to the client, which will be installed by their server admins. In the industry we are in, we usually are not allowed to access the server machines remotely. We need to deliver package with the instructions on how to install it and get it working. As this application is running on Apache Tomcat, we initially just bundle everything inside and deliver a tarball, database dump and installation instructions to the client.
As few iterations went by, new requirements and wishes emerged (as usual)!
Need to run the same application in the same machine in 2 different environment (database and TCP ports). We delivered 2 separated tarballs with ports hard coded.
Then there were needs to run more than 2 environments in single machine. This complicates the problem when you hard code the port numbers.
We shop around to see what open source installer options available, especially ones that can run well without GUI and very few dependencies need to be installed. Eventually we came into conclusion that we'd better develop our own installer script to have much greater control over what's happening.
I opt in for Python. It's there in most Linux/UNIX servers.
Ubuntu has Python 2.6 as the base of apt-get tools. Both RHEL's yum tool and SLES yast2 tool. All are sophisticated package dependency management tools!
I have (successfully) uninstalled Python 2.6 from Ubuntu, and also uninstalled Python 2.4 from CentOS. Oh, please don't do this at home!
At least it's encouraging that Python actually serves at the heart of these wonderful Linux distros. You can't just get rid of Python on those distros.
We came with Python 2.4.x as the winner, as it is the lowest common denominator. Python 2.4 script will mostly run without modification on Python 2.6. You can't uninstall Python 2.4 from RHEL or SLES (at least not for now!).
The library side of the code is open sourced: http://code.google.com/p/swpt-tools/
But I still need some time to tidy up the code and wiki there.
If you have the same requirements like:
- Need to deploy an application running on Tomcat (or other application servers)
- Need to prompt and modify (or parameterize) on installation:
- values which will go inside the XML or properties files inside your Tomcat folders
- values that needs to go inside your WAR file
- values that needs to go inside your JAR file inside WAR file
- the installation folder location
- etc.
Thursday, March 24, 2011
Using setuptools or easy_install in Jython
According to the manual, you just need to download from here: http://peak.telecommunity.com/dist/ez_setup.py
Then run:
$ jython ez_setup.py
Sunday, November 28, 2010
Bullet on my own foot: trying to uninstall Python 2.6 from Ubuntu 9.10 Karmic Koala
I just found another catch, when you are trying to install Python 2.6 in Ubuntu (I was using Karmic Koala, 9.10), such as:
[source lang='shell']
$ sudo apt-get remove python2.6
[/source]
It will display the components that are about to be removed.
Kids, don't try this at home!
It will remove your whole desktop related application! Java, Gnome, apt tools. You practically will be left with command line Linux, and without the apt tools.
Uninstalling Python 2.6 from Ubuntu seems to be an act of shooting own's foot!
Lucky I tried on not-so-important experimental Ubuntu installation on my laptop.
Saturday, July 10, 2010
Again about Google DevFest 2010
Yesterday I had to leave an hour earlier from the Google DevFest 2010 event, as I have to catch up with my wife, she was waiting for me for the second Antenatal Class. I missed the Code Lab, the Maps and Buzz T-shirts. Ouch. 5:30pm I had to leave while they ended the event on 6:30pm.
Flash back: After lunch time, there were some presentations on Google Apps, by Patrick Chanezon, followed by success story of people who developed applications for Google Apps. One from creately.com (http://www.creately.com). Another round from SingPath (http://singpath.appspot.com).
One thing that was missed a lot is the power points (aka power plugs). It was awful so many people carrying laptop and no power plug on the Connexis Theater. Almost everyone were running out of battery.
I just don't know why the crowd was kinda lacking enthusiasm to verbally respond to the speaker on stage with 'ooo's, 'aaaa's, 'yeah's, 'alright's and stuffs. Most of the time the crowd was silent.
Nevertheless it was a must-attend event of this year. I will attend the next event for sure.
Friday, July 9, 2010
In Google DevFest 2010
Currently I am attending the Google DevFest 2010. Timothy Jordan and Bob Aman in their presentation on Open Social.
Today the registration was pretty crowded, and they differentiate based on the first letter of your first name. I was in the "A-F queue". The queue was long and the registration process was draggy.
They changed the schedule a bit, Daniel Lee presented the Google Maps as opposed to the initial schedule on the web site: Google DevFest 2010 in Singapore. He showed us how to create a coffee shop location based informative web site as an example.
After the first session, Jeremy Orlow, an engineer working on the Chrome team, explained the HTML5 and the Chrome. They skipped the Q&A for HTML5 and Chrome. May be they pushed forward because we're late because of the registration, so in order to finish during the lunch time, the organizer advised to ask in person to Jeremy during lunch time for anyone who want to ask questions.
Then here comes the third session, and its about Open Social. Tim was of more lively presenter than others I think. More like MC may be? Google Buzz API stuffs, atom, OAuth, Salmon, Pubsubhubbub etc.
Tuesday, June 29, 2010
PyDev 1.5.8 is out: Eclipse IDE + PyDev == Cool Python IDE
PyDev 1.5.8 is out now. Eclipse update site: http://pydev.org/updates
- Support for Eclipse 3.6 Helios
- The PyDev jar is not signed out (no more confirmation message that you are installing from untrusted source during the Eclipse plugin installation)
- DoesNotExist and MultipleObjectsReturned recognized in Django
- Some issues fixed
PyDev is a plugin that enables users to use Eclipse as an IDE for Python, Jython and IronPython development. It has the syntax highlighting, refactor, syntax analysis, debug, and code completion.
Monday, June 14, 2010
Mercurial Server 1.0.1 Installation on Ubuntu
And of course if you are just as lazy as I, you will use the CollabNet Subversion or Edgewall Trac.
Mercurial Server from Lshift is one way to achieve similar thing. Though it is named Mercurial Server, it is not a server in traditional client/server perspective. It leverages the SSH authentication to make it like a central repository where multiple user can access and serves the same purpose.
Surprisingly, it is very easy to install in an Ubuntu box.
[sourcecode lang="shell"]
$ sudo apt-get install mercurial-server
[/sourcecode]
Gotcha! You have it now.
With this Mercurial Server, you can access the server using:
hg clone ssh://<ssh-user>@<host-name-or-ip-address>[:<ssh-port-num>]/<folder>
[sourcecode lang="shell"]
$ hg clone ssh://mercurial@192.168.0.1/projects
[/sourcecode]
Saturday, June 12, 2010
Attending Singapore Google Technology Group Meetup
Today I attended this Singapore Google Technology User Group Meeting. It's my first time to attend such a Google meetings. Some of previous meet ups had always fallen on the wrong days -- on the day that I have something else to do. Today I am glad to be able to make it, attended the meeting, and Wesley Chun, was the speaker. He presented 2 sessions, one about Python and the other one about Google App Engine.
This guy's a hardcore Python guy, wrote the Core Python series of book, and was a presenter in the PyCon Asia Pacific 2010, Singapore -- an event that has been held last 3 days. Awesome in depth knowledge, vast industrial experiences, and keep the talk flows fluent.
The rest about the meeting can be found here: http://www.sg-gtug.org/2010/05/sg-gtug-special-tutorial-session-june.html
Tuesday, May 18, 2010
Playing with IronPython again
It's been quite a while I haven't posted anything on this blog. I was too lazy to write. Now that I regain the composure, try to write again.
I have tried IronPython 2.6 before. It was presented in Python User Group Singapore somewhere last year which captured my attention. The IronPython made it easy to play around with .NET and Silverlight stuffs -- which not easy for me as I haven't play with .NET stuffs for quite sometime. It worked well that time. Recently when I want to run the ipy.exe interpreter, I came into certain problem. I was running it on Vista box, but the application crashed after I started, after around 30 seconds waiting for nothing. I try to do some ordinary "dance" like unistall-install, with no luck.
Today I gave it a try again, and eventually it worked after I installed the .NET framework 4 and Silverlight 4 from the download site. I wasn't sure what I missed, nevertheless now it works.
I tried some stuffs with Silverlight only to remind that I need a XAML editor to edit forms. I tried to download and use kaxaml from http://www.kaxaml.com, but haven't had much luck. It installs well, but didn't run quite well.
Thursday, April 22, 2010
PyCon Asia Pacific 2010 has been firmly announced
Now they announce the PyCon Asia Pacific 2010.
9-11 June 2010, at Ngee Ann Kongsi Auditorium, Singapore Management University.
SGD 250 for corporate.
SGD 200 for early bird individuals.
Highlights:
- Steve Holden, Chairman of the Python Software Foundation (PSF) will be coming as one of the keynotes
- Mark Hammond, author of "Python Programming on Win32"
- Wesley J. Chun, author of "Python Core Programming", now software architect at Google
- Martijn Faassen, a long standing member of the Zope Foundation
Friday, April 16, 2010
Missed PUG monthly meeting, exploring Java byte code and BCEL
I missed yesterday's Python User Group Singapore monthly meeting. I had to finish certain document before leaving office yesterday, I couldn't make it.
Last night I was exploring this Byte Code Engineering Library (BCEL) from Apache. This library gives us a way to analyse, create and manipulate binary Java class file. This library has been used by a lot of Java frameworks and containers, as those frameworks need to add some instrumentation when deploying those components in those frameworks and/or containers.
Well, this is considered an advanced thing in Java. Java classes are stored as Java byte codes. When you compile a Java source code, you will have .class file which is a Java byte code file. Java byte code is a form of machine instruction (in this case Java Virtual Machine or JVM). So it's executable binaries for JVM. Java byte code also have opcode like assembly language.
There are 2 type of instruction sets:
- stack machine
- register machine
Stack machine operates on stack. Operands are the stack only. The first programmable scientific calculators released by Hewlett-Packard are stack machines (http://www.hpmuseum.org/). They operate in a Reverse Polish Notation. I remembered that my first one of my first Java programming assignment was to implement GUI application for a Reverse Polish Notation calculator. My Dad has his own story of owning one of these calculators and he used to be very proud of the magnetic stripe stored Moon Lander game. It's just a number only Moon Lander, but it's a game running on programmable HP calculator!
Other sample of stack machines that most of us still use is the Intel x86 math coprocessor instructions set. It uses registers that are organised as stack, which will rotate back when overflowing the boundary (of 8 registers).
Stack machines, because it's only operate on stack and usually only the last few data in stack, may have shorter instruction bits. Unlike register machines which usually take some of the bits to specify from which and which register the data is from, and to which register the result goes, stack machines enjoy the benefit of default operands, that is top 1 or top 2 of the stack. The result is always in the stack.
I think one of the main considerations why JVM uses stack machine is to pack as few numbers of bits in the opcode. As most JVM runs as virtual machine, there will be no performance advantages of having a lot of register which anyway stored in RAM by the virtual machines.
Ok, enough for the stack machine, now back to the BCEL it's exciting to touch back the assembly language, byte code, opcode, operand, and stuffs if you are really into it. I try to code a bit and will share the code later.
Monday, April 5, 2010
What is Spring Python?
Spring Python takes the concept of the Spring Framework and applies them to Python. This means that we can take advantage of the features of Spring Framework such as Dependency Injection (Inversion of Control), aspect oriented programming (AOP), remoting, data access, transactions, and security, all with the same non-invasiveness style.
This means that:
- it will be easier to unit test software components (Python objects with standardized dependency injection)
- we can move cluttering code outside the object and have cross-cutting functionalities (aspect oriented programming)
- scalability of business objects by adding remoting
- transaction (ACID)
- security (interceptor based which won't allow outside world to touch your application unless they are really authenticated an authorized)
- you don't have to extends certain class in order to get all those features (non-invasiveness)
The project was started independently by Greg L. Turnquist, which later joined the SpringSource team as Project Lead for Spring Python project. He also authored "Spring Python" book from Packt.
Spring Python is now approaching version 1.1 with its second milestone before release 1.1.0.M2. Current stable release version is 1.0.0.
All about SpringPython can be found on its web site http://springpython.webfactional.com/
Saturday, April 3, 2010
PyDev 1.5.6 has been released
Fabio Zadrozny from Aptana, the author of PyDev plugin, passed this information through mailing list:
This Release Highlights:
- Django integration:
- New Django project can be created through twizard
- Can set an existing porject as a Django project (right-click project > pydev > set as django project) I think this is a kind of Eclipse's personality, like those of Maven2 plugins where you can declare that this project is a Maven project
- New Django project can be created throughtwizard
- Can remove Django project config (righ-click project > django > remove django project config)
- Custom actions can be passed to the configured manage.py through ctrl + 2 + dj django action -- if not action is passed, will open to choose from a list of previously used command
- Predefined/custom actions can be used through right-clicking the project > django > select custom action
- manage.py and settings module configured
- Django shell (with code-completion, history, etc) available
- Run/Debug as Django available
- See: http://pydev.org/manual_adv_django.html for more details
- Find/Replace:
- The search in open files is no longer added in the find/replace dialog and now works through Ctrl + 2+ s word_to_find (in the PyDev editor) and if no word is passed, the editor selection is used
- Go to definition:
- Properly works with unsaved files (so, it will work when searching for a definition on an unsaved file)
- Properly working with Eclipse 3.6 (having FileStoreEditorInput as the editor input)
- Editor:
- Automatically closing literals
- Removing closing pair on backspace on literal
- Improved heuristics for automatically closing (, [ and {
- Removing closing pair on backspace on (, [ and {
- Ctrl + 2 + sl (sl comes from 'split lines' -- can be used to add a new line after each comma in the selection
- Ctrl + 2 + is (is comes from 'import string' -- can be used to transform the selected import into a string with dots
- General:
- Code-completion properly working on relative import with an alias
- Fixed racing issue that could deadlock pydev (under really hard to reproduce circumstances)
- Removing reloading code while debugging until (if) it becomes more mature in the python side
- Fixed issue where a new project created didn't have the source folder correctly set
- Text selection in double click no longer has weird behavior
- Local refactoring working on files not in the PYTHONPATH
- Edit properly working on string substitution variables
- Using with statement on python 2.5 no longer makes lines wrong in the AST
Tuesday, March 23, 2010
Playing around with Ordered Dictionary (collections.OrderedDict)
The new and cool feature added to Python 3.1.x family is the Ordered Dictionary. Some implementations have been lying around for sometime, it's good to see one made it into the Python standard library.
Dictionaries are general purpose container data structure that are accessed through keys. It uses a hashing mechanism to achieve fast retrieval of information by key on typical cases. The annoying thing about standard dictionary dict object is that, whenever we retrieve the keys, it is not guaranteed to be sorted.
In Java platform, usually this dictionary is called map. java.util.Map provides interface to implementations of map such as java.util.HashMap, java.util.TreeMap.
Every value is associated with value, written in : pair.
Try to paste this code to your Python 3.1 interpreter:
[sourcecode lang="python"]<br />ud = dict()<br />ud['c']='1'<br />ud['b']='2'<br />ud['a']='3'<br />[/sourcecode]
This interactive session below highlight the thing:
[sourcecode lang="shell"]<br />&gt;&gt;&gt; ud = dict()<br />&gt;&gt;&gt; ud['c']='1'<br />&gt;&gt;&gt; ud['b']='2'<br />&gt;&gt;&gt; ud['a']='3'<br />&gt;&gt;&gt; ud<br />{'a': '3', 'c': '1', 'b': '2'}<br />[/sourcecode]Nice general purpose container for all of our applications. The dictionary keys doesn't display in sorted order.
Instead when we paste this code into Python interpreter:
[sourcecode lang="python"]<br />import collections as coll<br />od = coll.OrderedDict()<br />od['c']='1'<br />od['b']='2'<br />od['a']='3'<br />[/sourcecode]
We will get this result:
[sourcecode lang="shell"]<br />&gt;&gt;&gt; import collections as coll<br />&gt;&gt;&gt; od = coll.OrderedDict()<br />&gt;&gt;&gt; od['c']='1'<br />&gt;&gt;&gt; od['b']='2'<br />&gt;&gt;&gt; od['a']='3'<br />&gt;&gt;&gt; od<br />OrderedDict([('c', '1'), ('b', '2'), ('a', '3')])<br />[/sourcecode]As we can see in the result above, the collections.OrderedDict objects displayed the keys according to the sequence that they were inserted. When an insertion done on an already existing key, the new insertion will overwrite the value but the sequence is left untouched. A deletion followed by addition will move the key to the end of the list, as show in the session below (continuation of the previous one).
[sourcecode lang="shell"]<br />&gt;&gt;&gt; od['d']='4'<br />&gt;&gt;&gt; od<br />OrderedDict([('c', '1'), ('b', '2'), ('a', '3'), ('d', '4')])<br />&gt;&gt;&gt; od['b']='5'<br />&gt;&gt;&gt; od<br />OrderedDict([('c', '1'), ('b', '5'), ('a', '3'), ('d', '4')])<br />&gt;&gt;&gt; od.pop('a')<br />'3'<br />&gt;&gt;&gt; od<br />OrderedDict([('c', '1'), ('b', '5'), ('d', '4')])<br />&gt;&gt;&gt; od['a']='6'<br />&gt;&gt;&gt; od<br />OrderedDict([('c', '1'), ('b', '5'), ('d', '4'), ('a', '6')])<br />&gt;&gt;&gt;<br />[/sourcecode]I guess "battery included" still holds, or probably, "more organised battery included...".
Hooray for Python.
Python 3.1.2 Released (bug fix released)
Python 3.1.2 (bugfix release) is out now! We can download from this site: http://www.python.org/download/
Monday, February 1, 2010
Spring Python 1.1.0.M1 Released
SpringSource has has just announced last week of a milestone release of SpringPython 1.1.0.M1. This announcement made aware about this project. There is a project that has nearly reached its 1.1 version that tries to develop Spring-like framework in Python. I would like to look into this project.
It is different from invoking Spring Java from Jython in that, this project brings the concept of Spring framework into the CPython platform in general. Some of the configuration are really Pythonic!
I think I will explore more on this project.
Monday, November 2, 2009
Setting Up Your Own Jython 2.5.1 Environment
In this post I'll show you how to setup your own Jython environment.
Prerequisite to this, you must have a Java Runtime Environment (JRE) installed in your system. Chances are when you already have browser running some Java applet or Java Web Start application, you already have JRE installed on your system.
Get the latest JRE from http://java.com/en/download/manual.jsp.
First you need to download a Jython binaries installer, currently the latest one is version 2.5.1, which you could download from this link.
After download completion you should have a file named jython_installer-2.5.1.jar, click on the file, or run from command line:
[sourcecode lang="shell"]<br />$ java -jar jython_installer-2.5.1.jar<br />[/sourcecode]
Or in some other platform:
[sourcecode lang="shell"]<br />c:\> java -jar jython_installer-2.5.1.jar<br />[/sourcecode]
Now you need to add you Jython path to your OS Path variable, so that the shell or command line interpreter is able to find Jython. In my sample Windows installation case:
[sourcecode lang="shell"]<br />C:\> set PATH=%PATH%;c:\opt\env\jython2.5.1<br />[/sourcecode]
Alternatively, if you are running bash shell (assuming you installed Jython to /opt/env/jython2.5.1 folder):
[sourcecode lang="shell"]<br />$ export PATH=$PATH:/opt/env/jython2.5.1<br />[/sourcecode]
Now you may proceed with the first invocation of Jython.
[sourcecode lang="shell"]<br />C:\> jython<br />*sys-package-mgr*: processing new jar, 'C:\opt\env\jython2.5.1\jython.jar'<br />*sys-package-mgr*: processing new jar, 'C:\Program Files\Java\jre6\lib\resources.jar'<br />*sys-package-mgr*: processing new jar, 'C:\Program Files\Java\jre6\lib\rt.jar'<br />*sys-package-mgr*: processing new jar, 'C:\Program Files\Java\jre6\lib\jsse.jar'<br />*sys-package-mgr*: processing new jar, 'C:\Program Files\Java\jre6\lib\jce.jar'<br />*sys-package-mgr*: processing new jar, 'C:\Program Files\Java\jre6\lib\charsets.jar'<br />*sys-package-mgr*: processing new jar, 'C:\Program Files\Java\jre6\lib\ext\dnsns.jar'<br />*sys-package-mgr*: processing new jar, 'C:\Program Files\Java\jre6\lib\ext\localedata.jar'<br />*sys-package-mgr*: processing new jar, 'C:\Program Files\Java\jre6\lib\ext\QTJava.zip'<br />*sys-package-mgr*: processing new jar, 'C:\Program Files\Java\jre6\lib\ext\sunjce_provider.jar'<br />*sys-package-mgr*: processing new jar, 'C:\Program Files\Java\jre6\lib\ext\sunmscapi.jar'<br />*sys-package-mgr*: processing new jar, 'C:\Program Files\Java\jre6\lib\ext\sunpkcs11.jar'<br />Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)<br />[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_16<br />Type "help", "copyright", "credits" or "license" for more information.<br />>>><br />[/sourcecode]
The jython command line actually invoked a Windows batch file jython.bat, which
When first time invoked, Jython interpreter will activate sys-package-mgr to add standard Java library classes as Python package.
After the installation, just play around with simple thing such as:
[sourcecode lang="shell"]<br />Jython 2.5.1 (Release_2_5_1:6813, Sep 26 2009, 13:47:54)<br />[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_16<br />Type "help", "copyright", "credits" or "license" for more information.<br />>>> from java.lang import System<br />>>> System.out.println(&quot;Hello, world!&quot;)<br />Hello, world!<br />>>> System.out.println('Hello, world!')<br />Hello, world!<br />>>> System.currentTimeMillis()<br />1257145977410L<br />>>> from java.lang import String<br />>>> s = String(&quot;abc&quot;)<br />>>> s.toString()<br />u'abc'<br />[/sourcecode]Look at how System.out.println is able to receive both single quote and double quote Python string, and also the java.lang.String type by a Java class method is a Unicode string (u'abc').
Wednesday, October 21, 2009
PyDev 1.5 on Eclipse Galileo 3.5 SR1
I begin to have more time to explore the Eclipse Galileo Service Release 1 (Eclipse 3.5.1). This time I want to set it up for my Python development, using the PyDev plugin.
PyDev is an Eclipse plugin for Python language application development. It supports CPython, Jython and IronPython runtimes. It supports the interactive as well as non-interactive Python development on Eclipse IDE.
Eclipse IDE (and platform) has become the de facto industry standard IDE. More and more free software, open source software, and proprietary software makers build their systems on Eclipse platform. Galileo is the codename for 3.5 release, and now the latest one is the SR1 (Service Release 1).
There has been interesting development on PyDev since its last 1.4.7 version. PyDev has moved to be sheltered under the umbrella of Aptana. PyDev and PyDev Extension now has been merged and both now open source (previously the PyDev Extension, the advanced version of PyDev was not an open source).
The update site has been moved from domain www.fabioz.com (http://www.fabioz.com/pydev) to domain pydev.org (http://pydev.org/updates) . Aptana This development looks good for me, means that PyDev now being maintained by its own organization, and hopefully in more serious efforts.
In Eclipse Galileo, you need to go to the menu and choose: Help > Install New Software...
It will show the Install dialog.
Click the [Add] button on the upper of menu dialog. You will get the "Add Site" dialog.
Type name and location.
Name: "PyDev Update Site" (you can feel with any arbitrary name though)
Location: http://pydev.org/updates
Back to the "Install" dialog, the previous "Add Site" will fill up the "Work with" field for you.
Now tick the Checkbox "PyDev for Eclipse" under "PyDev". You may also optionally tick the "Pydev Mylyn Integration". In this example we don't tick.
Click the [Next >] button. It will show you the Install Details:
Proceed by clicking [Next >] button. Review Licenses dialog will be displayed.
Click the radio button "I accept the terms of the license agreement" when you are agree with the licenses. Proceed by clicking [Finish] button.
You will see the progress bar. Somewhere around the progress, you will be asked whether to install software that contains unsigned content.
Click [OK] to proceed (we have no choice as long as the provider of this plugin hasn't signed the content).
Click the [Yes] button to restart your Eclipse IDE.
