[Tutor] ok, I want to read a dir.

Kirk Bailey deliberatus@my995internet.com
Thu, 27 Dec 2001 20:45:50 -0500

ok, this is improving, still WRONG, but much closer.

Here is the new version:

ns# list TLwebmgr.py
Listing of file TLwebmgr.py in

# You must define the next lien for the WEB path to your server's web
# ALL web scripts must live in the cgi-bin UNDER this dir!
# THAT IS WHERE TL LIVES! /lists lives UNDER that dir in the tree!
import string, sys, os, glob
print "<html><head>Content-Type: text/html"             # HTML is
print "Content-Type: text/html"                         # HTML is
print                                                   # blank line,
end of headers
print " <TITLE>TinyList WebManager menu page</TITLE>"   # tells the
browser the title
print " <STYLE TYPE=\"text/css\">"
print " <!--  A { text-decoration: none; }  A:visited, A:hover,
A:active  text-decoration:none; } // -->"
print " </STYLE>" 
print " </head>"                                                # this
is the end of the head
print " <body bgcolor=\"#FFFFFF\" text=\"#000000\" links=\"0000FF\"
print " <center><h1>TinyList membership management
print "Here are all the lists we host here:<P>"
print "<hr width=60% align=\"center\"><P>"
def descriptor(filename):                       # Read 1st line in file
        f1=open(filename,'r')                   #open the file named,
        info=string.strip(f1.readline())        # read the first line in
the file
        f1.close()                              # close the file
        return info                             # and exit returning the
1 line read

filelist = glob.glob('./lists/*.info')
for x in filelist:                              # filelist lists all the
available info files
        print "<a href= \"" + webpath + "cgi-bin/commander.py?list=" + x
+  "\">" + x + "</a> ", descriptor(x) +'<P>'
#which means:
#      print 'a
print "<hr width=60% align=\"center\"><P><br>"
print "Please click a name to read the entire description and to access
the form to subscribe or subscribe for that list.<P>
print "<P><br><small><A href=\"http://www.tinylist.org/ \">Powered by

and it is in the server. Click this link to see it's output:

and this one should let you view the current source code:

Now, the thing is working, but still supplies me with more than desired
in the text. I want to take this by the forlock and cut off the
extranious stuff, at least for display purposes.

I am taking the liberty of posting this also to tutor list.

"Michael P. Reilly" wrote:
> On Thu, Dec 27, 2001 at 07:29:39PM -0500, Kirk Bailey wrote:
> > it got me this:
> >
> > Traceback (innermost last):
> >   File "./TLwebmgr.py", line 31, in ?
> >     filelist = fnmatch.filter(os.listdir('./lists'), "*.info")
> > AttributeError: filter
> > ns#
> >
> > AttributeError:  filter??? Hmmm?
> The fnmatch.filter funciton was added only in Python 2.2.  The glob.glob1
> function I mentioned has been in Python since before 1.5.2.
>   -Arcege
> --
> +----------------------------------+-----------------------------------+
> | Michael P. Reilly                | arcege@speakeasy.net              |
> | Ailment info: http://www.speakeasy.org/~arcege/michaelwatch.html     |

             -Kirk D Bailey (C)2001
              Addme! icq #27840081

Within the sweep of his sword, Each man is an Ubar.