Here is an extract of fields.py one of the openerp kernel file:
class _column(object):
.....
def __init__(self, string='unknown', required=False, readonly=False, domain=None, context=None, states=None, priority=0, change_default=False, size=None, ondelete=None, translate=False, select=False, manual=False, **args):
...
for a in args:
if args[a]:
setattr(self, a, args[a])
...
This last for loop is programmer paradise. It simply means you can create any field and add directly data to the field definition like a qualifier or anything you need in the constructor.
Simply cool, elegant and efficient !
Showing posts with label python. Show all posts
Showing posts with label python. Show all posts
Friday, August 17, 2012
Wednesday, May 02, 2012
Welcome to the Postgres magazine
When I decided to move to OpenERP, I had to move also to supporting technologies. Python of course (on which I still have a mixed feeling...) and Postgres.
Just one sentence : I love Postgres. It is enterprise ready, robust, extensible it is SQL and now noSQL etc etc
So join me and read pgmag.org
http://pgmag.org !
Just one sentence : I love Postgres. It is enterprise ready, robust, extensible it is SQL and now noSQL etc etc
So join me and read pgmag.org
http://pgmag.org !
Monday, September 19, 2011
OpenERP - Python - AttributeError: 'tuple' object has no attribute 'copy'
While OpenERP is a time saver for many aspects of writing a DB oriented app. Many aspects of the framework are left to the python and thus the framework.
I spent hours searching for this one...
AttributeError: 'tuple' object has no attribute 'copy'
I am too much use to declarative language like Java... so I still miss some basic reflex... This error was in the definitions of my class object:
lass bemedicalworksheet (osv.osv):
_name = 'nisf.bemedicalworksheet'
_columns = {
'vipowigw': fields.boolean("Wigw"),
},
well this last coma makes python thinking it is a tuple instead of a dictionnary...
I spent hours searching for this one...
AttributeError: 'tuple' object has no attribute 'copy'
I am too much use to declarative language like Java... so I still miss some basic reflex... This error was in the definitions of my class object:
lass bemedicalworksheet (osv.osv):
_name = 'nisf.bemedicalworksheet'
_columns = {
'vipowigw': fields.boolean("Wigw"),
},
well this last coma makes python thinking it is a tuple instead of a dictionnary...
Friday, February 04, 2011
Pychecker
I will not discuss the pro and cons of Python vs Java. But I regret everyday my taking care compiler / ide.
Simple syntax error like a missing bracket , a bad function description are enough to get a module unloadable by OpenERP. Things that would be immeidlately noticed with Netbeans online compile consume sometimes hours of vain and frustrating research....
This morning I found a good tool, similar to lint but for Python :
http://pychecker.sourceforge.net/
It really helps...
Simple syntax error like a missing bracket , a bad function description are enough to get a module unloadable by OpenERP. Things that would be immeidlately noticed with Netbeans online compile consume sometimes hours of vain and frustrating research....
This morning I found a good tool, similar to lint but for Python :
http://pychecker.sourceforge.net/
It really helps...
Monday, January 18, 2010
Python IDE - switched to PyDev
Last week, I wanted to prepare to my OpenERP technical training. So I was ready to buy one licence for Wingware. I don't mind paying for a licence, but I don't like their activation limit. I am spending my time installing new pcs, real and virtual one. Will I have to negociate with them exta-keys?
So I decided to give a try to Eclipse 3.5.x. Installing Eclipse is fairly easy, specially on Ubuntu 9.10. Adding PyDev (http://www.pydev.org/) took me only a few minutes.
The net result is an excellent IDE probably exceeding Wingware. Very stable and with a bunch of nice features. The ultimate test: debugging OpenERP ! Yes it does without a problem.
So clearly, it is better than a text editor (although gedit is not that bad with plugins) a bit less user friendly than Netbeans (my point of view), yet an excellent tool for programming Python & OpenERP.
I hope later one this week to be able to add Bazaar support to it...
In my class today, I think almost the half of the students have Eclipse on their machine. Kind of standard !
So I decided to give a try to Eclipse 3.5.x. Installing Eclipse is fairly easy, specially on Ubuntu 9.10. Adding PyDev (http://www.pydev.org/) took me only a few minutes.
The net result is an excellent IDE probably exceeding Wingware. Very stable and with a bunch of nice features. The ultimate test: debugging OpenERP ! Yes it does without a problem.
So clearly, it is better than a text editor (although gedit is not that bad with plugins) a bit less user friendly than Netbeans (my point of view), yet an excellent tool for programming Python & OpenERP.
I hope later one this week to be able to add Bazaar support to it...
In my class today, I think almost the half of the students have Eclipse on their machine. Kind of standard !
Friday, October 16, 2009
Back to python - Wingware does the job - Netbeans does not
So I am back to Open ERP and Python. I wanted to start tracing in Open ERP. The best way for me to understand the application, see how to make modifications etc. And of course hunting bugs...
I already mentioned the new NetBeans support for Python. Unfortunately the debugger is not able to debug multi-threaded application. So I give up. Going through some books and articles I found Wingware http://www.wingware.com/.
This is not free but I think worth its moderated price. It exists for Windows & Linux. My trial is very positive.
I already mentioned the new NetBeans support for Python. Unfortunately the debugger is not able to debug multi-threaded application. So I give up. Going through some books and articles I found Wingware http://www.wingware.com/.
This is not free but I think worth its moderated price. It exists for Windows & Linux. My trial is very positive.
Monday, September 21, 2009
Back to Joomla - Cake -PHP
So after a long Open ERP period I am back to the Joomla world.
Almost a year ago I setup for one customer an application built around JQuery and Cake PHP. A bit later the customer asked for a web site which has been built with Joomla. It would be perfect if the the web site and the application could share the same look and feel. I feel a bit faulty : at that time using Cake was for the simplest way (for me) to structure a small PHP app... but I did not plan anything concerning the web site - at that time his web site was made (by somebody else) with Wordpress - excellent for making a blog but terrible for making a web site...
My first steps today are basically to get back a development environment, the web site, (joomla,db...) the app etc. As usual I use Netbeans, here 6.7 - the PHP support is now stable and official.
Following Netbeans recommendation, I picked XAMPP (http://www.apachefriends.org) to install PHP and MySQL - I am working on my HP XP portable (Paddle).
After having transferred the web site I got an error message in a few modules positions. I then restarted a fresh Joomla install - same result.
Warning: Parameter 1 to modMainMenuHelper::buildXML() expected to be a reference, value given in C:\xampp\htdocs\joomla\libraries\joomla\cache\handler\callback.php on line 99
Basically Joomla 1.15.xx is not compatible with PHP 5.30 (which comes with the currently latest XAMPP 1.7.2). So you need to get an older PHP version, thus an older XAMPP. Older release are not on the same site, so you need to go to http://sourceforge.net/projects/xampp/files/ to find what you need. I decided to go for 1.6.8 to be sure to get rid of PHP 5.30. Unfortunately I then hitted another issue with phpMyAdmin the MySQL tool I cannot live without...
Too bad. I did not investigate that one, I de-installed XAMPP again. So I moved to 1.7.1 which installed PHP 5.2.9. Proceeding with dichotomy for finding release that's the job I am in...
It is now working (after a small battle for setting up a user and a password).
The rumor says that this will be fixed with Joomla 1.5.15 to be released soon (october).
One more time, I regret the Java platform. Some so called Agile programmers believe that their productivity decrease because of compile cycles, I am laughing at that. These compile times represent little amounts of time for most programming jobs. For me, the Netbeans background compiler removed this concern entirely.
The key point for the pro-compiler camp is this for me : the semantic analysis is a job for developers not for users. When a code is compiled with Java 1.4 it runs on 1.6 just because the VM are backward compatible at the VM level and in spite the language continues to evolve. Language changes do not impact the compiled and so you can keep your olfd stuff working as designed on a recent platform.
At this stage the two interpreted language that I used exhibited the same poor facilities to handle changes in the language itself : PHP & PYTHON.
So I move back to my stuff and still continue dreaming of the perfect environment for my job...
Almost a year ago I setup for one customer an application built around JQuery and Cake PHP. A bit later the customer asked for a web site which has been built with Joomla. It would be perfect if the the web site and the application could share the same look and feel. I feel a bit faulty : at that time using Cake was for the simplest way (for me) to structure a small PHP app... but I did not plan anything concerning the web site - at that time his web site was made (by somebody else) with Wordpress - excellent for making a blog but terrible for making a web site...
My first steps today are basically to get back a development environment, the web site, (joomla,db...) the app etc. As usual I use Netbeans, here 6.7 - the PHP support is now stable and official.
Following Netbeans recommendation, I picked XAMPP (http://www.apachefriends.org) to install PHP and MySQL - I am working on my HP XP portable (Paddle).
After having transferred the web site I got an error message in a few modules positions. I then restarted a fresh Joomla install - same result.
Warning: Parameter 1 to modMainMenuHelper::buildXML() expected to be a reference, value given in C:\xampp\htdocs\joomla\libraries\joomla\cache\handler\callback.php on line 99
Basically Joomla 1.15.xx is not compatible with PHP 5.30 (which comes with the currently latest XAMPP 1.7.2). So you need to get an older PHP version, thus an older XAMPP. Older release are not on the same site, so you need to go to http://sourceforge.net/projects/xampp/files/ to find what you need. I decided to go for 1.6.8 to be sure to get rid of PHP 5.30. Unfortunately I then hitted another issue with phpMyAdmin the MySQL tool I cannot live without...
Too bad. I did not investigate that one, I de-installed XAMPP again. So I moved to 1.7.1 which installed PHP 5.2.9. Proceeding with dichotomy for finding release that's the job I am in...
It is now working (after a small battle for setting up a user and a password).
The rumor says that this will be fixed with Joomla 1.5.15 to be released soon (october).
One more time, I regret the Java platform. Some so called Agile programmers believe that their productivity decrease because of compile cycles, I am laughing at that. These compile times represent little amounts of time for most programming jobs. For me, the Netbeans background compiler removed this concern entirely.
The key point for the pro-compiler camp is this for me : the semantic analysis is a job for developers not for users. When a code is compiled with Java 1.4 it runs on 1.6 just because the VM are backward compatible at the VM level and in spite the language continues to evolve. Language changes do not impact the compiled and so you can keep your olfd stuff working as designed on a recent platform.
At this stage the two interpreted language that I used exhibited the same poor facilities to handle changes in the language itself : PHP & PYTHON.
So I move back to my stuff and still continue dreaming of the perfect environment for my job...
Friday, September 04, 2009
python - version selection - easy_install
Finally, I found out the basic trick to use easy_install (so called Python setup tools) and to point it to the right python install.
Well : simply call the script with the right python version !
sudo python2.5 /usr/bin/easy_install -f http://files.turbogears.org/ "TurboGears==1.0.8"
easy_install -f http://files.turbogears.org/ "TurboGears==1.x.y"
Yes!
Thursday, July 23, 2009
Time for summer holidays
It is time for holidays. So a bit of desk cleaning and that's it. Two weeks for giving up with databases, Java, Python... projects, plannings and budgets. I am taking my portable of course, but that's basically for emergency only...
I finished my first Tony Buzan book. This was a bit general - the french title 'une tête bien faite', I think the original title is 'use your head', the book goes over fast reading, memory and mind-mappings (a subject I like more and more).
There is a lot to say about these subjects and Tony Buzan has written books dedicated to each of them -- I will continue investigating.
Following Tony Buzan recommendations, mind-maps should be graphical (including graphic but also being smartly shaped) and coloured. It is a shame that all software tools that I have see currently are implementing very regular organisation pattern and don't promote that much colors and graphics. Anyway, I recommend you this book.
On the Open ERP front line, I finished a small doc concerning Initial Analysis - see previous post and what to prepare to have good, constructive interviews sessions with business processes owners. Tiny provided me three mind-maps. A good start but I will try to develop mine for the next project...
I have done a bit of testing with Python, but I had not time to finish my test software - submitting HTML forms to a Joomla web site. Hm that will be for August I guess...
Finally I am taking with me 'Everything is Miscellaneous' - ' The power of the new digital disorder' from David Weinberger. Social aspects of the web is fascinating and I hope to work more on it later this year...
So I hope to come back rested and a bit smarter - what a plan !
I finished my first Tony Buzan book. This was a bit general - the french title 'une tête bien faite', I think the original title is 'use your head', the book goes over fast reading, memory and mind-mappings (a subject I like more and more).
There is a lot to say about these subjects and Tony Buzan has written books dedicated to each of them -- I will continue investigating.
Following Tony Buzan recommendations, mind-maps should be graphical (including graphic but also being smartly shaped) and coloured. It is a shame that all software tools that I have see currently are implementing very regular organisation pattern and don't promote that much colors and graphics. Anyway, I recommend you this book.
On the Open ERP front line, I finished a small doc concerning Initial Analysis - see previous post and what to prepare to have good, constructive interviews sessions with business processes owners. Tiny provided me three mind-maps. A good start but I will try to develop mine for the next project...
I have done a bit of testing with Python, but I had not time to finish my test software - submitting HTML forms to a Joomla web site. Hm that will be for August I guess...
Finally I am taking with me 'Everything is Miscellaneous' - ' The power of the new digital disorder' from David Weinberger. Social aspects of the web is fascinating and I hope to work more on it later this year...
So I hope to come back rested and a bit smarter - what a plan !
Wednesday, July 15, 2009
Friday, July 10, 2009
First steps with Python support in Netbeans 6.7
Python support is being added to Netbeans.
Install Netbeans 6.7 (in my case the bundled JDK did not installed, so I had to install the JDK speartely) then in the list of plugins install the Python module.
http://www.netbeans.org/kb/docs/python/temperature-converter.html
The install will bring you Jython as a first Python platform. I will keep that for further study. I then installed the Cpython 2.6. Restarted the Netbeans platform and to my great surprise Tools/Python plaftorms auto detected the new Pyhton install !
I created a project, but there, a problem occured when trying to debug. The message was a bit hard to decode. I saw file names truncated (under Windows, the default projects directory is under 'Documents and settings'. I changed the location to avoid spaces (something I always remind around me - don't put space in file names) and it works (I mean I can debug a 2 lines long Python program.
Install Netbeans 6.7 (in my case the bundled JDK did not installed, so I had to install the JDK speartely) then in the list of plugins install the Python module.
http://www.netbeans.org/kb/docs/python/temperature-converter.html
The install will bring you Jython as a first Python platform. I will keep that for further study. I then installed the Cpython 2.6. Restarted the Netbeans platform and to my great surprise Tools/Python plaftorms auto detected the new Pyhton install !
I created a project, but there, a problem occured when trying to debug. The message was a bit hard to decode. I saw file names truncated (under Windows, the default projects directory is under 'Documents and settings'. I changed the location to avoid spaces (something I always remind around me - don't put space in file names) and it works (I mean I can debug a 2 lines long Python program.
Thursday, June 04, 2009
Spring for Python - Yes they can !
I could not believe my eyes... SpringSource did it again... translating parts of its framework to Python -- including the IOC ! Ok I am convinced, I will give a serious look at Python.
By the way, my OpenERP on my Ubuntu is fine. I will go through Python tutorial (I bought already two book in french, but I found them not that good) and build a first development environnment.
By the way, my OpenERP on my Ubuntu is fine. I will go through Python tutorial (I bought already two book in french, but I found them not that good) and build a first development environnment.
Sunday, May 31, 2009
Back to Ubuntu - Installed OpenERP
Well, my experience with OpenSuse are over. There are basically 3 reasons.
1- performance. This thing is slow, slow, slow. My previous Suse 9.2 on a Pentium 4 was fine but with OpenSuse 11.1 it is strictly unusable.
2 - in spite of various attempts. I cannot get a config capable of NFS mounting from my SLES server at boot time.
3 - the repository is not complete as far Python is concerned. Annoying as I am digging into OpenERP a python based software.
So I moved to Ubuntu (8.1). Performance is great, may be faster than my old suse. Server admin : I miss Yast. But I put webmin using the debian package. So far so good.
I installed today OpenERP 5.0.1. Really easy cool setup. I must say my first opinion on Python is relatively negative. I don't link the syntax, the idea of significant indentations repulsed me... But as my coworker remarked, this will at least push me to indent my code (I do - but I am more a vertical developper than an horizontal one :-).
Also I am sure I will regret Java independance and the fact that good python extension are typically written using C or C++. Not talking about my Netbeans ide, my be-loved spring stuff...
However I admit the resulting app in this case is great !
Among the advantage of Python the designer of the app said to me that data structures changes are more simply implemented via python. I can agree. With a typicall Java ORM (JPA or Hibernate), any changes in the DB will turn into endless changes into the code base. So this is not new 'religion' to me, but I will sure look how OpenERP is built and why try to find why this ERP shine while all the Java based products miss elementary functionnalities and are pain in the a.. to setup and use.
1- performance. This thing is slow, slow, slow. My previous Suse 9.2 on a Pentium 4 was fine but with OpenSuse 11.1 it is strictly unusable.
2 - in spite of various attempts. I cannot get a config capable of NFS mounting from my SLES server at boot time.
3 - the repository is not complete as far Python is concerned. Annoying as I am digging into OpenERP a python based software.
So I moved to Ubuntu (8.1). Performance is great, may be faster than my old suse. Server admin : I miss Yast. But I put webmin using the debian package. So far so good.
I installed today OpenERP 5.0.1. Really easy cool setup. I must say my first opinion on Python is relatively negative. I don't link the syntax, the idea of significant indentations repulsed me... But as my coworker remarked, this will at least push me to indent my code (I do - but I am more a vertical developper than an horizontal one :-).
Also I am sure I will regret Java independance and the fact that good python extension are typically written using C or C++. Not talking about my Netbeans ide, my be-loved spring stuff...
However I admit the resulting app in this case is great !
Among the advantage of Python the designer of the app said to me that data structures changes are more simply implemented via python. I can agree. With a typicall Java ORM (JPA or Hibernate), any changes in the DB will turn into endless changes into the code base. So this is not new 'religion' to me, but I will sure look how OpenERP is built and why try to find why this ERP shine while all the Java based products miss elementary functionnalities and are pain in the a.. to setup and use.
Tuesday, May 26, 2009
Python 2.6 - OpenERP openSuse 11.1
Well, I am looking at an open source ERP called "OpenERP". Not a very orginal name but an impressing product. Strangely this is written in Python. Quite uncommon but only the result matters...
The editor provides good documentation for installing the sofwtare. Example are given for Ubuntu. The apt-get commands solves dependencies issues and Ubuntu install was painless. But I am now with my openSuse distro.
I tried getting apt-get for openSuse and use zypper (the equivalent of apt-get for openSuse). Unfortunately some dependencies cannot be solved.
As usual wrong rumor circulates, one being that OpenERP does not work with Python 2.6. I checked yesteday with the editor. Not correct it works with Pythpn 2.6.
The problem is simply that the openSuse repositories are not complete and do not contain all the need libraries.
The editor provides good documentation for installing the sofwtare. Example are given for Ubuntu. The apt-get commands solves dependencies issues and Ubuntu install was painless. But I am now with my openSuse distro.
I tried getting apt-get for openSuse and use zypper (the equivalent of apt-get for openSuse). Unfortunately some dependencies cannot be solved.
As usual wrong rumor circulates, one being that OpenERP does not work with Python 2.6. I checked yesteday with the editor. Not correct it works with Pythpn 2.6.
The problem is simply that the openSuse repositories are not complete and do not contain all the need libraries.
Sunday, May 24, 2009
Args - My NFS proble solved
After hours of idiot searches. I simply cleaned the/etc/mtab~ file (the lock file for the mtab - mounted files). And it works. So my Python install had nothing to do with my NFS issue. I feel better.
Giving up with Ubuntu for now - looking at OpenSuse
I need to upgrade my Linux computers.
Linuxers may explain you that Linux solves install dependencies issues - dll hell. Unfortunately that's wrong. One day, you will find the need to install software requiring something requiring a more recent kernel. Is it possible to get around it? May be, may be not. For the common Linux user (I don't want to recompile others stuff) the only path is to upgrade the entire OS and rebuild you complete stuff.
I did a try with Ubuntu desktop. Nice install and a good looking desktop with easy config. Synaptic package manager is great. The shell apt-get is great to install software in a matter of minute. I found it promising...
However I decided to go for OpenSuse. Why? Simply said, the separation between so called Desktop / Server is pure marketing vision - at least in the Linux world. What if you have a desktop and want to organize your mind with a wiki? What if you are a Web developper.What if you want a database etc Well it is all server stuff. So this separation is artificial and unworkable.
Ubuntu server exists but unfortunately they haven't done for server the great work they did for Desktop - I mean a good administration front-end. So every piece of software will require you to dig in to file based condigs without help.
So I started to regret Suse (I used Suse 9.2 and Sles 10.x) and Yast (equivalent to Windows control panel) which does an honorable job at configuring everything on your system.
It almost worked fine... Install is friendly as Ubuntu and the desktop is the same - I took Gnome as it seems to be defacto standard (in the past I preferred KDE but since their version 4 big bang they are loosing support I think).
Performance is not that great. Bloating is not only a MS Windows problem. Moving from Suse 9.x to 11.x seems to be the same performance loss as you move from XP to Vista...
Well it worked fine... until I tried to install extra packages - Python libs. Since then (is it related ? It is still strange to me, but it is the only thing I did with it...) I cannot mount my NFS share with my fresh desktop anymore (it worked, yes it worked for almost a day and now, it is gone). Mysterious ! And I don't see what's wrong with this NFS share.
Why do I need Python? Well, it will be for a coming article.
Linuxers may explain you that Linux solves install dependencies issues - dll hell. Unfortunately that's wrong. One day, you will find the need to install software requiring something requiring a more recent kernel. Is it possible to get around it? May be, may be not. For the common Linux user (I don't want to recompile others stuff) the only path is to upgrade the entire OS and rebuild you complete stuff.
I did a try with Ubuntu desktop. Nice install and a good looking desktop with easy config. Synaptic package manager is great. The shell apt-get is great to install software in a matter of minute. I found it promising...
However I decided to go for OpenSuse. Why? Simply said, the separation between so called Desktop / Server is pure marketing vision - at least in the Linux world. What if you have a desktop and want to organize your mind with a wiki? What if you are a Web developper.What if you want a database etc Well it is all server stuff. So this separation is artificial and unworkable.
Ubuntu server exists but unfortunately they haven't done for server the great work they did for Desktop - I mean a good administration front-end. So every piece of software will require you to dig in to file based condigs without help.
So I started to regret Suse (I used Suse 9.2 and Sles 10.x) and Yast (equivalent to Windows control panel) which does an honorable job at configuring everything on your system.
It almost worked fine... Install is friendly as Ubuntu and the desktop is the same - I took Gnome as it seems to be defacto standard (in the past I preferred KDE but since their version 4 big bang they are loosing support I think).
Performance is not that great. Bloating is not only a MS Windows problem. Moving from Suse 9.x to 11.x seems to be the same performance loss as you move from XP to Vista...
Well it worked fine... until I tried to install extra packages - Python libs. Since then (is it related ? It is still strange to me, but it is the only thing I did with it...) I cannot mount my NFS share with my fresh desktop anymore (it worked, yes it worked for almost a day and now, it is gone). Mysterious ! And I don't see what's wrong with this NFS share.
Why do I need Python? Well, it will be for a coming article.
Subscribe to:
Posts (Atom)