Thought about development and more. My interest is mainly in Python, Ruby and Lisp development, web and AI.
Wednesday, July 11, 2007
Primoris CMS
I have created a project on Google Code for a CMS and CMS framework developed in Python.
http://code.google.com/p/primoris/
The framework will support access (users, groups) , pages and page hierarchies , i18n and extension modules.
http://code.google.com/p/primoris/
The framework will support access (users, groups) , pages and page hierarchies , i18n and extension modules.
Saturday, April 21, 2007
Django for CMS
Well, Django is nice for building web applications, but have some drawback if you need to develop a CMS.
- The URL dispatcher is not much help. In a CMS you cannot determine the content of a given URL without looking inside some sort of DB which hold the content. This means that the urlpatterns structure most likely will hold a regex to an admin system and a regex to a handers for all other URLS.
- The above point also means that you only have 2 Django application, the page handler and the admin system. What you really need in a CMS is the ability to display different content elements in the same page.
- The automatic admin system is just to lame to be any help in a CMS. It's lack of features, like a integrated editor (FCKEditor / TinyMCE) or an ability to grant some users access to specific part of the admin, unability to handle record positioning by an index (move up/down), makes it pretty useless.
So, what should you do? Roll your own content mangement framework (CMF), or reuse the parts of Django which can help you?
If it had been any other language I would probertly have gone for the reuse, but the is Python, and we have all sort of nice code (fx Paste) which can be used for a CMF.
I'm I way off?
Saturday, April 7, 2007
Django
So, there is quite a few Python web frameworks to choose from these days. Thats really nice. After Guidos appraisal of Django I have been giving it a try.
After a background in ASP its something quiet different: URL's are routed to a specific function, so no need for a file per URL. Arguments can be incorporated into the URL instead of having it in the querystring. Django also have a really nice ORM so you can write code without having to use SQL.
My initial project is to build a small CMS using Django.
The system will for a start consist of the following element:
Page
- name
- parentpage
Content
- page
- data
I'll post the code when i have got something working.
After a background in ASP its something quiet different: URL's are routed to a specific function, so no need for a file per URL. Arguments can be incorporated into the URL instead of having it in the querystring. Django also have a really nice ORM so you can write code without having to use SQL.
My initial project is to build a small CMS using Django.
The system will for a start consist of the following element:
Page
- name
- parentpage
Content
- page
- data
I'll post the code when i have got something working.
Tuesday, February 27, 2007
Autoupdate application modules
It's pretty easy to reload modules in Python. Using this feature you can update you whole application to a new version, without leaving or restarting your application.
The code below updates all loaded modules with newer version from any given path. To be included in the update, the module must contain the attribute autoupdate and a version attribute.
This only works for modules that can work after a reload. Fx. SQLObject has a problem with that...
It would be an easy task to extend this to autoupdate from a FTP- or website.
The code below updates all loaded modules with newer version from any given path. To be included in the update, the module must contain the attribute autoupdate and a version attribute.
import sys
import os
def check(path):
""" Update all modules containing a autoupdate attribute
"""
for name,mod in sys.modules.items():
if hasattr(mod,'autoupdate'):
last_version=getattr(mod,'version')
print "Testing update of : %s v. %d" % (name,last_version)
org_file=os.path.split(mod.__file__)[1].replace('.pyc','.py')
new_module_file="%s\\%s.%d" % (path,org_file,last_version+1)
if os.path.exists(new_module_file):
print "Update found: %s" % new_module_file
update=file(new_module_file,'rb').read()
destination="%s\\%s" % (os.getcwd(), org_file)
print "Will replace: %s" % destination
#os.remove(destination)
#file(destination,'wb').write(update)
reload(mod)
This only works for modules that can work after a reload. Fx. SQLObject has a problem with that...
It would be an easy task to extend this to autoupdate from a FTP- or website.
Sunday, February 25, 2007
Socket performance
Just written a small script to test network/firewall performance in Python, and could not help myself from testing it on both XP and Linux...
OpenSUSE 10.2 performance:
1896.296296 mbit / second
Windows XP performance:
299.645137 mbit / second
(Tested on a dualboot machine.)
So, again the question must be, is this related to Python or the OS?
Well, iperf to localhost on Win XP yields:
C:\Documents and Settings\Martin\Desktop>iperf.exe -c localhost
------------------------------------------------------------
Client connecting to localhost, TCP port 5001
TCP window size: 8.00 KByte (default)
------------------------------------------------------------
[1912] local 127.0.0.1 port 1328 connected with 127.0.0.1 port 5001
[ ID] Interval Transfer Bandwidth
[1912] 0.0-10.0 sec 610 MBytes 511 Mbits/sec
iperf on Linux:
martin@msjdell:~> iperf -c localhost
------------------------------------------------------------
Client connecting to localhost, TCP port 5001
TCP window size: 49.4 KByte (default)
------------------------------------------------------------
[ 3] local 127.0.0.1 port 28150 connected with 127.0.0.1 port 5001
[ 3] 0.0-10.0 sec 3.55 GBytes 3.05 Gbits/sec
OpenSUSE 10.2 performance:
1896.296296 mbit / second
Windows XP performance:
299.645137 mbit / second
(Tested on a dualboot machine.)
So, again the question must be, is this related to Python or the OS?
Well, iperf to localhost on Win XP yields:
C:\Documents and Settings\Martin\Desktop>iperf.exe -c localhost
------------------------------------------------------------
Client connecting to localhost, TCP port 5001
TCP window size: 8.00 KByte (default)
------------------------------------------------------------
[1912] local 127.0.0.1 port 1328 connected with 127.0.0.1 port 5001
[ ID] Interval Transfer Bandwidth
[1912] 0.0-10.0 sec 610 MBytes 511 Mbits/sec
iperf on Linux:
martin@msjdell:~> iperf -c localhost
------------------------------------------------------------
Client connecting to localhost, TCP port 5001
TCP window size: 49.4 KByte (default)
------------------------------------------------------------
[ 3] local 127.0.0.1 port 28150 connected with 127.0.0.1 port 5001
[ 3] 0.0-10.0 sec 3.55 GBytes 3.05 Gbits/sec
Monday, February 12, 2007
SQLObject
SQLObject is a really neat Object Relational Manager for Python. But imho not very well documented.
I have been developing a class which can handle the usual Create, Read, Update and Delete (CRUD) pattern. I'm using Kid for templates.
Here are some bites of the code:
I have been developing a class which can handle the usual Create, Read, Update and Delete (CRUD) pattern. I'm using Kid for templates.
Here are some bites of the code:
# getting a tables columns
for col in table.sqlmeta.columnList:
print col.name
columnType=table.sqlmeta.columnDefinitions[col.name]
if col.foreignKey==None:
# normal column
else:
# relationship column
# getting remove and add method in join
rm=getattr(obj,'remove' + join.addRemoveName)
rm(record) # remove a record from relation
Wednesday, January 31, 2007
Linux / XP speed difference
I have just tried to run a simple WSGI server, based on the Python WSGI server implementation, on Windows XP on openSUSE 10.2.
There are significant difference in speed:
Windows XP:
1. run : 0.51 secs (to load Python modules)
2. run : 0.04 secs (normal time to generate HTML)
openSUSE 10.2:
1. run : 0.29 secs (to load Python modules)
2. run : 0.02 secs (normal time to generate HTML)
The WSGI server displays an almost empty MoinMoin page.
The test was done on a dual boot laptop, so the hardware is identical. Both server and client was running on this machine.
It's properly not the OS's fault. Maybe the Python (v.2.5) implementation?
There are significant difference in speed:
Windows XP:
1. run : 0.51 secs (to load Python modules)
2. run : 0.04 secs (normal time to generate HTML)
openSUSE 10.2:
1. run : 0.29 secs (to load Python modules)
2. run : 0.02 secs (normal time to generate HTML)
The WSGI server displays an almost empty MoinMoin page.
The test was done on a dual boot laptop, so the hardware is identical. Both server and client was running on this machine.
It's properly not the OS's fault. Maybe the Python (v.2.5) implementation?
Laptop Linux
Just downloaded and installed openSUSE 10.2 and installed it on my Dell D410, and to my surprise it worked right "out of the box"! Tried the same a year ago with some different distributions, and I never got the whole laptop working. But even the WiFi works nicely with SUSE.
Seems appropriate to test an up to date Linux distro before surrendering to installing Windows Vista...
Seems appropriate to test an up to date Linux distro before surrendering to installing Windows Vista...
Tuesday, January 23, 2007
WSGI
Web Server Gateway Interface (WSGI) is the standard interface between web server software and Python web applications.
And this is really neat. The obvious first; you can plug any app supporting WSGI into any webserver supporting WSGI. And most webservers do, in some way or another. But whats even cooler is that WSGI has an architecture which allows applications to be stacked. You can have fx your authorization in a separate application.
Its easy and it allows for minimum coupling.
And this is really neat. The obvious first; you can plug any app supporting WSGI into any webserver supporting WSGI. And most webservers do, in some way or another. But whats even cooler is that WSGI has an architecture which allows applications to be stacked. You can have fx your authorization in a separate application.
Its easy and it allows for minimum coupling.
Welcome
Welcome to my blog.
I usually code web solutions in ASP, but my new love in programming languages is Python. So thats probertly what will be posted here.
I usually code web solutions in ASP, but my new love in programming languages is Python. So thats probertly what will be posted here.
Subscribe to:
Posts (Atom)