Wednesday, July 11, 2012

Starting on Lisp

I'm a Python programmer. But you should never stop learning!

I'm using OSX and heavily into webdevelopment, so i used Homebrew to install Lisp and the Hunchentoot webserver.

The procedure is:

  1. Install Homebrew
  2. Install SBCL using Homebrew
  3. Install Quicklisp
  4. With quicklisp its easy to install the Hunchentoot lisp webserver

Start a Hunchentoot webserver:

(hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 4242))





Monday, September 21, 2009

Watch folder for change


import os
import sys
import time

import win32file
import win32event
import win32con

ACTIONS = {
1 : "Created",
2 : "Deleted",
3 : "Updated",
4 : "Renamed from something",
5 : "Renamed to something"
}
FILE_LIST_DIRECTORY = 0x0001

path_to_watch = u"d:\\test"
path_to_watch = os.path.abspath (path_to_watch)

print "Watching %s at %s" % (path_to_watch, time.asctime ())

FILE_LIST_DIRECTORY = 0x0001
hdir = win32file.CreateFile (path_to_watch,
FILE_LIST_DIRECTORY, win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE,
None, win32con.OPEN_EXISTING, win32con.FILE_FLAG_BACKUP_SEMANTICS, None)


while 1:

results = win32file.ReadDirectoryChangesW (
hdir, 1024, True,
win32con.FILE_NOTIFY_CHANGE_FILE_NAME |
win32con.FILE_NOTIFY_CHANGE_DIR_NAME |
win32con.FILE_NOTIFY_CHANGE_ATTRIBUTES |
win32con.FILE_NOTIFY_CHANGE_SIZE |
win32con.FILE_NOTIFY_CHANGE_LAST_WRITE |
win32con.FILE_NOTIFY_CHANGE_SECURITY,
None, None
)
for action, file in results:
full_filename = os.path.join (path_to_watch, file)
print full_filename, ACTIONS.get (action, "Unknown")

Sunday, July 6, 2008

Django for CMS, Part 2

I have previously had doubts about the benefits of using Django as a framework for a CMS. I still have my doubts but after working with Django I might be about to change my mind.

The last year or so I have completed 4 projects using Django. 3 out of 4 projects was completed in time with a result that satisfied the customer. All 4 projects of cause of a higher quality that could be accomplished without the use of a framework.

But Django is not an easy framework to use. Even though the basic usage of the framework if simple, it takes time to master more complex tasks. Or what really takes time is to research the topic and discover the correct way to handle the task from within the framework.

But non the less, it's a greate framework!

So, why choose Django as the framework for a CMS? Here are some points:

1. It's easy to catch and URL and map it to a page-like object.

2. There are more and more "off the shelf" plug-and-play Django applications which could easy be integrated into the CMS.

3. Easy to write new CMS extensions as just another application.

4. Build-in json generator to ease communication with client side javascript.

So, after I have really gotten to know Django I feel that it might be the right choice for a CMS. And as Django is slowly getting to a stable version 1.0 and having got the Google stamp of approvel (used in Google App Engine), it might just be time to start.

Wednesday, July 11, 2007

Web 2.0

Web 2.0 is old news, but still funny :-)

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.

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.

  1. 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.
  2. 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.
  3. 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.