[Tutor] returning to my memberlister script
Kirk Bailey
idiot1@netzero.net
Sat, 31 Aug 2002 23:17:22 -0400
OK, this is getting frustrating.
I am reading the actual source text for cgi.py, and sure enough, the
damn thing returns a dictionary. This script should be working, and it
howls like a wolf with a full moon. Which means I am doing something
wrong, but I am not catching it. Anyone want to look at this and adjust
my headspace and timing please? This apprentice requests correction.
Kirk Bailey wrote:
>
> Well, I have been busy, but finally got to return to my memberlister script.
>
> It gets this result in the www.errorlog:
> SyntaxError: invalid syntax
> [Thu Aug 29 00:26:38 2002] [error] [client 63.208.207.252] Premature end of script headers: /www/www.tinylist.org/cgi-bin/TLmemberlister.py
> Traceback (innermost last):
> File "/www/www.tinylist.org/cgi-bin/TLmemberlister.py", line 126, in ?
> print 'listname='+mylist+'<P>'
> TypeError: __add__ nor __radd__ defined for these operands
>
> Here is the script ( I will omit the text headers):
> login as: howlermo
> Sent username "howlermo"
> howlermo@howlermonkey.net's password:
> Last login: Wed Aug 28 00:04:44 2002 from dialup-65.59.82.
> Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
> The Regents of the University of California. All rights reserved.
>
> FreeBSD 3.4-RELEASE (HOWLER) #0: Thu Jun 21 22:13:44 EDT 2001
>
> Welcome to the Monkey!
> Please, enjoy your stay... now get to work!
>
> You have new mail.
> $ /www/www.howlermonkey.net
>
> print "Key 'owner' not found!" #120
> if not (form.has_key("password")):
> print "key 'password' not found!"
> if not (form.has_key("listname")):
> print "key 'listname' not found!"
> mylist = form["listname"] # listname,
> print 'listname='+mylist+'<P>'
> myowner = form["Owner"] # owner,
> print 'owner='+myowner+'<P>'
> mypassword = form["password"] # and password.
> print 'password='+mypassword+'<P>' #130
> f1=open('/lists/' + listname + '.owner','r') # read the (listname).owner fil$
> trueowner=string.srip(f1.readline()) # read the owner id
> trueword=string.strip(f1.readline()) # read THE PASSWORD
> f1.close() # Close the file.
> if myowner == trueowner : # if the owner matches up, test$
> if mypassword==trueword: # if the password also $
> f1=open('/lists/'+ mylist,'r') #proceed to access the member ro$
> members=f1.readlines() # read them in,
> [ Wrote 151 lines ]
>
> ns# list TLmemberlister.py
> Listing of file TLmemberlister.py in directory:/www/www.tinylist.org/cgi-bin
>
> #!/usr/local/bin/python
> #
> # This is TLmemberviewer V:1.3.0 COPYRIGHT 2002 by Kirk D Bailey
> #
> # It is part of the TinyList MLM suite, released under the GNU GPL.
> # which suite is also COPYRIGHT 2002 by Kirk D Bailey.
> # Please referr to enclosed GNU license in a seperate file.
> #
> # Being modular makes for MORE CHOICES AVAILABLE TO YOU!
> #10#############################################################################
> ###
> # Python can be studied and aquired at http://www.python.org/ !!!
> #########1#########2#########3#########4#########5#########6#########7#########8
> # that line is 80 char across, try to stay within it if you can.
> #
> # ADMIN AND LEGAL STUFF:
> # This program is free software; you can redistribute it and/or
> # modify it under the terms of the GNU General Public License
> # as published by the Free Software Foundation; either version 2
> # of the License, or (at your option) any later version.
> #20
> # This program is distributed in the hope that it will be useful,
> # but WITHOUT ANY WARRANTY; without even the implied warranty of
> # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> # GNU General Public License for more details.
> #
> # You should have received a copy of the GNU General Public License
> # along with this program; if not, write to the Free Software
> # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
> # You should have received a copy of the GNU General Public License
> #30 along with this program; if not, write to:
> #
> # Free Software Foundation, Inc.
> # 59 Temple Place - Suite 330
> # Boston, MA 02111-1307 USA.
> #
> # and request one; be cool and include a business sized SASE.
> #
> # Also, the GNU GPL may be viewed online at
> # http://www.gnu.org/licenses/gpl.html
> #40############################################################################
> #
> # "The tyrant's foe, the people's friend, a free press." -Dr Benjamin Franklin.
> #
> # Think about that last line- this software is your Ezine engine.
> ###############################################################################
> #
> # OWNERSHIP AND PERMISSION ISSUES
> # make sure this script runs as a TRUSTED USER-
> # and NOT as root!!! You set that up in the Sendmail Config file (sendmail.cf).
> #50 Make sure that a NON-priviliged user OWNS
> # this script, and that it runs as that identity!
> # Generally, this is accomplished by making sure it is owned by that user.
> # Permission on all scripts must be 755, files as 666, and listdir as 744.
> # The image files must NOT be placed in the cgi-bin, but in the web directory!
> ###############################################################################
> #
> # SPAM
> # Spam SUCKS. It also ROBS everyone it touches, each system it passes through.
> # Fight spam. DO NOT host open lists all the world may post to.
> #60 TinyList CANNOT do so as written, PLEASE do not defeat this.
> #
> ###############################################################################
> #
> #
> import os, sys, string, cgi # MUST be invoked!
> #
> # CONFIGURATION SECTION
> # =====================
> #number in the next line is a line number to help locate sections of code.
> #70
> # NOTE that this script is SUPPOSED to be installed in the web cgi-bin!
> # and the lists dir is immediately under this dir!
> #
> # ok, where am I? I just woke up!
> fullpathtoscript = os.path.split(os.path.abspath(sys.argv[0]))
> #
> # ok, now my config file is supposed to be RIGHT HERE with me!
> # So let's read the thing!
> f1=open("tinylist.cf",'r')
> #80
> # Tell me little file, who am I?
> webdomain=string.strip(f1.readline())
> f1.close()
> #
> # knowing where I am, I know that my lists are ONE FLOOR DOWN!
> path=fullpathtoscript[0]
> # ALL TinyList scripts MUST live in the web cgi-bin, and
> # ALL global and list files are directly off the web cgi-bin dir in '/lists'.
> # that dir should be owned by the same owner and group as this script, and
> #90 should be chmod 766. DIR 'list' must be 766, with all Scripts 755.
> #
> #
> #
> #
> #
> #
> #
> #
> # data arrives as 'QUERY_STRING'=(listname value) using
> #100 the GET method, but cgi module handles this nicely,
> # parsing it out into keywords and vlaues in a dictionary!
> #
> #
> #
> print "Content-type: text/html\n\n" # HTML is following
> print '<html><head>'
> print '<META HTTP-EQUIV="Pragma" CONTENT="no-cache">'
> print '<TITLE>TinyList membership listing Utility.</TITLE>'
> print '<STYLE TYPE="text/css">'
> #110
> print '<!-- A { text-decoration: none; } A:visited, A:hover, A:active text-de
> coration:none; } // -->'
> print '</STYLE>'
> print "</head>"
> print '<body bgcolor="FFFFFF" text="000000" ><blockquote>'
> print '<P><br><font color="FF0000"><font size="5"><font face="Century Gothic Li
> ght"> TinyList</font></font></font><p>'
> print '<hr width=50%><P>'
> #
> form=cgi.FieldStorage() # recover the form's data,
> if not (form.has_key("Owner")):
> print "Key 'owner' not found!" #120
> if not (form.has_key("password")):
> print "key 'password' not found!"
> if not (form.has_key("listname")):
> print "key 'listname' not found!"
> mylist = form["listname"] # listname,
> print 'listname='+mylist+'<P>' #
> myowner = form["Owner"] # owner,
> print 'owner='+myowner+'<P>' #
> mypassword = form["password"] # and password.
> print 'password='+mypassword+'<P>' #130
> f1=open('/lists/' + listname + '.owner','r') # read the (listname).owner file,
> trueowner=string.srip(f1.readline()) # read the owner id
> trueword=string.strip(f1.readline()) # read THE PASSWORD
> f1.close() # Close the file.
> if myowner == trueowner : # if the owner matches up, test the password;
> if mypassword==trueword: # if the password also matches,
> f1=open('/lists/'+ mylist,'r') #proceed to access the member roster.
> members=f1.readlines() # read them in,
> f1.close # and close the file.
> for i in members: #130
> print i + '<br>'
> else:
> print 'Sorry, wrong password.'
> else:
> print 'Sorry, wrong owner id.'
> #
> print '<P><hr width=50%></body></html>' # close the page, and end.
> #
> #
> #140
> #
>
> ns#
>
> Note I am using 1.5.2 python, and an upgrade is not practical at this time.
>
> I invite suggestions, advice, evil humor, and dead parrot sketch sequals.
>
> --
>
> end
>
> Respectfully,
> Kirk D Bailey
>
> +---------------------"Thou Art Free." -Eris-----------------------+
> | http://www.howlermonkey.net mailto:highprimate@howlermonkey.net |
> | KILL spam dead! http://www.scambusters.org/stopspam/#Pledge |
> | http://www.tinylist.org +--------+ mailto:grumpy@tinylist.org |
> +------------------Thinking| NORMAL |Thinking----------------------+
> +--------+
> -------------------------------------------
> Introducing NetZero Long Distance
> Unlimited Long Distance only $29.95/ month!
> Sign Up Today! www.netzerolongdistance.com
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
--
end
Respectfully,
Kirk D Bailey
+---------------------"Thou Art Free." -Eris-----------------------+
| http://www.howlermonkey.net mailto:highprimate@howlermonkey.net |
| KILL spam dead! http://www.scambusters.org/stopspam/#Pledge |
| http://www.tinylist.org +--------+ mailto:grumpy@tinylist.org |
+------------------Thinking| NORMAL |Thinking----------------------+
+--------+
-------------------------------------------
Introducing NetZero Long Distance
Unlimited Long Distance only $29.95/ month!
Sign Up Today! www.netzerolongdistance.com