Archive for March, 2006
Python Script/ZSQL – Alternate data over 2 columns
by Greg on Mar.31, 2006, under Linux, Programming, Python
Here’s a quick post based on a Python Script I made in Zope to display the data from a ZSQL method in a 2 column table layout. Not that big of a deal, but I wanted to save this because it took a little bit of thought and some learning.
(My original code is all mess up on this, I’ll try to find and repost it.)
## Script (Python) "genlodinfo" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=itemid ##title= ## # Example code: ################################### """ Author: Greg Fischer 1st Byte Solutions - greg@1stbyte.com Date: 9/24/05 License: You are free to reengineer rework, recode, redistribute, resell or alter this code in any way you see fit, but you must give credit to my original work and you must provide this same license to those that may receive your distribution if you do. (just leave my name on it, and you must offer the same freedom in your work, that's all) Purpose: This script will gather from a zsql method, cat the records into address records (with exra info), then generate a table with alternating rows. In other words, it will fill the table from left to right, then down a row, 2 columns wide. """ ################################### def iseven(n): """Return true if n is even.""" return n%2==0 def isodd(n): """Return true if n is odd.""" return not iseven(n) # Import a standard function, and get the HTML request and response objects. from Products.PythonScripts.standard import html_quote request = container.REQUEST RESPONSE = request.RESPONSE rs = context.sql.ap_lodging(itemid) rownum = 1 x = [] for r in rs: ritemid = str(r[0]) rtqstart = str(r[4]) rtqend = str(r[5]) rstreet1 = r[12] rstreet2 = r[13] rcity = r[14] rstate = r[15] rzip = r[16] rnotes = r[18] lodstr = rtqstart + ' - ' + rtqend + ' ' lodstr = lodstr + rstreet1 + ' ' + rstreet2 + ' ' lodstr = lodstr + rcity + ', ' + rstate + ' ' + rzip + ' ' if rnotes <> '': lodstr = lodstr + rnotes + ' ' x.append(lodstr) table = '' tablee = ' ' tr = '' tre = '' td = '' tde = '' if len(x) >= 1: c = len(x) listing = '' cur = 0 for addy in x: listing = listing + '' #first build the addy with starting table elements #first record only if cur == 0: listing = listing + table + tr + td + addy + tde #Now check if this is an odd seq item, #just add a new cell and end the row if isodd(cur): listing = listing + td + addy + tde + tre #if this is an even item, it should be on a new row #and NOT the first item if iseven(cur) and cur <> 0: listing = listing + tr + td + addy + tde #all good, but if last record, then end row #else skip and loop to previous isodd and #add a new cell(which ends the row as well) if cur == (c - 1): listing = listing + tre #if this is the last item, end the table if cur == (c - 1): listing = listing + tablee cur = cur + 1 else: listing = 'No records' return listing
And you return the results simply by calling the script in your dtml. something like: dtml-var “path.to.script(itemid=itemid)”
As always, I hope this help someone else out there, not just myself! Good luck!
Compile PHP 5.1 with JPEG support on Debian
by Greg on Mar.30, 2006, under Linux, PHP
Ok, here’s my configure command:
./configure --with-apxs2=/path/to/httpd/bin/apxs --with-mysql=/path/to/mysql --with-mysql-sock=/tmp/mysql.sock --prefix=/path/to/httpd/php --with-config-file-path=/path/to/httpd/php --enable-force-cgi-redirect --disable-cgi --with-zlib --with-gettext --with-gdbm --with-gd --with-png --with-png-dir=/usr/lib --with-jpeg --with-jpeg-dir=/usr/lib --with-pdo-mysql --with-mysqli
I ran into errors trying to run the function imagecreatefromjpeg and imagesx and imagesy. And the system could not find the jpeg libs. On Debian Sarge, you need to run an apt-get install libjpeg62-dev. Also, I ran configure with just the –with-jpeg switch, and it didn’t work. So, I had to also include the –with-jpeg-dir=/path/to/lib. On Debian is was in /usr/lib. After that, it all worked out.
It’s worth noting, you must have libpng, libjpeg, and GD installed as well. If I remember, GD was already on Debian, or maybe it was in PHP, not sure about that, but I know it must installed.
My top three web design requirements
by Greg on Mar.23, 2006, under Programming, Web Design
Recently I asked myself, “If I had to pick 3 things that are most difficult in web design to achieve, and achieve all at once, what would I pick?” I thought about that and decided it really boils down to these three things: ( I may rephrase them later )
- Visually acceptable.
- Quick to load
- Accessible
If I can get all three of these things to match up, then we’re in good shape.
Let me explain briefly about this. At first you might say, “Duh!” Well, here’s how I define them.
Visually Acceptable
I really have 3 sub items that I must, must have in my designs, or must work around somehow as a limitation. Of course, to me it is unsaid, that you should strive for cross-browser compatibility. I am willing to live with a few graphical errors in Safari, because it is still visually acceptable. Such a very small percentage of the visitors use it on my sites. Even Opera, but I noticed that more and more, if it looks good on Firefox, it probably looks very close, if not just like it on Opera. (using fairly recent versions)
- I must always provide a graphically pleasing design that aligns images to the pixel. Having an image that is sliding over a single pixel can look terrible. Though, sometimes, if the bottom right corner of the page has a single pixel issue with colors that are hard to make out, then I don’t fuss too much. But I don’t like it.
- The layout must stretch according to my content. NOT WINDOW SIZE! Unlike all the CSS fans out there, I don’t utilize all CSS layouts because of the limitations in browser standards and the box model. The box model does not allow my dynamic content to stretch out the layout as needed. Liquid CSS layouts are not the same. So I use a hybrid layout, using a single table to wrap, maybe an inner 2 column table for my content, but other than that, it’s all divs. (new blog on just this topic later)
- Image transparencies! UGH! GIFs just don’t look good enough, and Internet Explorer does not support transparent PNG’s. PNG is an awesome image format, and the lack of support by the most widely used browser causes me to design around this limitation.
Quick to load
Do I really need to explain this one? Well, let’s just say, this is where I like CSS more. The more I can load into an external CSS file, the better. I can use them on tables too. But, being able to specify “header art” as a whole, even if it’s a larger image, is faster than loading many smaller images. So, I strive for this always.
Accessible
Yes, this is for those of us who have a hard time with all our graphics, small print, and visual layouts. When I create anything, I like to allow for larger fonts the visitor might adjust to on their browser. This can cripple the graphic layout if not done correctly. Screen readers for the blind, also, must be accounted for. Tables, as far as I can tell, do NOT deter from their use. (maybe I am wrong, and if so, someone please show me.) The section508.gov website is all table based.
To make things more Accessible, I try to have cleaner markup code (more CSS), give resizable fonts, list “title” and “alt” properties in my tags, and provide skip navigation.


