Python: Turbogears and Templates
Been working one of the pages and setting up conditional stuff in a table. Seems to working well. Basically if I return data with some rows in it I display a select dropdown if not I display a submit button that will allow the user to create whatever it is they don't have to select from...
I wonder if that made sense.
Basically it does something like this:
are there rows?
if yes: show the rows
if no: show a button that takes you to a page so you can create the type of things you don't have rows for.
Python: Templates in TurboGears, and a solution to SQLObject Problem
Well, I got templates working, and it was not as bad as it could have been. Plus I found an example of looping through a SQLObject and it is rather elegant. Although I have not implemented. I should be able to do something like this:
for Table.field in Table.select(Table.q.select(fred=1)): do something here.
Once I get the real code working I will post it.
Templates are fun, but at times frustrating, plus I think I was trying to do something you can't easily do, nested for loops in a template. Just didn't work, so I went a different way. So my homepage for my project is about 30% complete, it is taking me a little longer than I would like, but then that is what happens when you are learning something for the first time.
Plus I found some idiosyncrasies with extended templates not being picked up without a restart of the CherryPy Server, but that made sense to me for some reason. I figure it grabs the master.kid which is being extended when it starts and does not check to see if it has changed and needs to be reloaded.
I do like the fact that CherryPy know when the controllers.py or model.py file is saved, that might be TurboGears doing that, but it is cool you change the page save it and the server shuts down and restarts.
So all in all I nice system. Oh also, yesterday I upgraded to TurboGears 0.9 to get all the new features, of course there is very little documentation on these features so I have not had a chance to explore them.
But it was fun working on it when I wasn't in meanings and doing real work. Although I just have to convince my boss that real company projects can be developed in this language.
Java, not my favorite language is what I am working in for the current project. In fact once I finish the authentication pages that I am working on, I will look into implementing our new front-end with JSFaces, looks sort of .NET like, and I enjoyed that once I learned it so we will see how that goes over the next few weeks. So I should have more side by side compares and experiences to relate in the near future.
¶ 4:52 PM0 comments
Monday, March 13, 2006
Python: SQLObject or How Dumb a Programmer am I?
Ok, I know that I am dumb sometimes, but I also must be really thick too. It took me most of the day to figure out how to do a simple select query in SQLObject.
Basically I ended up doing something like this:
def VoiceTypeContents(self): p = VoiceType.select().count() html = "<li>" + str(p) if p > 0: for i in range(p): vt = VoiceType.get(i + 1) html += "<li>" + vt.description return html
Now I am sure there is a better way, but the biggest complaint that I have with programmers and I am one of them, is that we suck a doing documentation. And since a lot of open source stuff is early in its development cycles, examples are quite sparse.
Now that being said, I think that SQLObject is a great package, and I can see the power of it and I am sure as I figure it out it will be fun to work with, but boy did I pound my head against some walls today.
Next is doing the same thing as above but using templates. :) Dumb stuff I know, but it is how we learn.
¶ 4:58 PM0 comments
Friday, March 10, 2006
Python: Church Music Assistant v0.01
One thing that I have not really talked about here is my professional life, I am a programmer by trade, currently writing things in VB6, Java and Python. I picked up Python about a little over a year ago, when I got hired in my current job.
Well one of things that I started working on in my spare time was something to keep the Church Music that I select such as hymns and anthems organized.
My first attempt was to do a tradional application in Windows using python and wax a wxPython wrapper. Well I didn't get very far, basically because I got swamped at work.
Well recently I have been exposed to TurboGears, and I bit the bullet and have upgraded my Python to 2.4, so now I am all set to recode my app in Turbogears.
My plan is that this will become the start of progamming diary, about the trials and tribulations of creating a Web Application from scratch with a totally new framework. I have done this professionally in .NET and in a language nobody probably has heard of MetaHTML, but I have not done it recently so it will not necessarily be a new experience, but I am sure it will be an interesting one.
I have been married for almost 23 years, and am the father of a teenage girl. I spend my days programming in just about any language they want in the banking and investing field. In the evening I work on my music, currently concentrating on arrangements and new choral pieces for my Church Choir. I have been Minister of Music, at my church for the past year, looking forward to next year. When I have time, I take pictures of anything and anyone. Also I play golf, not very well, but I enjoy it. Finally what I enjoy most is spending time with my family.