From redbird@rbisland.cx Tue Aug 1 02:28:41 2000 From: redbird@rbisland.cx (Gordon Worley) Date: Mon, 31 Jul 2000 21:28:41 -0400 Subject: [Pythonmac-SIG] dbm problems Message-ID: In my program, I'm importing shelve, which thereby imports anydbm. Everything works fine when my program is run from the IDE, but once built as a stand alone application, I get the following error upon trying to save a file: ImportError: no dbm clone found; tried ['dbhash', 'gdbm', 'dbm', 'dumbdbm'] Traceback (innermost last): File "Wapplication.py", line 34, in mainloop self.do1event(mask, wait) File "FrameWork.py", line 178, in do1event self.dispatch(event) File "FrameWork.py", line 207, in dispatch handler(event) File "FrameWork.py", line 265, in do_mouseDown handler(partcode, wid, event) File "Wapplication.py", line 178, in do_inMenuBar self.do_rawmenu(id, item, window, event) File "FrameWork.py", line 285, in do_rawmenu self.do_menu(id, item, window, event) File "FrameWork.py", line 290, in do_menu self.menubar.dispatch(id, item, window, event) File "Wapplication.py", line 410, in dispatch self.menus[id].dispatch(id, item, window, event) File "Wapplication.py", line 427, in dispatch W.CallbackCall(callback, 0, id, item, window, event) File "Wbase.py", line 684, in CallbackCall return callback() File "rb_todo_manager.py", line 124, in domenu_save self.domenu_save_as() File "rb_todo_manager.py", line 136, in domenu_save_as todo_file = shelve.open(self.file, "n") File "shelve.py", line 157, in open return DbfilenameShelf(filename, flag) File "shelve.py", line 146, in __init__ import anydbm File "anydbm.py", line 65, in ? raise ImportError, "no dbm clone found; tried %s" % _names So, basically, from what I can tell, it can't find dbm or a dbm clone. I tried importing dumbdbm (more on this in further down), but then saving files gave me back a "Mac OS Error: -43, "File not found"" (<-- that's not literal, it might be missing parens and the capitalization could be wrong). Also, the hash was divided into two files when saved (yes, the data writes but reports aforementioned error and the one currently being mentioned): [filename].dat with the pickled contents of my objects, and [filename].dir with the keys. Why is this happening (i.e. what does this problem appear in built applications but not in scripts run from the IDE) and what can I do to work around it? Now, you may be wondering why I'm importing dumbdbm. In fact, in its own code it notes many bugs (which I have run into) and admits to being slow. Well, it was the only dbm clone in the Lib folder. Actually, dbhash is there nominaly, but is just a wrapper for baddb, which is not present. Now, just to make things more complicated, the program complaines (but only when built as an application) that no module named gdbm can be found when trying to open files. Well, no kidding, gdbm is no where to be found, but why would anydbm want gdbm specifically when opening files? Just to finish up, I haven't tried building my program as an applet, but this isn't what I want to do anyway. -- Gordon Worley http://www.rbisland.cx/ mailto:redbird@rbisland.cx PGP: C462 FA84 B811 3501 9010 20D2 6EF3 77F7 BBD3 B003 From jack@oratrix.nl Tue Aug 1 09:03:42 2000 From: jack@oratrix.nl (Jack Jansen) Date: Tue, 01 Aug 2000 10:03:42 +0200 Subject: [Pythonmac-SIG] dbm problems In-Reply-To: Message by Gordon Worley , Mon, 31 Jul 2000 21:28:41 -0400 , Message-ID: <20000801080347.A45BAE266F@oratrix.oratrix.nl> Anydbm is one of the few modules that defeats the BuildApplication/freeze method of finding modules used. It's best to help it along a little, and as the only dbm-clone available on the mac is gdbm a bit of code like if 0: import gdbm somewhere in your code will do the trick. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From asymmetrik@yahoo.com Tue Aug 1 17:10:59 2000 From: asymmetrik@yahoo.com (erik ryerson) Date: Tue, 1 Aug 2000 09:10:59 -0700 (PDT) Subject: [Pythonmac-SIG] ip masq possible? Message-ID: <20000801161059.16234.qmail@web1702.mail.yahoo.com> howdy. i'm not sure if what i'm asking is doable or already done, but would it be possible to do ip masquerading/aliasing in python for macOS? I'm still too much of a novice and haven't put too much thought into it, but i think that if possible it'd be a fantastic thing...and free. if possible any starting advice would be greatly appreciated. thanks. asYmmetriK __________________________________________________ Do You Yahoo!? Kick off your party with Yahoo! Invites. http://invites.yahoo.com/ From JWight@bigfoot.com Tue Aug 1 17:31:21 2000 From: JWight@bigfoot.com (Jonathan Wight) Date: Tue, 01 Aug 2000 11:31:21 -0500 Subject: [Pythonmac-SIG] Building from CVS. Message-ID: Hello, Quick question - I'm trying to embed Mac Python into my application. I decided to rebuild Python by hand instead of just trying to use the PythonCore shared lib (maybe that was my first mistake). Building 1.5.2 was out of the question (mainly because it uses an older version of GUSI and I'm using the latest version in my app). Getting the 1.6 source code from CVS (btw had no problems with MacCVS Pro) got me only the Mac specific stuff. Downloading the 1.6a2 tarball from www.python.org and merging it with the Mac Python CVS code still meant I have to fix 30 or so bugs and produced a missing file - exceptions.c Where can I get the complete 1.6 source package? Thanks. Jon. From cbarker@jps.net Tue Aug 1 18:34:54 2000 From: cbarker@jps.net (Chris Barker) Date: Tue, 01 Aug 2000 10:34:54 -0700 Subject: [Pythonmac-SIG] Using Python .py scripts for CGI with personal web sharing References: Message-ID: <39870A3E.65C36579@jps.net> Sam, Thanks for your note on this. I'm trying to get it working, with no success. I've put the PythonCGISlave applet in by Web Pages:cgi-bin folder, and set a Personal Web Sharing Launch at suffix action to launch it, but it doesn't seem to get launched. I just get a "A CGI or internal server component could not complete the requested action." error from netscape. the url that shows up in netscape is the python script that I'm trying to run, and it does have a .py suffix. I have no idea how to debug this! any ideas? -Chris -- Christopher Barker, Ph.D. cbarker@jps.net --- --- --- http://www.jps.net/cbarker -----@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Water Resources Engineering ------ @ ------ @ ------ @ Coastal and Fluvial Hydrodynamics ------- --------- -------- ------------------------------------------------------------------------ ------------------------------------------------------------------------ From garabik@melkor.dnp.fmph.uniba.sk Tue Aug 1 18:32:04 2000 From: garabik@melkor.dnp.fmph.uniba.sk (Radovan Garabik) Date: Tue, 1 Aug 2000 19:32:04 +0200 Subject: [Pythonmac-SIG] Re: Any ftpd wrote in MacPython Message-ID: <20000801193204.A1099@melkor.dnp.fmph.uniba.sk> : Hi : I find som ftpd programming with Python : http://melkor.dnp.fmph.uniba.sk/~garabik/pyftpd.html : but I find it can not work under Mac Can you tell me what was the actual error? I would like to see pyftpd run on Macs, but I have no access to one. Does python on Mac support threading? : Any ftpd in MacPython? : Please help me thanks. -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/ | | __..--^^^--..__ garabik @ melkor.dnp.fmph.uniba.sk | ----------------------------------------------------------- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! From smith@oe.fau.edu Tue Aug 1 19:12:39 2000 From: smith@oe.fau.edu (Samuel Smith) Date: Tue, 1 Aug 2000 14:12:39 -0400 Subject: [Pythonmac-SIG] Using Python .py scripts for CGI with personal web sharing In-Reply-To: <39870A3E.65C36579@jps.net> References: <39870A3E.65C36579@jps.net> Message-ID: >Sam, > >Thanks for your note on this. > >I'm trying to get it working, with no success. I've put the >PythonCGISlave applet in by Web Pages:cgi-bin folder, and set a Personal >Web Sharing Launch at suffix action to launch it, but it doesn't seem to >get launched. I just get a "A CGI or internal server component could not >complete the requested action." error from netscape. the url that shows >up in netscape is the python script that I'm trying to run, and it does >have a .py suffix. > >I have no idea how to debug this! any ideas? > >-Chris > I have the PythonCGISlave applet in the Web Pages folder not in a subdirectory. Do you have both the applet and the .py URL with the complete path to Web Pages:cgi-bin. I saw the same error when my applet couldn't find the python core. Is the applet running after you invoke the CGI?. If not try running the applet by itself see if it loads without the python core not found error. This may be a stupid question but did you build the applet on your system from the PythonCGISlave.py > > > >-- >Christopher Barker, >Ph.D. >cbarker@jps.net --- --- --- >http://www.jps.net/cbarker -----@@ -----@@ -----@@ > ------@@@ ------@@@ ------@@@ >Water Resources Engineering ------ @ ------ @ ------ @ >Coastal and Fluvial Hydrodynamics ------- --------- -------- >------------------------------------------------------------------------ >------------------------------------------------------------------------ -- ********************************** Samuel M. Smith Ph.D. Professor Director Advanced Marine Systems Lab **************(Dania SeaTech Building)*********************** Institute for Ocean and Systems Engineering Florida Atlantic University Rm. 225 B, SeaTech Bldg. 101 North Beach Road, Dania, FL 33004 (voice) 954-924-7232 (secretary Paula) 954-924-7230 (fax) 954-924-7233 (mobile) 561-251-2114 (email) smith@oe.fau.edu (web) http://www.oe.fau.edu From redbird@rbisland.cx Wed Aug 2 01:10:07 2000 From: redbird@rbisland.cx (Gordon Worley) Date: Tue, 1 Aug 2000 20:10:07 -0400 Subject: [Pythonmac-SIG] dbm problems In-Reply-To: <20000801080347.A45BAE266F@oratrix.oratrix.nl> References: <20000801080347.A45BAE266F@oratrix.oratrix.nl> Message-ID: At 10:03 AM +0200 8/1/2000, Jack Jansen wrote: >Anydbm is one of the few modules that defeats the >BuildApplication/freeze method of finding modules used. It's best to >help it along a little, and as the only dbm-clone available on the mac >is gdbm a bit of code like >if 0: > import gdbm >somewhere in your code will do the trick. Okay, adding import gdbm makes it work. Yesterday I searched all around for dbm clones and all I came up with was dumbdbm. Guess next time I should just start typing away see what happens or remember to look in the Plugins folder. BTW, what is the if 0 part for? In fact, if 0 seems like it would always be false, so the import gdbm part would never be run. -- Gordon Worley http://www.rbisland.cx/ mailto:redbird@rbisland.cx PGP: C462 FA84 B811 3501 9010 20D2 6EF3 77F7 BBD3 B003 From jaredu@its.caltech.edu Wed Aug 2 03:27:48 2000 From: jaredu@its.caltech.edu (Jared Updike) Date: Tue, 1 Aug 2000 19:27:48 -0700 (PDT) Subject: [Pythonmac-SIG] Linking Python Core into an XOP code resource Message-ID: My situation is this: I have the Code Warrior C project embeddemo working, and I changed the code to perform a specific task (send a text string to a TCP socket). This works fine (by itself). I have an Igor (Igor is a lab data-retrieval/ storage/grahing/etc. program) XOP function that I stole from the sample demo, which takes string data input and concatenates two strings (nothing too fancy). Igor XOPs are code resources that dwell in a specific directory that Igor peruses when it initializes, loading any XOPs that are present. This works fine (by itself). The goal is to make a Codewarrior project that acts as XOP code resource that takes string input from Igor and sends it to Python to send over TCP socket. This willl enable the lab experiment running in Igor to communicate with the SGI that is running the stimulus, and solve timing problems, etc. The problem that arises is that when Igor loads, if I have linked the Python Core into the Codewarrior project/XOP then the Igor application will fail to load, without any dialog boxes or error messages. Could this be a problm with the linking of my Codewarrior project, the fact that it is a code resource and not something else, or is it an Igor problem (I doubt that this specific of an issue has an obvious Python-related solution, therefore I have sent a similar message to Igor Development Support as well...) Any input would be appreciated. --Jared Web: http://waffles.caltech.edu Phone: (626)395-1154 Campus Adress: Blacker Hovse, Room 31 Adress: MSC 935 Caltech Pasadena, CA 91126-0935 From cwebster@nevada.edu Wed Aug 2 07:43:23 2000 From: cwebster@nevada.edu (Corran Webster) Date: Tue, 1 Aug 2000 23:43:23 -0700 Subject: [Pythonmac-SIG] os.path.normpath() Message-ID: --============_-1246923890==_============ Content-Type: text/plain; charset="us-ascii" Hi, there is currently discussion on the distutils list because of some problems with the current implementation of os.path.normpath() on the macintosh. The problem arises because os.path.normpath("Macintosh HD:Applications:") == "Macintosh HD:Applications:" and os.path.normpath("Macintosh HD:Applications") == "Macintosh HD:Applications" despite the fact that the paths are equivalent. distutils needs a platform independent way to check for two paths being equivalent, and this is failing because of examples like the above. I've written a replacement (see attachment) which should guarantee that two equivalent paths get normalised to the same thing, but I'd like to just check with folks here that I'm not missing anything. If all looks good, I'll submit a patch for macpath.py to use this new normpath. Regarsd, Corran --============_-1246923890==_============ Content-Type: text/plain; name="normpath.py"; charset="us-ascii" Content-Disposition: attachment; filename="normpath.py" import string def normpath(s): """Normalize a pathname. Will return the same result for equivalent paths.""" if ":" not in s: return ":"+s comps = string.splitfields(s, ":") i = 1 while i < len(comps)-1: if comps[i] == "" and comps[i-1] != "": if i > 1: del comps[i-1:i+1] i = i-1 else: # best way to handle this is to raise an exception raise norm_error, 'path starts with volume::' else: i = i + 1 print i, comps s = string.join(comps, ":") # remove trailing ":" except for ":" and "Volume:" if s[-1] == ":" and len(comps) > 2 and s != ":"*len(s): s = s[:-1] return s def _test_normpath(): pass if __name__ == "__main__": _test_normpath() --============_-1246923890==_============ Content-Type: text/plain; name="test_normpath.py"; charset="us-ascii" Content-Disposition: attachment; filename="test_normpath.py" from test_support import * import normpath errors = 0 def testit(name, value, expected): if value != expected: raise TestFailed, '%s returned %f, expected %f'%\ (name, value, expected) testit("normpath", normpath.normpath(":"), ":") testit("normpath", normpath.normpath("::"), "::") testit("normpath", normpath.normpath(":::"), ":::") testit("normpath", normpath.normpath("test"), ":test") testit("normpath", normpath.normpath(":test"), ":test") testit("normpath", normpath.normpath("test:"), "test:") testit("normpath", normpath.normpath(":test:test1:"), ":test:test1") testit("normpath", normpath.normpath("test:test1:"), "test:test1") testit("normpath", normpath.normpath(":test::"), ":") testit("normpath", normpath.normpath(":test:::"), "::") testit("normpath", normpath.normpath(":test:::test1:"), "::test1") testit("normpath", normpath.normpath(":test:test1::"), ":test") testit("normpath", normpath.normpath("test:test1::"), "test:") testit("normpath", normpath.normpath(":test:test1:::"), ":") if errors: print str(errors) + " errors." else: print "No errors. Thank your lucky stars." --============_-1246923890==_============-- From tmk@easynet.be Wed Aug 2 08:09:40 2000 From: tmk@easynet.be (tmk) Date: Wed, 02 Aug 2000 09:09:40 +0200 Subject: [Pythonmac-SIG] Using Python .py scripts for CGI with personal web sharing In-Reply-To: <39870A3E.65C36579@jps.net> Message-ID: > From: Chris Barker > Date: Tue, 01 Aug 2000 10:34:54 -0700 > To: Samuel Smith > Cc: pythonmac-sig@python.org > Subject: Re: [Pythonmac-SIG] Using Python .py scripts for CGI with personal > web sharing > > Sam, > > Thanks for your note on this. > > I'm trying to get it working, with no success. I've put the > PythonCGISlave applet in by Web Pages:cgi-bin folder, and set a Personal > Web Sharing Launch at suffix action to launch it, but it doesn't seem to > get launched. I just get a "A CGI or internal server component could not > complete the requested action." error from netscape. the url that shows > up in netscape is the python script that I'm trying to run, and it does > have a .py suffix. > > I have no idea how to debug this! any ideas? It could be that the applet could run because of an error. You may want to try the following: 1. Try launching the PythonCGISlave applet 'by hand' and see if it posts a "Can't find PythonCore" (or something like that) error dialog. 2. If so try to run the ConfigurePython applet. 3. Back to point 1. above. There seem to be an issue with applets not being able to find PythonCore after a reboot. Running ConfigurePython seems to cure that problem. I've put an alias to ConfigurePython in my Startup Items folder to take care of this problem. Hope this helps. = tmk = > > -Chris > > > > > > -- > Christopher Barker, > Ph.D. > cbarker@jps.net --- --- --- > http://www.jps.net/cbarker -----@@ -----@@ -----@@ > ------@@@ ------@@@ ------@@@ > Water Resources Engineering ------ @ ------ @ ------ @ > Coastal and Fluvial Hydrodynamics ------- --------- -------- > ------------------------------------------------------------------------ > ------------------------------------------------------------------------ > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG@python.org > http://www.python.org/mailman/listinfo/pythonmac-sig > From jack@oratrix.nl Wed Aug 2 08:57:37 2000 From: jack@oratrix.nl (Jack Jansen) Date: Wed, 02 Aug 2000 09:57:37 +0200 Subject: [Pythonmac-SIG] dbm problems In-Reply-To: Message by Gordon Worley , Tue, 1 Aug 2000 20:10:07 -0400 , Message-ID: <20000802075738.672EC303181@snelboot.oratrix.nl> > At 10:03 AM +0200 8/1/2000, Jack Jansen wrote: > >Anydbm is one of the few modules that defeats the > >BuildApplication/freeze method of finding modules used. It's best to > >help it along a little, and as the only dbm-clone available on the mac > >is gdbm a bit of code like > >if 0: > > import gdbm > >somewhere in your code will do the trick. > [...] > BTW, what is the if 0 part for? In fact, if 0 seems like it would > always be false, so the import gdbm part would never be run. That's right: anydbm will import it. The only reason it is there is to fool BuildApplication. The way BuildApplication finds all the modules used is basically by searching for "import xxxx" and "from xxxx import ..." statements. So by putting in such a statement, even if it's inside an if 0, BuildApplication will find the module. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From jack@oratrix.nl Wed Aug 2 09:12:49 2000 From: jack@oratrix.nl (Jack Jansen) Date: Wed, 02 Aug 2000 10:12:49 +0200 Subject: [Pythonmac-SIG] Building from CVS. In-Reply-To: Message by Jonathan Wight , Tue, 01 Aug 2000 11:31:21 -0500 , Message-ID: <20000802081249.30453303181@snelboot.oratrix.nl> > Where can I get the complete 1.6 source package? If you're using the MacPython sources from CVS you also have to use the main Python sources from CVS. You can get them through python.sourceforge.net. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From jack@oratrix.nl Wed Aug 2 09:16:31 2000 From: jack@oratrix.nl (Jack Jansen) Date: Wed, 02 Aug 2000 10:16:31 +0200 Subject: [Pythonmac-SIG] ip masq possible? In-Reply-To: Message by erik ryerson , Tue, 1 Aug 2000 09:10:59 -0700 (PDT) , <20000801161059.16234.qmail@web1702.mail.yahoo.com> Message-ID: <20000802081631.B7213303181@snelboot.oratrix.nl> > howdy. > i'm not sure if what i'm asking is doable or already done, but would it be > possible to do ip masquerading/aliasing in python for macOS? I'm still too much > of a novice and haven't put too much thought into it, but i think that if > possible it'd be a fantastic thing...and free. I think it's difficult in Python. Actually, it's difficult in any "user space" process, because you'll have to open a raw IP socket and do all filtering yourself. And you'll get all the IP packets that pass through your machine. And this is the sort of stuff that Python isn't at its best at, because speed is of the essence: you want to packet to go out again with the new IP address/port as soon as possible, and with consuming as little resources as possible. That is really the type of code you want to write as some sort of a device driver or so in C or C++. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From just@letterror.com Wed Aug 2 09:13:34 2000 From: just@letterror.com (Just van Rossum) Date: Wed, 2 Aug 2000 09:13:34 +0100 Subject: [Pythonmac-SIG] dbm problems In-Reply-To: References: <20000801080347.A45BAE266F@oratrix.oratrix.nl> <20000801080347.A45BAE266F@oratrix.oratrix.nl> Message-ID: At 8:10 PM -0400 01-08-2000, Gordon Worley wrote: >BTW, what is the if 0 part for? In fact, if 0 seems like it would >always be false, so the import gdbm part would never be run. It's only a hint for the modulefinder used by BuildApplication (& MacFreeze). It makes sure gdbm gets included (it doesn't do any flow analusis, it simply scans for import statements. Just From tom@othermedia.com Sat Aug 12 14:19:05 2000 From: tom@othermedia.com (tom smith) Date: Sat, 12 Aug 2000 14:19:05 +0100 Subject: [Pythonmac-SIG] Python probs all over the place In-Reply-To: Message-ID: Hi, on my G4 I can only get an applet to run as a cgi if I give it 10MB memory on my G3 powerbook I get the error (Your python prefs are corrupt or missing). I have deleted them and ran the Configure python tool. I have tried moving Python to the same partition as the cgi applet (you never know with bugs :-) If I run the "editPythonPrefs" tool, it kinda freezes with the dialog in the background somewhere and not active. (I suspect navigation services, does this really need to be a dialog window?) I'm using "Python 1.6a2" on System 9.0.4 and nothing about Python seems to work. please help tom From jack@oratrix.nl Wed Aug 2 15:49:46 2000 From: jack@oratrix.nl (Jack Jansen) Date: Wed, 02 Aug 2000 16:49:46 +0200 Subject: [Pythonmac-SIG] Python probs all over the place In-Reply-To: Message by tom smith , Sat, 12 Aug 2000 14:19:05 +0100 , Message-ID: <20000802144947.F359F303181@snelboot.oratrix.nl> > on my G4 I can only get an applet to run as a cgi if I give it 10MB memory That could be about right, I'm afraid. The framework pulls in quite a bit of stuff. Note that running as a single CGI isn't the optimal way to do this anyway, acgi is the way to go (and then you're sharing the 10MB among all your CGIs) > on my G3 powerbook I get the error (Your python prefs are corrupt or > missing). I have deleted them and ran the Configure python tool. This is a known bug: open the cgi applet in ResEdit or Resourcerer and remove the 'alis' resource. > If I run the "editPythonPrefs" tool, it kinda freezes with the dialog in the > background somewhere and not active. (I suspect navigation services, does > this really need to be a dialog window?) Your symptoms are different from normal, but there is a known bug in 1.6a2 EditPythonPrefs: EditPythonPrefs.py and py_preferences.py disagree about the name of the "navservice" pref. I don't have the source handy, but in one place its called nonavservice and in the other nonavservices, I think. Fix py_preferences.py and EditPythonPrefs should work again. > I'm using "Python 1.6a2" on System 9.0.4 and nothing about Python seems to > work. That's what happens with alfa releases, I'm afraid. The bad news is that in your case going back to the stable 1.5.2 is probably not an option, because the CGI stuff in its current form is fairly new. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From michael.geary@seranova.com Wed Aug 2 19:02:46 2000 From: michael.geary@seranova.com (Michael Geary) Date: Wed, 2 Aug 2000 12:02:46 -0600 Subject: [Pythonmac-SIG] simple cgi help? Message-ID: Hi folks, I'm a new subscriber. I've been playing with Python (on a mac) for about a month now. I'm comfortable with it, but not expert. A recent thread suggests that some of you have set up Python with personal Web Sharing on their macs. I am trying to do the same. I have downloaded and (i think) installed the PythonCGIslave applet, but I am looking for information about actually coding a CGI script. I thought that simply having a script: print "hello world" in a script titled "helloworld.py" would output that text to the browser, but I get error messages in my PythonCGIslave app, and it terminates (but doesn't quit). Can anyone offer help and/or a super simple cgi script I can build from? thanks, michael geary From cbarker@jps.net Wed Aug 2 21:14:58 2000 From: cbarker@jps.net (Chris Barker) Date: Wed, 02 Aug 2000 13:14:58 -0700 Subject: [Pythonmac-SIG] Using Python .py scripts for CGI withpersonal web sharing References: <39870A3E.65C36579@jps.net> Message-ID: <39888142.7DD20DF0@jps.net> Samuel Smith wrote: > I have the PythonCGISlave applet in the Web Pages folder not in a > subdirectory. Do you have both the applet and the .py URL with the > complete path to Web Pages:cgi-bin. Yes, I did, but I moved them both to the "Web Pages" folder, just to make it easier. > I saw the same error when my applet couldn't find the python core. Is > the applet running after you invoke the CGI?. If not try running the > applet by itself see if it loads without the python core not found > error. As it happens, I had already tried this, and yes, it will start and run if I double click on it. Now that I have moved it to the "Web Pages" folder, it does start when I request a *.py URL, but my script doesn't run. There are no messages put into the error log either. > This may be a stupid question but did you build the applet on your > system from the PythonCGISlave.py Yes I did. I tried adding some diagnostic messages to PythonCGISlave (sys.stderr.write() ), but then it just started crashing. I'm kind of stumped here. Anyone have an idea? Michael Geary wrote: >I thought that simply having a script: >print "hello world" Well, that should in fact work (it certainly does on my Linux Box with Apache). Can anyone confirm this for PythonCGISlave? you might want to add a line like: print "Content-type: text/html\n\n" To let the browser know that it's html, but it should work anyway. >in a script titled "helloworld.py" would output that text to the >browser, but I get error messages in my PythonCGIslave app, and it >terminates (but doesn't quit). It probably doesn't quit because you have "keep stdio window open on error exit" check in EditPython Prefs. Anyway you are having a problem that isn't because you have a bad cgi script. there is something else going on, as there is with me. Can anyone help us figure out what? Thanks, -Chris cbarker@jps.net --- --- --- http://www.jps.net/cbarker -----@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Water Resources Engineering ------ @ ------ @ ------ @ Coastal and Fluvial Hydrodynamics ------- --------- -------- ------------------------------------------------------------------------ ------------------------------------------------------------------------ From cbarker@jps.net Wed Aug 2 21:19:28 2000 From: cbarker@jps.net (Chris Barker) Date: Wed, 02 Aug 2000 13:19:28 -0700 Subject: [Pythonmac-SIG] another PythonCGISlave note. References: Message-ID: <39888250.77132CF6@jps.net> To add to my last note: PythonCGISlave is started and keeps running, but it does have a "double menu", that is two apple and file menus. Does this give a hint as to what is wrong? a bug in MiniApplication perhaps? Probably not the source of my problems, but what the heck. -Chris -- Christopher Barker, Ph.D. cbarker@jps.net --- --- --- http://www.jps.net/cbarker -----@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Water Resources Engineering ------ @ ------ @ ------ @ Coastal and Fluvial Hydrodynamics ------- --------- -------- ------------------------------------------------------------------------ ------------------------------------------------------------------------ From just@letterror.com Wed Aug 2 22:22:52 2000 From: just@letterror.com (Just van Rossum) Date: Wed, 2 Aug 2000 22:22:52 +0100 Subject: [Pythonmac-SIG] another PythonCGISlave note. In-Reply-To: <39888250.77132CF6@jps.net> References: Message-ID: At 1:19 PM -0700 02-08-2000, Chris Barker wrote: >To add to my last note: > >PythonCGISlave is started and keeps running, but it does have a "double >menu", that is two apple and file menus. Does this give a hint as to >what is wrong? a bug in MiniApplication perhaps? Probably not the source >of my problems, but what the heck. Hm, this indicates that "delay console until needed" is set, but *something* is writing to sys.stdout anyway (stderr is redirected to a log file). GUSI weirdness? Just From cbarker@jps.net Wed Aug 2 22:48:12 2000 From: cbarker@jps.net (Chris Barker) Date: Wed, 02 Aug 2000 14:48:12 -0700 Subject: [Pythonmac-SIG] More PythonCGISlave notes. References: Message-ID: <3988971C.D2A565FF@jps.net> Just van Rossum wrote: > >PythonCGISlave is started and keeps running, but it does have a "double > >menu", that is two apple and file menus. Does this give a hint as to > >what is wrong? a bug in MiniApplication perhaps? Probably not the source > >of my problems, but what the heck. > > Hm, this indicates that "delay console until needed" is set, but > *something* is writing to sys.stdout anyway (stderr is redirected to a log > file). GUSI weirdness? Well, perhaps it's line 69: print "%s version %s ready." % (self.__class__.__name__, __version__) Without it it doesn't bring up the window. Will this cause any problems? As it happens, I've used sys.stdout to write data for diagnosing problems. Should I re-direct it? I've also found why it's not working for me. It crashes on line 79: root = args['DIRE'].as_pathname() args does not get a 'DIRE' key. It looks like this is supposed to get passed in from the Web server by the AppleEvent, but apparently it's not. I know NOTHING about AppleEvents, so I am completely lost now. I'm using Personal Web Sharing in MAC OS 8.6. MacPython 1.5.2c Does anyone have it working with these versions? -Thanks, Chris -- Christopher Barker, Ph.D. cbarker@jps.net --- --- --- http://www.jps.net/cbarker -----@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Water Resources Engineering ------ @ ------ @ ------ @ Coastal and Fluvial Hydrodynamics ------- --------- -------- ------------------------------------------------------------------------ ------------------------------------------------------------------------ From just@letterror.com Wed Aug 2 23:58:05 2000 From: just@letterror.com (Just van Rossum) Date: Wed, 2 Aug 2000 23:58:05 +0100 Subject: [Pythonmac-SIG] More PythonCGISlave notes. In-Reply-To: <3988971C.D2A565FF@jps.net> References: Message-ID: At 2:48 PM -0700 02-08-2000, Chris Barker wrote: >Well, perhaps it's line 69: > >print "%s version %s ready." % (self.__class__.__name__, __version__) > >Without it it doesn't bring up the window. Will this cause any problems? >As it happens, I've used sys.stdout to write data for diagnosing >problems. Should I re-direct it? Oops, sorry, I misinformed you. It is the reverse: for PythonCGISlave, "delay console until needed" should be *off*. This way, the SIOUX window + menus get installed before the applets own menus override them. >I've also found why it's not working for me. It crashes on line 79: > >root = args['DIRE'].as_pathname() > >args does not get a 'DIRE' key. It looks like this is supposed to get >passed in from the Web server by the AppleEvent, but apparently it's >not. I know NOTHING about AppleEvents, so I am completely lost now. I'm >using Personal Web Sharing in MAC OS 8.6. MacPython 1.5.2c Does anyone >have it working with these versions? Ah, this may be a WebStar-specific key. The thing to do is hardwire the script path in PythonCGISlave.py, possibly as a relative path from the applet (by looking at os.getcwd() at startup). Just From jack@oratrix.nl Wed Aug 2 23:23:28 2000 From: jack@oratrix.nl (Jack Jansen) Date: Thu, 03 Aug 2000 00:23:28 +0200 Subject: [Pythonmac-SIG] MacPython, CGI and free cd's Message-ID: <20000802222333.6FC84E2670@oratrix.oratrix.nl> Okay, folks, I have an idea about how I would like MacPython CGI stuff to work, but absolutely no time to implement it. Whoever implements it (or something similar, and probably better:-) gets (a) their name mentioned first in the contributors list for the next macPython release and (b) an autographed copy of the next Uit de Sloot CD (released in a month or so). CGI is hot, and MacPython could do a great job here. To make CGI scripting as easy as possible I'd like the scripts to be compatible with unix/window scripts, live in a standard place and be almost trivial to hook into your webserver. I think the following architecture will do this. There's a folder CGIScripts that lives in the toplevel Python folder. CGI authors should drop their scripts in there (with or without the .py name, I don't care). The scripts are identical to unix/windows scripts, i.e. they grab their arguments from sys.environ and send their results to sys.stdout with print commands. There's applets CGIPython.cgi and CGIPython.acgi. If a user creates a CGI script "foobar" in the CGIScripts folder s/he is instructed to copy CGIPython.cgi to their webserver standard CGI place *under the name foobar.cgi* (or similarly for acgi). What CGIPython does is obtain the name under which they've been called (from sys.argv[0] or the applevent verb name or so, I'm not sure), construct a sys.environ from the AppleScript args it got, create a file-like object with StringIO and stuff it in sys.stdout, go to theCGIScripts folder with chdir() and execute the correct script there with this environment. Whatever is in the stringio object after the script has finished is stuffed in the AppleEvent reply and sent back to the webserver. If something is amiss the end-user is given a polite note of this with some references to the documentation (on a webserver, I can fill in the eventual name to use here, or with a file: url so the reference will only work for the author). Putting the stacktrace, if there is one, in an html-comment is probably also a good idea: zope does that too, making it easier to debug without baffling non-pythoneers). Replies >=32k would be nice, but not vital for a first cut. So would an extra applet TestCGIPython where the user can simulate the script execution (or possibly this could be CGIPython itself if it notices it isn't executed as a cgiscript but double clicked). Other niceties like push and such (or is that the same mechanism as big replies? I forget) ditto. Any takers? -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | ++++ see http://www.xs4all.nl/~tank/ ++++ From just@letterror.com Thu Aug 3 08:50:12 2000 From: just@letterror.com (Just van Rossum) Date: Thu, 3 Aug 2000 08:50:12 +0100 Subject: [Pythonmac-SIG] MacPython, CGI and free cd's In-Reply-To: <20000802222333.6FC84E2670@oratrix.oratrix.nl> Message-ID: A few remarks: - I don't have the time to persue this either... - With PythonCGISlave, scripts are already largely compatible with unix: I think I've done a fair job ov converting most AE arguments to their os.environ counterparts. (As an example, using the cgi.py module as a test script works out of the box.) - I think to use a script server (as in PythonCGISlave) that executes any *.py file is superior to having to copy/rename a "wrapper" applet. The only disadvantages I can think of are a) that it's harder to configure your webserver to act that way, b) it might not work with *all* webservers. Good documentation might help here... - It appears most of the current PythonCGISlave problems have to do with - MacPython 1.6a wrinkles - poor documentation - a WebStar dependency (the 'DIRE' argument) Other than that, I think it works quite nicely... Just At 12:23 AM +0200 03-08-2000, Jack Jansen wrote: >Okay, folks, I have an idea about how I would like MacPython CGI stuff >to work, but absolutely no time to implement it. Whoever implements it >(or something similar, and probably better:-) gets (a) their name >mentioned first in the contributors list for the next macPython >release and (b) an autographed copy of the next Uit de Sloot CD >(released in a month or so). CGI is hot, and MacPython could do a >great job here. > >To make CGI scripting as easy as possible I'd like the scripts to be >compatible with unix/window scripts, live in a standard place and be >almost trivial to hook into your webserver. I think the following >architecture will do this. > >There's a folder CGIScripts that lives in the toplevel Python >folder. CGI authors should drop their scripts in there (with or >without the .py name, I don't care). The scripts are identical to >unix/windows scripts, i.e. they grab their arguments from sys.environ >and send their results to sys.stdout with print commands. > >There's applets CGIPython.cgi and CGIPython.acgi. If a user creates a CGI >script "foobar" in the CGIScripts folder s/he is instructed to copy >CGIPython.cgi to their webserver standard CGI place *under the name >foobar.cgi* (or similarly for acgi). > >What CGIPython does is obtain the name under which they've been called >(from sys.argv[0] or the applevent verb name or so, I'm not sure), >construct a sys.environ from the AppleScript args it got, create a >file-like object with StringIO and stuff it in sys.stdout, go to >theCGIScripts folder with chdir() and execute the correct script there with >this environment. Whatever is in the stringio object after the script >has finished is stuffed in the AppleEvent reply and sent back to the >webserver. If something is amiss the end-user is given a polite note >of this with some references to the documentation (on a webserver, I >can fill in the eventual name to use here, or with a file: url so the >reference will only work for the author). Putting the stacktrace, if >there is one, in an html-comment is probably also a good idea: zope >does that too, making it easier to debug without baffling >non-pythoneers). > >Replies >=32k would be nice, but not vital for a first cut. So would >an extra applet TestCGIPython where the user can simulate the script >execution (or possibly this could be CGIPython itself if it notices it >isn't executed as a cgiscript but double clicked). Other niceties like >push and such (or is that the same mechanism as big replies? I forget) >ditto. > >Any takers? From jack@oratrix.nl Thu Aug 3 10:05:12 2000 From: jack@oratrix.nl (Jack Jansen) Date: Thu, 03 Aug 2000 11:05:12 +0200 Subject: [Pythonmac-SIG] MacPython, CGI and free cd's In-Reply-To: Message by Just van Rossum , Thu, 3 Aug 2000 08:50:12 +0100 , Message-ID: <20000803090512.8C136303181@snelboot.oratrix.nl> > - With PythonCGISlave, scripts are already largely compatible with unix: I > think I've done a fair job ov converting most AE arguments to their > os.environ counterparts. (As an example, using the cgi.py module as a test > script works out of the box.) But you don't do stdout-to-appleevent reply mapping yet, or do you? > - I think to use a script server (as in PythonCGISlave) that executes any > *.py file is superior to having to copy/rename a "wrapper" applet. The only > disadvantages I can think of are a) that it's harder to configure your > webserver to act that way, b) it might not work with *all* webservers. Good > documentation might help here... At the moment I'm not really interested in what is superior, I want something that works, and that can be explained in 3 sentences (at least to someone familiar with CGI in general). Once people start using this stuff they'll find out for themselves (I hope) that there's all sorts of things they can do to make it perform better. And a script server may be a good idea if your machine is a dedicated webserver, but if you're using your mac to debug cgi-scripts for unix you really want it to restart the scripts each time, and you don't really care about performance. And I think that things like good error messages, decent testing facilities and reasonable documentation (at least the getting started stuff) is really important too. These are the type of things that help you along the first bits of your learning curve, and they should be geared towards helping new users (new either to Python, Macintosh and/or CGI). -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From just@letterror.com Thu Aug 3 11:49:37 2000 From: just@letterror.com (Just van Rossum) Date: Thu, 3 Aug 2000 11:49:37 +0100 Subject: [Pythonmac-SIG] MacPython, CGI and free cd's In-Reply-To: <20000803090512.8C136303181@snelboot.oratrix.nl> References: Message by Just van Rossum , Thu, 3 Aug 2000 08:50:12 +0100 , Message-ID: At 11:05 AM +0200 03-08-2000, Jack Jansen wrote: >But you don't do stdout-to-appleevent reply mapping yet, or do you? Of course I do: it wouldn't be compatible otherwise... Really, unix CGI scripts do work as-is under a Mac web server, as long as they don't do unixy things like forking, executing shell commands or opening pipes. >At the moment I'm not really interested in what is superior, I want something >that works, and that can be explained in 3 sentences (at least to someone >familiar with CGI in general). Apart from the server configuration (which I think is not harder than setting up a Python CGI script under Unix), it is dead simple. But you're right, something that works right away is better. >Once people start using this stuff they'll find >out for themselves (I hope) that there's all sorts of things they can do to >make it perform better. And a script server may be a good idea if your >machine >is a dedicated webserver, but if you're using your mac to debug cgi-scripts >for unix you really want it to restart the scripts each time, and you don't >really care about performance. Good points. >And I think that things like good error messages, decent testing facilities >and reasonable documentation (at least the getting started stuff) is really >important too. These are the type of things that help you along the first >bits >of your learning curve, and they should be geared towards helping new users >(new either to Python, Macintosh and/or CGI). Web servers generally don't offer any help in debugging CGI scripts, they just barf "Internal server error" at you when something goes wrong. That's virtually the same on any platform. Catching exceptions and sending it to the browser is in my optinion the job of the CGI script itself, and not correct behavior for any web server or Python wrapper. And it's easy enough to do: import cgi, traceback print "Content-type: text/html" print try: domycgistuff() except: cgi.print_exception() I don't know, it just seems inappropriate to make CGI look any nicer than it really is. Errors unrelated to the actual CGI script should of course be reported in a decent fashion, which is not generally the case with PytonCGISlave. Just From jack@oratrix.nl Thu Aug 3 11:30:30 2000 From: jack@oratrix.nl (Jack Jansen) Date: Thu, 03 Aug 2000 12:30:30 +0200 Subject: [Pythonmac-SIG] MacPython, CGI and free cd's In-Reply-To: Message by Just van Rossum , Thu, 3 Aug 2000 11:49:37 +0100 , Message-ID: <20000803103031.334E8303181@snelboot.oratrix.nl> > At 11:05 AM +0200 03-08-2000, Jack Jansen wrote: > >But you don't do stdout-to-appleevent reply mapping yet, or do you? > > Of course I do: it wouldn't be compatible otherwise... Really, unix CGI > scripts do work as-is under a Mac web server, as long as they don't do > unixy things like forking, executing shell commands or opening pipes. Ah, wow! It's a lot more complete than I had expected, then! > Apart from the server configuration (which I think is not harder than > setting up a Python CGI script under Unix), it is dead simple. But you're > right, something that works right away is better. Will something simple like dropping the applet in the server's CGI directory work? If we can explain this is a few simple sentences for Personal Websharing I think we're all set. Personal Websharing is what everyone will start with nowadays, as it's included in MacOS, so I guess we can safely assume that anyone who has a more powerful server will also have the knowledge about where to put CGI stuff for their brand of server. > Web servers generally don't offer any help in debugging CGI scripts, they > just barf "Internal server error" at you when something goes wrong. That's > virtually the same on any platform. Catching exceptions and sending it to > the browser is in my optinion the job of the CGI script itself, and not > correct behavior for any web server or Python wrapper. And it's easy enough > to do: > > import cgi, traceback > > print "Content-type: text/html" > print > > try: > domycgistuff() > except: > cgi.print_exception() But why wouldn't we do something nicer for Python users? Putting the try/except in the wrapper, for instance (the user can always override it with another try/exceept in their script). Also, on unix you can test your CGI script with something like % QUERY_STRING=arg+arg+arg cgi-bin/myscript but on the mac this isn't possible, but we could easily provide some help. Hmm, maybe this should be folded into the IDE? If you could "Run as CGI" from the IDE and then "Save as CGI" (which would save in the right place, copy the applet, etc) we would be giving people a pretty decent CGI development environment... -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From redbird@rbisland.cx Wed Aug 2 17:20:55 2000 From: redbird@rbisland.cx (Gordon Worley) Date: Wed, 02 Aug 2000 12:20:55 -0400 Subject: [Pythonmac-SIG] dbm problems In-Reply-To: <20000802075738.672EC303181@snelboot.oratrix.nl> References: <20000802075738.672EC303181@snelboot.oratrix.nl> Message-ID: At 9:57 AM +0200 8/2/2000, Jack Jansen wrote: >That's right: anydbm will import it. The only reason it is there is to fool >BuildApplication. The way BuildApplication finds all the modules used is >basically by searching for "import xxxx" and "from xxxx import ..." >statements. So by putting in such a statement, even if it's inside an if 0, >BuildApplication will find the module. Well, I tried it and it didn't work. I got the same error as before (couldn't find a dbm clone). Is there any particular reason why just typing import gdbm would be bad? -- Gordon Worley http://www.rbisland.cx/ mailto:redbird@rbisland.cx PGP: C462 FA84 B811 3501 9010 20D2 6EF3 77F7 BBD3 B003 From jack@oratrix.nl Thu Aug 3 14:09:35 2000 From: jack@oratrix.nl (Jack Jansen) Date: Thu, 03 Aug 2000 15:09:35 +0200 Subject: [Pythonmac-SIG] dbm problems In-Reply-To: Message by Gordon Worley , Wed, 02 Aug 2000 12:20:55 -0400 , Message-ID: <20000803130936.6C91E303181@snelboot.oratrix.nl> > Well, I tried it and it didn't work. I got the same error as before > (couldn't find a dbm clone). Strange... > Is there any particular reason why just > typing import gdbm would be bad? No, not at all. But then why not simply replace them "import anydbm" with "import gdbm"? Anydbm is a bit of a hack anyway, as it can fail in mysterious ways if more than one of dbm/gdbm/db are installed (it can load the wrong module for an existing database if you're not very strict about your file extensions). -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From redbird@rbisland.cx Thu Aug 3 14:15:17 2000 From: redbird@rbisland.cx (Gordon Worley) Date: Thu, 3 Aug 2000 09:15:17 -0400 Subject: [Pythonmac-SIG] os.path.normpath() In-Reply-To: References: Message-ID: At 11:43 PM -0700 8/1/2000, Corran Webster wrote: >Hi, > there is currently discussion on the distutils list because of some >problems with the current implementation of os.path.normpath() on the >macintosh. The problem arises because > >os.path.normpath("Macintosh HD:Applications:") == "Macintosh HD:Applications:" > >and > >os.path.normpath("Macintosh HD:Applications") == "Macintosh HD:Applications" > >despite the fact that the paths are equivalent. distutils needs a platform >independent way to check for two paths being equivalent, and this is >failing because of examples like the above. Umm, they're not equivilant. The former refers to a folder and the latter a file (or application or whatever but not a folder). While with folders this is not important, it would be a problem if os.path.normpath thought that my file at "machd:docs:file" was the same as "machd:docs:file:", a folder that does not and cannot exist whilst a file is there. -- Gordon Worley http://www.rbisland.cx/ mailto:redbird@rbisland.cx PGP: C462 FA84 B811 3501 9010 20D2 6EF3 77F7 BBD3 B003 From just@letterror.com Thu Aug 3 15:42:59 2000 From: just@letterror.com (Just van Rossum) Date: Thu, 3 Aug 2000 15:42:59 +0100 Subject: [Pythonmac-SIG] MacPython, CGI and free cd's In-Reply-To: <20000803103031.334E8303181@snelboot.oratrix.nl> References: Message by Just van Rossum , Thu, 3 Aug 2000 11:49:37 +0100 , Message-ID: At 12:30 PM +0200 03-08-2000, Jack Jansen wrote: >Will something simple like dropping the applet in the server's CGI directory >work? With PythonCGISlave? No. It does if you run your script through BuildCGIApplet, which will create a .cgi applet ready to roll. Unfortunately for every change you will have to create the applet again. For PythonCGISlave, you need to configure the server so it directs any *.py requests to the PythonCGISlave applet. I think in most (Mac) web servers this is called an "action handler". The disadvantage (as well as advantage, once the script works) of this method is that modules don't get reloaded upon each request; if you edit a module, you're forced to either do a reload() in your script, or quit PythonCGISlave by hand. However, for debugging, PythonCGISlave can be configured to quit after each request, by setting the global variable LONG_RUNNING to 0. >If we can explain this is a few simple sentences for Personal Websharing >I think we're all set. Personal Websharing is what everyone will start with >nowadays, as it's included in MacOS, so I guess we can safely assume that >anyone who has a more powerful server will also have the knowledge about >where >to put CGI stuff for their brand of server. Also good points. Unfortunately I'm still running an ancient OS (8.1), so I don't have PWS yet to play with. [ ... ] >But why wouldn't we do something nicer for Python users? You mean create something portable? Or do you mean _Mac_Python users? >Putting the >try/except in the wrapper, for instance (the user can always override it with >another try/exceept in their script). I don't see why we should create different default behavior than for unix. >Also, on unix you can test your CGI script with something like >% QUERY_STRING=arg+arg+arg cgi-bin/myscript >but on the mac this isn't possible, but we could easily provide some help. Ah, but that's an entirely different problem I'd say. How about a *very* simple wrapper, as an applet called, say, TestCGIScript: import sys, os import EasyDialogs if len(sys.argv) <> 2: print "please drop exactly one cgi script on this applet" sys.exit(1) query = EasyDialogs.AskString("Enter query string:") if query: script = sys.argv[1] namespace = {"__name__": "__main__"} os.environ["QUERY_STRING"] = query execfile(script, namespace) >Hmm, maybe this should be folded into the IDE? If you could "Run as CGI" from >the IDE and then "Save as CGI" (which would save in the right place, copy the >applet, etc) we would be giving people a pretty decent CGI development >environment... And make the UI even messier than it already is? ;-) Just From jack@oratrix.nl Thu Aug 3 14:53:12 2000 From: jack@oratrix.nl (Jack Jansen) Date: Thu, 03 Aug 2000 15:53:12 +0200 Subject: [Pythonmac-SIG] os.path.normpath() In-Reply-To: Message by Gordon Worley , Thu, 3 Aug 2000 09:15:17 -0400 , Message-ID: <20000803135313.361EF303181@snelboot.oratrix.nl> > At 11:43 PM -0700 8/1/2000, Corran Webster wrote: > >Hi, > > there is currently discussion on the distutils list because of some > >problems with the current implementation of os.path.normpath() on the > >macintosh. The problem arises because > > > >os.path.normpath("Macintosh HD:Applications:") == "Macintosh HD:Applications:" > > > >and > > > >os.path.normpath("Macintosh HD:Applications") == "Macintosh HD:Applications" > > > >despite the fact that the paths are equivalent. distutils needs a platform > >independent way to check for two paths being equivalent, and this is > >failing because of examples like the above. > > Umm, they're not equivilant. The former refers to a folder and the > latter a file (or application or whatever but not a folder). Not completely correct: the latter can refer to anything (including a folder). It is customary on MacOS to show folder pathnames with the : at the end, but this is not absolutely needed (try macfs.FSSpec on the pathname both with and without colon and you'll see they return the same). There is one case where the colon *is* needed, though: if you're referring to a toplevel disk. "Macintosh HD:" is the toplevel folder on a disk, "Macintosh HD" is a file in the working directory. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From jack@oratrix.nl Thu Aug 3 15:00:14 2000 From: jack@oratrix.nl (Jack Jansen) Date: Thu, 03 Aug 2000 16:00:14 +0200 Subject: [Pythonmac-SIG] MacPython, CGI and free cd's In-Reply-To: Message by Just van Rossum , Thu, 3 Aug 2000 15:42:59 +0100 , Message-ID: <20000803140015.678D4303181@snelboot.oratrix.nl> > At 12:30 PM +0200 03-08-2000, Jack Jansen wrote: > >Will something simple like dropping the applet in the server's CGI directory > >work? > > With PythonCGISlave? No. It does if you run your script through > BuildCGIApplet, which will create a .cgi applet ready to roll. > Unfortunately for every change you will have to create the applet again. Okay, this I'd like to change. This behaviour is nice once you have the cgi script working, but for debugging it's much easier if the PythonCGISlave engine would simply execfile() the script in a fixed folder. > >Putting the > >try/except in the wrapper, for instance (the user can always override it with > >another try/exceept in their script). > > I don't see why we should create different default behavior than for unix. Okay, let's try a different angle: do you _oppose_ this behaviour or is it just that you don't think it worth it? (i.e. would you mind if I implemented it:-) > >Also, on unix you can test your CGI script with something like > >% QUERY_STRING=arg+arg+arg cgi-bin/myscript > >but on the mac this isn't possible, but we could easily provide some help. > > Ah, but that's an entirely different problem I'd say. How about a *very* > simple wrapper, as an applet called, say, TestCGIScript: > > import sys, os > import EasyDialogs > > if len(sys.argv) <> 2: > print "please drop exactly one cgi script on this applet" > sys.exit(1) > > query = EasyDialogs.AskString("Enter query string:") > if query: > script = sys.argv[1] > namespace = {"__name__": "__main__"} > os.environ["QUERY_STRING"] = query > execfile(script, namespace) Exactly. > >Hmm, maybe this should be folded into the IDE? If you could "Run as CGI" from > >the IDE and then "Save as CGI" (which would save in the right place, copy the > >applet, etc) we would be giving people a pretty decent CGI development > >environment... > > And make the UI even messier than it already is? ;-) Ok. We can always put some extensions in the IDE extension folder to give access to this. I'm getting so enthusiastic about the project by now that I may well try and find some time to do the last little bits myself, as 99% of the code is already there (and I'd probably have to do the organization myself anyway, as that's mostly a question of beating on the installer). What do you think, is CGI scripting important enough to put PythonCGISlave in the toplevel folder, along with a CGI folder? Also, would you be opposed to renaming it to CGIPython.cgi? -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From just@letterror.com Thu Aug 3 16:10:33 2000 From: just@letterror.com (Just van Rossum) Date: Thu, 3 Aug 2000 16:10:33 +0100 Subject: [Pythonmac-SIG] os.path.normpath() In-Reply-To: <20000803135313.361EF303181@snelboot.oratrix.nl> References: Message by Gordon Worley , Thu, 3 Aug 2000 09:15:17 -0400 , Message-ID: At 3:53 PM +0200 03-08-2000, Jack Jansen wrote: >Not completely correct: the latter can refer to anything (including a >folder). >It is customary on MacOS to show folder pathnames with the : at the end, but >this is not absolutely needed (try macfs.FSSpec on the pathname both with and >without colon and you'll see they return the same). > >There is one case where the colon *is* needed, though: if you're referring to >a toplevel disk. "Macintosh HD:" is the toplevel folder on a disk, "Macintosh >HD" is a file in the working directory. I just wrote almost the same... But the bug in normpath() in macpath.py *is* indeed a bug: it should strip a trailing colon except when it's the only colon in the path. posixpath.normpath.py does the same: it strips any trailing slashes. Just From just@letterror.com Thu Aug 3 16:18:52 2000 From: just@letterror.com (Just van Rossum) Date: Thu, 3 Aug 2000 16:18:52 +0100 Subject: [Pythonmac-SIG] MacPython, CGI and free cd's In-Reply-To: <20000803140015.678D4303181@snelboot.oratrix.nl> References: Message by Just van Rossum , Thu, 3 Aug 2000 15:42:59 +0100 , Message-ID: At 4:00 PM +0200 03-08-2000, Jack Jansen wrote: >> Unfortunately for every change you will have to create the applet again. > >Okay, this I'd like to change. Which is easy if we make the LONG_RUNNING switch accesible from a menu. It could store the last value in a prefs file, and the default setting could be 0. >This behaviour is nice once you have the cgi >script working, but for debugging it's much easier if the PythonCGISlave >engine would simply execfile() the script in a fixed folder. I don't quite understand the fixed folder idea: why not put it where the web server wants it? (I mean, I do understand the idea in the context of your proposal, but in the context of PythonCGISlave as it is.) >> I don't see why we should create different default behavior than for unix. > >Okay, let's try a different angle: do you _oppose_ this behaviour or is it >just that you don't think it worth it? (i.e. would you mind if I implemented >it:-) I think it's simply not worth it... >> And make the UI even messier than it already is? ;-) > >Ok. We can always put some extensions in the IDE extension folder to give >access to this. Sure. >I'm getting so enthusiastic about the project by now that I may well try and >find some time to do the last little bits myself, as 99% of the code is >already there (and I'd probably have to do the organization myself anyway, as >that's mostly a question of beating on the installer). > >What do you think, is CGI scripting important enough to put PythonCGISlave in >the toplevel folder, along with a CGI folder? Nah... >Also, would you be opposed to renaming it to CGIPython.cgi? No; except when used as a slave (though a *.py action handler) it doesn't need to end in .cgi. Please also have a look at BuildCGIApplet; it uses PythonCGISlave.py; there's a simple switch in the latter to distinguish between the two behaviors. Just From smith@oe.fau.edu Thu Aug 3 15:23:43 2000 From: smith@oe.fau.edu (Samuel Smith) Date: Thu, 3 Aug 2000 10:23:43 -0400 Subject: [Pythonmac-SIG] simple cgi help? In-Reply-To: References: Message-ID: --============_-1246809857==_============ Content-Type: text/plain; charset="us-ascii" ; format="flowed" >Hi folks, > >I'm a new subscriber. I've been playing with Python (on a mac) for >about a month now. I'm comfortable with it, but not expert. > >A recent thread suggests that some of you have set up Python with >personal Web Sharing on their macs. I am trying to do the same. I >have >downloaded and (i think) installed the PythonCGIslave applet, but I >am >looking for information about actually coding a CGI script. > >I thought that simply having a script: > >print "hello world" > >in a script titled "helloworld.py" would output that text to the >browser, but I get error messages in my PythonCGIslave app, and it >terminates (but doesn't quit). > >Can anyone offer help and/or a super simple cgi script I can build >from? Here is a script. --============_-1246809857==_============ Content-Id: Content-Type: multipart/appledouble; boundary="============_-1246809857==_D============" --============_-1246809857==_D============ Content-Transfer-Encoding: base64 Content-Type: application/applefile; name="%processform.py" Content-Disposition: attachment; filename="%processform.py" ; modification-date="Sat, 8 Jul 2000 09:43:57 -0400" AAUWBwACAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAADAAAAPgAAAA4AAAAJAAAATAAAACAA AAAIAAAAbAAAABBwcm9jZXNzZm9ybS5weVRFWFRSKmNoAQAACwEUAAAAAAAAAAAAAIAA AAAAAAAAAPR6HgD5tF1LbQwAARwEvw== --============_-1246809857==_D============ Content-Type: application/octet-stream; name="processform.py" Content-Disposition: attachment; filename="processform.py" Content-Transfer-Encoding: base64 IiIiDVNlbmRzIGVtYWlsIHdpdGggbmFtZSBhbmQgY29udGFjdCBpbmZvcm1hdGlvbi4N YXNzdW1lcyBjZXJ0YWluIGZpZWxkcyBpbiBmb3JtIG9yIGdldCBVUkwNYXNzdW1lcyB0 aGF0IHRoaXMgc2NyaXB0IGlzIHJ1biBieSBjZ2lzbGF2ZXNlcnZlciBvbiBhIG1hY2lu dG9zaA0JIA0iIiINDWltcG9ydCBvcw1pbXBvcnQgc3lzDWltcG9ydCBjZ2kNaW1wb3J0 IHN0cmluZw1pbXBvcnQgY1N0cmluZ0lPDWltcG9ydCBzbXRwbGliDQ0jIGRlZmF1bHQg dmFsdWVzIGZvciBlbWFpbA1tYWlsc2VydmVyID0gInNhdmFpaS5hZGVwdHN5c3RlbXNp bmMuY29tIgkgDW1haWxzZW5kZXIgPSAid2VibWFzdGVyQGFkZXB0c3lzdGVtc2luYy5j b20iDW1haWxyZWNpcGllbnQgPSBtYWlsc2VuZGVyDW1haWxzdWJqZWN0ID0gIkNvbnRh Y3QgaW5mbyBmcm9tIHdlYiBwYWdlIGZvcm0uIg0NIyBzZXQgdXAgc3RyaW5nIGZpbGUg b2JqZWN0IHNvIHdlIGNhbiB1c2UgZmlsZSBpbyB0byBnZW5lcmF0ZSBtYWlsIG1lc3Nh Z2UNbWFpbHRleHQgPSBjU3RyaW5nSU8uU3RyaW5nSU8oKQkNDSMgc2V0dXAgZmlsZSB0 byBzdG9yZSByZXF1ZXN0cw1maWxlbmFtZSA9ICJjb250YWN0ZGF0YS50eHQiDQ0jIHBy b2Nlc3MgdGhlIGNnaSBpbnB1dA1mb3JtID0gY2dpLkZpZWxkU3RvcmFnZSgpDQ0NIyBj aGVjayB0byBzZWUgaWYgcmVxdWlyZWQgZmllbGRzIGFyZSBwcmVzZW50LiB0aGUgZmll bGQgbmFtZWQgJ3JlcXVpcmVkJw0jIGhhcyB0aGUgbmFtZXMgb2YgdGhlIHJlcXVpcmVk IGZpZWxkcyBhcyBhIHNwYWNlIGRlbGltaXRlZCBsaXN0IG9mIHdvcmRzDQ1taXNzaW5n ID0gW10gICMgcGxhY2UgdG8gcHV0IG1pc3NpbmcgZmllbGQgbmFtZXMgaWYgYW55DQ1p ZiBmb3JtLmhhc19rZXkoInJlcXVpcmVkIik6ICMgaXRlcmF0ZSB0aHJvdWdoIGxpc3Qg b2YgcmVxdWlyZWQgZmllbGQgbmFtZXMNCWZvciBmaWVsZCBpbiBzdHJpbmcuc3BsaXQo Zm9ybVsicmVxdWlyZWQiXS52YWx1ZSk6IA0JCWlmIG5vdChmb3JtLmhhc19rZXkoZmll bGQpKSBvciBmb3JtW2ZpZWxkXS52YWx1ZSA9PSAiIjogIA0JCQltaXNzaW5nLmFwcGVu ZChmaWVsZCkgIyBhcHBlbmQgbWlzc2luZyBmaWVsZCBuYW1lIHRvIGxpc3QNCQ1pZiBt aXNzaW5nICE9IFtdOgkgIyBwcmludCBvdXQgZXJyb3IgcGFnZQ0JcHJpbnQgIiIiSFRU UC8xLjAgMjAwIE9LDQkJCQlTZXJ2ZXI6IFBlcnNvbmFsV2ViU2hhcmluZzsgcHl0aG9u LWNnaS1zY3JpcHQNCQkJCU1JTUUtVmVyc2lvbjogMS4wDQkJCQlDb250ZW50LXR5cGU6 IHRleHQvaHRtbA0JCQkiIiINCXByaW50ICIiIg0JCQkJPGh0bWw+DQkJCQkJPGhlYWQ+ DQkJCQkJCTx0aXRsZT5TdWJtaXNzaW9uIEZhaWxlZDwvdGl0bGU+DQkJCQkJPC9oZWFk Pg0JCQkJCQk8Ym9keT4NCQkJCQkJCTxoMT5TdWJtaXNzaW9uIEZhaWxlZDwvaDE+DQkJ CQkJCQk8cD5UaGUgZm9sbG93aW5nIGZpZWxkcyB3ZXJlIG5vdCBmaWxsZWQgaW46PC9w Pg0JCQkJCQkJPFVMPg0JCQkiIiINCWZvciBmaWVsZCBpbiBtaXNzaW5nOg0JCXByaW50 ICIJPGxpPiIgKyBmaWVsZA0JIA0JcHJpbnQgIiIiDQkgCQkJIDwvVUw+DQkJCQkJPHA+ IFBsZWFzZSBnbyBiYWNrIGFuZCBjb21wbGV0ZSBhbGwgcmVxdWlyZWQgZmllbGRzIDwv cD4NCQkJCSA8L2JvZHk+DQkJCQkgPC9odG1sPg0JCQkgIiIiDWVsc2U6CSAjIGFsbCBy ZXF1aXJlZCBmaWVsZHMgYXJlIHByZXNlbnQgDQkjIGdldCBtYWlsIGZpZWxkcyBpZiBw cmVzZW50DQlpZiBmb3JtLmhhc19rZXkoInJlY2lwaWVudCIpIGFuZCBmb3JtWyJyZWNp cGllbnQiXS52YWx1ZSAhPSAiIjoNCQltYWlscmVjaXBpZW50ID0gZm9ybVsicmVjaXBp ZW50Il0udmFsdWUgICNzZXQgcmVjaXBpZW50IG90aGVyd2lzZSB1c2UgZGVmYXVsdAkJ CQkgDQkNCWlmIGZvcm0uaGFzX2tleSgic3ViamVjdCIpIGFuZCBmb3JtWyJzdWJqZWN0 Il0udmFsdWUgIT0gIiI6DQkJbWFpbHN1YmplY3QgPSBmb3JtWyJzdWJqZWN0Il0udmFs dWUgICNzZXQgc3ViamVjdCBvdGhlcndpc2UgdXNlIGRlZmF1bHQNCQ0JIyBnZXQgZmls ZSBmaWVsZCBpZiBwcmVzZW50IGFuZCBzZXQgdXAgZmlsZQ0JaWYgZm9ybS5oYXNfa2V5 KCJmaWxlIikgYW5kIGZvcm1bImZpbGUiXS52YWx1ZSAhPSAiIjoNCQlmaWxlbmFtZSA9 IGZvcm1bImZpbGUiXS52YWx1ZSAgI3NldCBmaWxlbmFtZSBvdGhlcndpc2UgdXNlIGRl ZmF1bHQNCQ0JY29udGFjdGZpbGUgPSBvcGVuKGZpbGVuYW1lLCJhKyIpDQljb250YWN0 ZmlsZS5zZWVrKDApDQkNCWlmIGNvbnRhY3RmaWxlLnJlYWQoMSkgPT0gIiI6DQkJd3Jp dGVoZWFkZXIgPSAxDQllbHNlOg0JCXdyaXRlaGVhZGVyID0gMA0JDQljb250YWN0Zmls ZS5zZWVrKDAsMikNCQ0JIyBGaWxsIGluIGhlYWRlciB0byBlbWFpbA0JbWFpbHRleHQu d3JpdGUoIlN1YmplY3Q6ICVzIFxuVG86ICVzXG5cbiIgJSAobWFpbHN1YmplY3QsbWFp bHJlY2lwaWVudCkgKQ0JDQlmaWVsZGxpc3QgPSBbXQ0JaWYgZm9ybS5oYXNfa2V5KCJz dWJtaXR0ZWQiKTogIyBpdGVyYXRlIHRocm91Z2ggbGlzdCBvZiBmaWVsZCBuYW1lcyB0 byBzdWJtaXQNCQlmaWVsZGxpc3QgPSBzdHJpbmcuc3BsaXQoZm9ybVsic3VibWl0dGVk Il0udmFsdWUpDQkJIyB3cml0ZSBmaWVsZCBuYW1lcw0JCWZvciBmaWVsZCBpbiBmaWVs ZGxpc3RbOi0xXTogDQkJCW1haWx0ZXh0LndyaXRlKCIlc1x0IiAlIGZpZWxkKQ0JCQlp ZiB3cml0ZWhlYWRlcjoNCQkJCWNvbnRhY3RmaWxlLndyaXRlKCIlc1x0IiAlIGZpZWxk KQ0JCW1haWx0ZXh0LndyaXRlKCIlc1xuIiAlIGZpZWxkbGlzdFstMV0pDQkJaWYgd3Jp dGVoZWFkZXI6DQkJCWNvbnRhY3RmaWxlLndyaXRlKCIlc1xuIiAlIGZpZWxkbGlzdFst MV0pDQkJCQkNCQkjIHdyaXRlIGZpZWxkIHZhbHVlcw0JCWZvciBmaWVsZCBpbiBmaWVs ZGxpc3RbOi0xXTogDQkJCWlmIGZvcm0uaGFzX2tleShmaWVsZCk6ICANCQkJCW1haWx0 ZXh0LndyaXRlKCIlc1x0IiAlIGZvcm1bZmllbGRdLnZhbHVlKQ0JCQkJY29udGFjdGZp bGUud3JpdGUoIiVzXHQiICUgZm9ybVtmaWVsZF0udmFsdWUpDQkJCWVsc2U6DQkJCQlt YWlsdGV4dC53cml0ZSgiXHQiKQ0JCQkJY29udGFjdGZpbGUud3JpdGUoIlx0IikNCQlp ZiBmb3JtLmhhc19rZXkoZmllbGRsaXN0Wy0xXSk6DQkJCW1haWx0ZXh0LndyaXRlKCIl c1xuIiAlIGZvcm1bZmllbGRsaXN0Wy0xXV0udmFsdWUpDQkJCWNvbnRhY3RmaWxlLndy aXRlKCIlc1xuIiAlIGZvcm1bZmllbGRsaXN0Wy0xXV0udmFsdWUpDQkJZWxzZToNCQkJ bWFpbHRleHQud3JpdGUoIlxuIikNCQkJY29udGFjdGZpbGUud3JpdGUoIlxuIikNCQ0J Y29udGFjdGZpbGUuY2xvc2UoKQ0JDQkjIHNlbmQgZW1haWwJCQkJCQkNCXNlcnZlciA9 IHNtdHBsaWIuU01UUChtYWlsc2VydmVyKQ0Jc2VydmVyLnNlbmRtYWlsKG1haWxzZW5k ZXIsbWFpbHJlY2lwaWVudCxtYWlsdGV4dC5nZXR2YWx1ZSgpKQ0JbWFpbHRleHQuY2xv c2UoKQ0Jc2VydmVyLnF1aXQoKQ0JDQkNCQkNCSMgZm9ybWF0IGNvbmZpcm1hdGlvbiBw YWdlDQlwcmludCAiIiJIVFRQLzEuMCAyMDAgT0sNCQkJCVNlcnZlcjogUGVyc29uYWxX ZWJTaGFyaW5nOyBweXRob24tY2dpLXNjcmlwdA0JCQkJTUlNRS1WZXJzaW9uOiAxLjAN CQkJCUNvbnRlbnQtdHlwZTogdGV4dC9odG1sDQkJCSIiIg0JcHJpbnQgIiIiDQkJCQk8 aHRtbD4NCQkJCQk8aGVhZD4NCQkJCQkJPHRpdGxlPlN1Ym1pc3Npb24gU3VjY2VlZGVk PC90aXRsZT4NCQkJCQk8L2hlYWQ+DQkJCQkJCTxib2R5Pg0JCQkJCQkJPGgxPllvdXIg U3VibWlzc2lvbiBTdWNjZWVkZWQ8L2gxPg0JCQkJCQkJPHA+V2UgaGF2ZSByZWNlaXZl ZCB0aGUgZm9sbG93aW5nIGluZm9ybWF0aW9uOzwvcD4NCQkJCQkJCQ0JCQkiIiINCWZv ciBmaWVsZCBpbiBmaWVsZGxpc3Q6IA0JCWlmIGZvcm0uaGFzX2tleShmaWVsZCk6ICAN CQkJcHJpbnQgIiVzOiAlczxicj4iICUgKGZvcm1bZmllbGRdLm5hbWUsIGZvcm1bZmll bGRdLnZhbHVlKQ0JCQkNCQ0gDQlwcmludCAiIiINCQkJCQk8cD5UaGFuayB5b3UgdmVy eSBtdWNoITwvcD4NCQkJCSA8L2JvZHk+DQkJCQkgPC9odG1sPg0JCQkgIiIiCQ0JDQkN CQ0= --============_-1246809857==_D============-- --============_-1246809857==_============ Content-Id: Content-Type: text/html; name="submit.html"; charset="us-ascii" ; format="flowed" Content-Disposition: attachment; filename="submit.html" ; modification-date="Tue, 4 Jul 2000 18:02:00 -0400" ; x-mac-type="54455854" ; x-mac-creator="522A6368" Adept Test Page

Please enter your name and address.
















 
 

[Adept Systems]
--============_-1246809857==_============ Content-Type: text/plain; charset="us-ascii" ; format="flowed" -- ********************************** Samuel M. Smith Ph.D. Professor Director Advanced Marine Systems Lab **************(Dania SeaTech Building)*********************** Institute for Ocean and Systems Engineering Florida Atlantic University Rm. 225 B, SeaTech Bldg. 101 North Beach Road, Dania, FL 33004 (voice) 954-924-7232 (secretary Paula) 954-924-7230 (fax) 954-924-7233 (mobile) 561-251-2114 (email) smith@oe.fau.edu (web) http://www.oe.fau.edu --============_-1246809857==_============-- From smith@oe.fau.edu Thu Aug 3 15:40:34 2000 From: smith@oe.fau.edu (Samuel Smith) Date: Thu, 3 Aug 2000 10:40:34 -0400 Subject: [Pythonmac-SIG] More PythonCGISlave notes. In-Reply-To: References: Message-ID: At 23:58 +0100 8/2/00, Just van Rossum wrote: >At 2:48 PM -0700 02-08-2000, Chris Barker wrote: >>Well, perhaps it's line 69: >> >>print "%s version %s ready." % (self.__class__.__name__, __version__) >> >>Without it it doesn't bring up the window. Will this cause any problems? >>As it happens, I've used sys.stdout to write data for diagnosing >>problems. Should I re-direct it? > >Oops, sorry, I misinformed you. It is the reverse: for PythonCGISlave, >"delay console until needed" should be *off*. This way, the SIOUX window + >menus get installed before the applets own menus override them. > >>I've also found why it's not working for me. It crashes on line 79: >> >>root = args['DIRE'].as_pathname() >> >>args does not get a 'DIRE' key. It looks like this is supposed to get >>passed in from the Web server by the AppleEvent, but apparently it's >>not. I know NOTHING about AppleEvents, so I am completely lost now. I'm >>using Personal Web Sharing in MAC OS 8.6. MacPython 1.5.2c Does anyone >>have it working with these versions? I didn't have any of these problems. I am using MacOS 9.0.4 with Web Sharing v1.5. Here is a dump from my errors file if it is of any help. I deleted the cookie info since it included a password. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CGI exception (Mon Jul 3 22:19:31 2000) os.environ = { 'AE_AGNT': 'Mozilla/4.72 (Macintosh; U; PPC)', 'AE_FRMU': '', 'AE_KACT': 'ACTION', 'AE_KAPT': '/processform.py', 'AE_KCID': '\000\000\000\177', 'AE_KFRQ': 'POST /processform.py HTTP/1.0\015\012Referer: http://upolu.adeptsystemsinc.com/submit.html\015\012Connection: Keep-Alive\015\012User-Agent: Mozilla/4.72 (Macintosh; U; PPC)\015\012Host: upolu.adeptsystemsinc.com\015\012Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*\015\012Accept-Encoding: gzip\015\012Accept-Language: en\015\012Accept-Charset: iso-8859-1,*,utf-8\015\012Cookie: samuelsmithmanilawebsite=smithsm@samuelsmith.org%09falesa\015\012Content-type: application/x-www-form-urlencoded\015\012Content-length: 131\015\012', 'AE_PASS': '', 'AE_POST': 'fun=doit&recipient=webmaster%40adeptsystemsinc.com&required=first+address&first=John&last=Smith&address=101+Elm+St.&city=Boca+Raton', 'AE_REFR': 'http://upolu.adeptsystemsinc.com/submit.html', 'AE_USER': '', 'CONTENT_LENGTH': '131', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'DOCUMENT_ROOT': 'IntHDA:Web Pages', 'HTTP_ACCEPT': 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*', 'HTTP_ACCEPT_CHARSET': 'iso-8859-1,*,utf-8', 'HTTP_ACCEPT_ENCODING': 'gzip', 'HTTP_ACCEPT_LANGUAGE': 'en', 'HTTP_CONNECTION': 'Keep-Alive', 'HTTP_CONTENT_LENGTH': '131', 'HTTP_CONTENT_TYPE': 'application/x-www-form-urlencoded', 'HTTP_COOKIE': '', 'HTTP_HOST': 'upolu.adeptsystemsinc.com', 'HTTP_REFERER': 'http://upolu.adeptsystemsinc.com/submit.html', 'HTTP_USER_AGENT': 'Mozilla/4.72 (Macintosh; U; PPC)', 'QUERY_STRING': '', 'REMOTE_ADDR': '209.118.209.180', 'REMOTE_HOST': '209.118.209.180', 'REQUEST_METHOD': 'POST', 'REQUEST_URI': '/processform.py', 'SCRIPT_NAME': '/processform.py', 'SERVER_NAME': '209.118.209.180', 'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.0', } Traceback (innermost last): File "IntHDB:Python:Python 1.5.2c1:User:bin:PythonCGISlave.py", line 211, in cgihandler File "IntHDA:Web Pages:processform.py", line 81, in ? server.sendmail(mailsender,mailrecipient,mailtext.getvalue()) File "IntHDB:Python:Python 1.5.2c1:Lib:smtplib.py", line 472, in sendmail for each in to_addrs: AttributeError: __getitem__ >Ah, this may be a WebStar-specific key. The thing to do is hardwire the >script path in PythonCGISlave.py, possibly as a relative path from the >applet (by looking at os.getcwd() at startup). > >Just > > > >_______________________________________________ >Pythonmac-SIG maillist - Pythonmac-SIG@python.org >http://www.python.org/mailman/listinfo/pythonmac-sig -- ********************************** Samuel M. Smith Ph.D. Professor Director Advanced Marine Systems Lab **************(Dania SeaTech Building)*********************** Institute for Ocean and Systems Engineering Florida Atlantic University Rm. 225 B, SeaTech Bldg. 101 North Beach Road, Dania, FL 33004 (voice) 954-924-7232 (secretary Paula) 954-924-7230 (fax) 954-924-7233 (mobile) 561-251-2114 (email) smith@oe.fau.edu (web) http://www.oe.fau.edu From just@letterror.com Thu Aug 3 17:19:16 2000 From: just@letterror.com (Just van Rossum) Date: Thu, 3 Aug 2000 17:19:16 +0100 Subject: [Pythonmac-SIG] More PythonCGISlave notes. In-Reply-To: References: Message-ID: At 2:48 PM -0700 02-08-2000, Chris Barker wrote: >args does not get a 'DIRE' key. It looks like this is supposed to get >passed in from the Web server by the AppleEvent, but apparently it's >not. I know NOTHING about AppleEvents, so I am completely lost now. I'm >using Personal Web Sharing in MAC OS 8.6. MacPython 1.5.2c Does anyone >have it working with these versions? At 10:40 AM -0400 03-08-2000, Samuel Smith wrote: >I didn't have any of these problems. I am using MacOS 9.0.4 with Web >Sharing v1.5. > >Here is a dump from my errors file if it is of any help. I deleted >the cookie info since it included a password. Thanks, this is interesting info: it means that Web Sharing 1.5 under MacOS 9 does support the 'DIRE' AE parameter. Just From tmk@easynet.be Thu Aug 3 16:43:58 2000 From: tmk@easynet.be (tmk) Date: Thu, 03 Aug 2000 17:43:58 +0200 Subject: [Pythonmac-SIG] MacPython, CGI and free cd's In-Reply-To: <20000803140015.678D4303181@snelboot.oratrix.nl> Message-ID: > What do you think, is CGI scripting important enough to put PythonCGISlave in > the toplevel folder, along with a CGI folder? Also, would you be opposed to > renaming it to CGIPython.cgi? Is there a reason not to make it an ."acgi" to allow for async processing? = tmk = > -- > Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ > Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ > www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm > > > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG@python.org > http://www.python.org/mailman/listinfo/pythonmac-sig > From just@letterror.com Thu Aug 3 20:40:06 2000 From: just@letterror.com (Just van Rossum) Date: Thu, 3 Aug 2000 20:40:06 +0100 Subject: [Pythonmac-SIG] MacPython, CGI and free cd's In-Reply-To: References: <20000803140015.678D4303181@snelboot.oratrix.nl> Message-ID: At 5:43 PM +0200 03-08-2000, tmk wrote: >Is there a reason not to make it an ."acgi" to allow for async processing? Don't acgi's need to send explicit events back to the server instead of simply "returning" a value? Just From redbird@rbisland.cx Fri Aug 4 02:53:58 2000 From: redbird@rbisland.cx (Gordon Worley) Date: Thu, 3 Aug 2000 21:53:58 -0400 Subject: [Pythonmac-SIG] MacPython ODP Category update Message-ID: Well, while I'm at it, I might as well give the summer reminder for everyone to send those links in to the MacPython Open Directory Project category. To do it, all you have to do is visit the below URL and submit your links. Remember, this can only be a good resource if people keep submitting linkage for the work they are doing. If you tried to connect to the category recently, you may have had some trouble. Well, that's because we moved it. In an effort to clean up all of Mac/Dev, MacPython was moved to . Please update your links. -- Gordon Worley http://www.rbisland.cx/ mailto:redbird@rbisland.cx PGP: C462 FA84 B811 3501 9010 20D2 6EF3 77F7 BBD3 B003 From redbird@rbisland.cx Fri Aug 4 05:12:30 2000 From: redbird@rbisland.cx (Gordon Worley) Date: Fri, 4 Aug 2000 00:12:30 -0400 Subject: [Pythonmac-SIG] _menustocheck questions Message-ID: I'm having some trouble with getting _menustocheck to work the way I would like it to. Most everything in there seems to be fine, but the selallitem item doesn't work (when the window with the domenu_selectall callback is closed, the selectall menu remains hilighted, even though there is no function to handle it). To make sure I'm not messing up somewhere else, here is my makeusermenus method: def makeusermenus(self): # Set up menu items which all applications should have. # Apple Menu has already been set up. # File menu m =3D Wapplication.Menu(self.menubar, "File") newitem =3D FrameWork.MenuItem(m, "New", "N", 'new') openitem =3D FrameWork.MenuItem(m, "Open=8A", "O", 'open') FrameWork.Separator(m) closeitem =3D FrameWork.MenuItem(m, "Close", "W", 'close') saveitem =3D FrameWork.MenuItem(m, "Save", "S", 'save') saveasitem =3D FrameWork.MenuItem(m, "Save as=8A", None, 'save_as') FrameWork.Separator(m) quititem =3D FrameWork.MenuItem(m, "Quit", "Q", 'quit') # Edit menu m =3D Wapplication.Menu(self.menubar, "Edit") undoitem =3D FrameWork.MenuItem(m, "Undo", 'Z', "undo") FrameWork.Separator(m) cutitem =3D FrameWork.MenuItem(m, "Cut", 'X', "cut") copyitem =3D FrameWork.MenuItem(m, "Copy", "C", "copy") pasteitem =3D FrameWork.MenuItem(m, "Paste", "V", "paste") clearitem =3D FrameWork.MenuItem(m, "Clear", None, "clear") FrameWork.Separator(m) selallitem =3D FrameWork.MenuItem(m, "Select all", "A", "selectall") FrameWork.Separator(m) selallitem =3D FrameWork.MenuItem(m, "Add Item", "D", "add_item") selallitem =3D FrameWork.MenuItem(m, "Edit Selection", "E", "edit_item"= ) # Any other menus would go here # These menu items need to be updated periodically; # any menu item not handled by the application should be here, # as should any with a "can_" handler. self._menustocheck =3D [closeitem, saveitem, saveasitem, undoitem, cutitem, copyitem, pasteitem, clearitem, selallitem] selectall doesn't have a can_selectall function anywhere, but adding one doesn't seem to help. Then, to make matters worse, when I try to add items (using several different methods, like adding the callback name, the callback name in quotes, the callback name with item appended...) to _menustocheck it just gets errors when run (specifically, a NameError). I tried looking around at the IDE's code, but it wasn't much help. From FrameWork it seemed like the items in _menustocheck should be the callback names, but that didn't work either. So, I want to know how _menustocheck works. The code didn't help this time, so could someone please explain it to me? BTW, sorry if I'm getting anoying the past few days. I usually don't have so many questions to ask one after another. ;-) -- Gordon Worley http://www.rbisland.cx/ mailto:redbird@rbisland.cx PGP: C462 FA84 B811 3501 9010 20D2 6EF3 77F7 BBD3 B003 From savageb@pacbell.net Fri Aug 4 05:23:24 2000 From: savageb@pacbell.net (Bob Savage) Date: Thu, 03 Aug 2000 21:23:24 -0700 Subject: [Pythonmac-SIG] MacPython Links In-Reply-To: Message-ID: on 8/3/00 6:53 PM, Gordon Worley wrote: > Well, while I'm at it, I might as well give the summer reminder for > everyone to send those links in to the MacPython Open Directory Speaking of links, does the change to PythonLabs mean we get more control over the PythonMac SIG webpage? I think it should have a link to the MacPython webpage and mention should be dropped of OpenDoc. Just a thought... Bob From cwebster@nevada.edu Fri Aug 4 06:50:37 2000 From: cwebster@nevada.edu (Corran Webster) Date: Thu, 3 Aug 2000 22:50:37 -0700 Subject: [Pythonmac-SIG] _menustocheck questions In-Reply-To: Message-ID: At 12:12 AM -0400 4/8/00, Gordon Worley wrote: > I'm having some trouble with getting _menustocheck to work the way I > would like it to. Most everything in there seems to be fine, but the > selallitem item doesn't work (when the window with the > domenu_selectall callback is closed, the selectall menu remains > hilighted, even though there is no function to handle it). To make > sure I'm not messing up somewhere else, here is my makeusermenus > method: If you're using W, and you haven't yet done so, you should read over the notes I wrote up last year at http://www.nevada.edu/~cwebster/Python/WWidgets/ particularly http://www.nevada.edu/~cwebster/Python/WWidgets/usingW.html#moremenus which explains how to use _menustocheck works. > def makeusermenus(self): [...] > # These menu items need to be updated periodically; > # any menu item not handled by the application should be here, > # as should any with a "can_" handler. > self._menustocheck = [closeitem, saveitem, saveasitem, > undoitem, cutitem, copyitem, pasteitem, > clearitem, selallitem] > > selectall doesn't have a can_selectall function anywhere, but adding > one doesn't seem to help. Then, to make matters worse, when I try to > add items (using several different methods, like adding the callback > name, the callback name in quotes, the callback name with item > appended...) to _menustocheck it just gets errors when run > (specifically, a NameError). I tried looking around at the IDE's > code, but it wasn't much help. From FrameWork it seemed like the > items in _menustocheck should be the callback names, but that didn't > work either. The basic idea is that these are widget-level callbacks. The "can_" methods allow widgets to update which menus are highlighted based on their state - eg. a text widget can enable copy and cut menus if some text is selected (or disable if it is not) via the can_copy and can_cut methods. > So, I want to know how _menustocheck works. The code didn't help > this time, so could someone please explain it to me? Have a look at the W text editor widgets for some good examples of how to use them or some of the sample code at my site, particularly http://www.nevada.edu/~cwebster/Python/WWidgets/stylededitor.html Hopefully this will clear things up for you. Regards, Corran From dante@oz.net Fri Aug 4 07:22:20 2000 From: dante@oz.net (Dante) Date: Thu, 3 Aug 2000 23:22:20 -0700 Subject: [Pythonmac-SIG] Get Info Comments In-Reply-To: References: Message-ID: Answering my own question after a little help from AECaptureParser (thanks Erik!) These two functions will set and get comments with a path to a file. They're not tested much, but they've worked well so far. Michael import aetools, aetypes def getComment(path): """Get the comment in the Get Info window of a file""" AEobject_00 = aetypes.ObjectSpecifier(want=aetypes.Type('file'), form="name", seld=path, fr=None) AEobject_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('iwnd'), fr=AEobject_00) AEobject_02 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('comt'), fr=AEobject_01) _arguments = {'----':AEobject_02} _reply, _arguments, _attributes = aetools.TalkTo("MACS").send("core", "getd", _arguments, {}) if _arguments.has_key('errn'): raise aetools.Error, aetools.decodeerror(_arguments) if _arguments.has_key('----'): return _arguments['----'] def setComment(path, comment): "Set the comment in the Get Info window of a file""" _arguments = {} AEobject_00 = aetypes.ObjectSpecifier(want=aetypes.Type('file'), form="name", seld=path, fr=None) AEobject_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('iwnd'), fr=AEobject_00) AEobject_02 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('comt'), fr=AEobject_01) _arguments = {'----':AEobject_02, 'data':comment} _reply, _arguments, _attributes = aetools.TalkTo("MACS").send("core", "setd", _arguments, {}) if _arguments.has_key('errn'): raise aetools.Error, aetools.decodeerror(_arguments) if _arguments.has_key('----'): return _arguments['----'] -- bang but a whimper/conduct your own funeral/let the light shine through ... Michael Esveldt mailto:dante@oz.net - http://velocity.editthispage.com/ #FightThePower on irc.openprojects.net From redbird@rbisland.cx Sat Aug 5 04:21:28 2000 From: redbird@rbisland.cx (Gordon Worley) Date: Fri, 4 Aug 2000 23:21:28 -0400 Subject: [Pythonmac-SIG] _menustocheck questions In-Reply-To: References: Message-ID: At 10:50 PM -0700 8/3/2000, Corran Webster wrote: > > def makeusermenus(self): >[...] >> # These menu items need to be updated periodically; >> # any menu item not handled by the application should be here, >> # as should any with a "can_" handler. >> self._menustocheck = [closeitem, saveitem, saveasitem, >> undoitem, cutitem, copyitem, pasteitem, >> clearitem, selallitem] >> >> selectall doesn't have a can_selectall function anywhere, but adding >> one doesn't seem to help. Then, to make matters worse, when I try to >> add items (using several different methods, like adding the callback >> name, the callback name in quotes, the callback name with item >> appended...) to _menustocheck it just gets errors when run >> (specifically, a NameError). I tried looking around at the IDE's >> code, but it wasn't much help. From FrameWork it seemed like the >> items in _menustocheck should be the callback names, but that didn't >> work either. > >The basic idea is that these are widget-level callbacks. The "can_" >methods allow widgets to update which menus are highlighted based on their >state - eg. a text widget can enable copy and cut menus if some text is >selected (or disable if it is not) via the can_copy and can_cut methods. Well, I actually used your code from WWidgets for my application and then worked up from there. I've read through the docs (I did this before posting, just to make sure I hadn't missed anything) and understand the semantics, but am getting hung up on the syntax. I should rephrase that I want to how _menustocheck's syntax works. For example, let's consider selectall for a minute since I've thrown that out previously. The callback for the menu is selectall, so domenu_selectall and can_selectall would be what we want to code. Now, we also want selectall in _menustocheck so that the can_selectall function won't have been written just to sit idlely. From looking at other items in _menustocheck (like saveitem and copyitem), it seems that we would just append item to the callback name. selectall, however, in _menustocheck is put in as selallitem, reporting a NameError if anything else is put there instead. I don't see where this syntax is comming from, and thus can't add any more items into _menustocheck unless I get lucky and happen to guess the right thing to put there. Maybe I'm just missing something basic here that everyone else has already figured out, but I just can't see why something like selallitem works while selectallitem doesn't (which extends to adding menu items to _menustocheck that have never been added to it by anyone else before). Consider one more final example, where I try to add add_item to _menustocheck. All of my attempts has looked basically like this: self._menustocheck = [closeitem, ..., add_itemitem] which results in a NameError on the newly added item. To be more direct, where do the names used in _menustocheck come from and how do they relate to the menuitems that they are connected to? -- Gordon Worley http://www.rbisland.cx/ mailto:redbird@rbisland.cx PGP: C462 FA84 B811 3501 9010 20D2 6EF3 77F7 BBD3 B003 From cwebster@nevada.edu Sat Aug 5 07:22:05 2000 From: cwebster@nevada.edu (Corran Webster) Date: Fri, 4 Aug 2000 23:22:05 -0700 Subject: [Pythonmac-SIG] _menustocheck questions In-Reply-To: References: Message-ID: At 11:21 PM -0400 4/8/00, Gordon Worley wrote: > At 10:50 PM -0700 8/3/2000, Corran Webster wrote: > > > def makeusermenus(self): > >[...] > >> # These menu items need to be updated periodically; > >> # any menu item not handled by the application should be here, > >> # as should any with a "can_" handler. > >> self._menustocheck = [closeitem, saveitem, saveasitem, > >> undoitem, cutitem, copyitem, pasteitem, > >> clearitem, selallitem] > >> [snip] > For example, let's consider selectall for a minute since I've thrown > that out previously. The callback for the menu is selectall, so > domenu_selectall and can_selectall would be what we want to code. > Now, we also want selectall in _menustocheck so that the > can_selectall function won't have been written just to sit idlely. > From looking at other items in _menustocheck (like saveitem and > copyitem), it seems that we would just append item to the callback > name. selectall, however, in _menustocheck is put in as selallitem, > reporting a NameError if anything else is put there instead. I don't > see where this syntax is comming from, and thus can't add any more > items into _menustocheck unless I get lucky and happen to guess the > right thing to put there. Maybe I'm just missing something basic > here that everyone else has already figured out, but I just can't see > why something like selallitem works while selectallitem doesn't > (which extends to adding menu items to _menustocheck that have never > been added to it by anyone else before). > > Consider one more final example, where I try to add add_item to > _menustocheck. All of my attempts has looked basically like this: > > self._menustocheck = [closeitem, ..., add_itemitem] > > which results in a NameError on the newly added item. To be more > direct, where do the names used in _menustocheck come from and how do > they relate to the menuitems that they are connected to? OK, I see what you're asking. Sorry for missing the point in my previous reply. If you look in the code for makeusermenus() you will see the line selallitem = FrameWork.MenuItem(m, "Select all", "A", "selectall") which is what creates the selectall menu. The arguments are respectively, the menu that the item is inserted into, the text of the menu, the command key equivalent, and the callback. It's the callback that you're after. If the callback is a string, then you have the options of using the "domenu_" or "can_" methods in widgets. However, when specifying the _menustocheck, you need to use the actual menu item object, not the callback, ie. selallitem. That's why you've been getting name errors - you've been trying to add non-existent menu item objects to the list. To consider your second example, you could do it by adding the line add_itemitem = Framework.MenuItem(m, "Add Item", None, "additem") in the appropriate place in makeusermenus, and changing self._menustocheck = [ ... stuff ..., add_itemitem] finally, you'd add "domenu_additem" and possibly "can_additem" methods to appropriate widget classes. Hope this helps. Regards, Corran From ben@ninjatech.com Mon Aug 7 19:41:06 2000 From: ben@ninjatech.com (Ben Smith) Date: Mon, 7 Aug 2000 11:41:06 -0700 (PDT) Subject: [Pythonmac-SIG] creating c/c++ python extensions on the mac? Message-ID: Are there any useful docs out there on how to do this? I have instructions for windows/unix, but I wasn't able to turn something up for the mac. I'm using codewarrior pro 5. If anyone has anything that would help, please drop me a line. Thanks -b From ben@ninjatech.com Tue Aug 8 01:53:12 2000 From: ben@ninjatech.com (Ben Smith) Date: Mon, 7 Aug 2000 17:53:12 -0700 (PDT) Subject: [Pythonmac-SIG] creating c/c++ python extensions on the mac? In-Reply-To: Message-ID: Nevermind, I found some useful stuff while browsing the sig archive from april. It's too bad I didn't look around more, sorry for duplication. -b From rtrocca@libero.it Wed Aug 9 17:20:29 2000 From: rtrocca@libero.it (rtrocca@libero.i) Date: Wed, 9 Aug 2000 18:20:29 +0200 Subject: [Pythonmac-SIG] MacPython, Qt4 & GWorlds Message-ID: Hello. I'm playing with MacPython in order to use it for my research. I've been using 1.5.2 and the sources DLed from the MacPython page. I compiled NumPy 15.3 for MacPython so I can put it somewhere on the Web if somebody wants it. I've also tried to translate a code samples for the QuickTime developer site from C to Python. The sample I'm speaking about is called "VideoFrameToGWorld". It takes a mov file (not an mpeg file) and put every frame in a GWorld ready for analysis or other processing. I've found some problem doing it in Python, given the fact that the sample used a Qt4 call and GWorld. So I made a new Qt4.ppc.slb, a QuickTime4.py and modified Qdoffs a bit in order to make GWorlds work with SetGWorld and SetMovieGWorld. I don't know if it is my poor skill in Python but I wasn't able to make them work (is it possible to do typecasting in Python?). Anyway now the port to Pyhton works and I've also wrote some classes to extract frames from a movie and put them in a PIL image or a Numeric array. Add to it some small utility to display PIL images or Numeric arrays in a framework window. Again if somebody is interested I'll post evrything. I hope that I'll be able to create a web page where I'll put everything. Anyway compliments to everybody for MacPython,it is really a pleasure to work with it. I'm looking forward to learn CVS enough in order to work with the latest version. Is there the possibility to have a snapshot of the current CVS once per week or less (month)? Riccardo Trocca From jaredu@its.caltech.edu Wed Aug 9 20:41:48 2000 From: jaredu@its.caltech.edu (Jared Updike) Date: Wed, 9 Aug 2000 12:41:48 -0700 (PDT) Subject: [Pythonmac-SIG] building PythonCorePPC-DBG Message-ID: I finally got _most_ of PythonCorePPC-DBG to compile, but I have one link error, which refers to the symbol fwalk not being found. When I was compiling CWGUSI, I noticed that it mentions that the fwalk code cannot be included, and that he instead included the binary. I don't know if this has something to do with the problem or not, but I need to be able to get a debug version of the PythonCore(PPC) library for debugging purposes. --Jared Web: http://waffles.caltech.edu Phone: (626)395-1154 Campus Adress: Blacker Hovse, Room 31 Adress: MSC 935 Caltech Pasadena, CA 91126-0935 From owen@astro.washington.edu Wed Aug 9 23:41:24 2000 From: owen@astro.washington.edu (Russell E Owen) Date: Wed, 9 Aug 2000 15:41:24 -0700 Subject: [Pythonmac-SIG] Tkinter, hopefully simple questions Message-ID: Has anybody been successful in attaching the standard cut, copy and paste menu items (with key accelerators) to a Text item in Tkinter? I'm not having much luck. By default the Edit menu appears, but does not seem to be attached to anything. "Effective Tcl/Kt Programming" (a great book, by the way) suggests binding to the <>, <> and <> virtual events, but they don't seem to exist in the Python world. I suspect I'll have to build my own Edit menu to replace the one that normally appears, which brings up the second question...how does one implement key accelerators in menus? Finally, has anybody found the Tkinter equivalent to Tk's "event add", to create new events? -- Russell From owen@astro.washington.edu Wed Aug 9 23:59:40 2000 From: owen@astro.washington.edu (Russell E Owen) Date: Wed, 9 Aug 2000 15:59:40 -0700 Subject: [Pythonmac-SIG] Tkinter, hopefully simple questions In-Reply-To: References: Message-ID: Nothing like finding *some* of the answers right after posting. Sorry about that. Still haven't got the heart of it nailed down, though... event add is actually just event_add, I somehow managed to miss it the first time I looked for it. My apologies. The <>, <> and <> virtual events *do* exist, but they only seem to be sent to a window, not widgets such as Text. It seems to me that makes it challenging to handle the events properly. So, the main questions remain: * Any decent solutions to implementing the standard Cut, Copy and Paste menu items and key accelerators in all relevant widgets? I'd also like to add Select All, which brings up... * Any way to add key accelerators to menu items? -- Russell >Has anybody been successful in attaching the standard cut, copy and >paste menu items (with key accelerators) to a Text item in Tkinter? >I'm not having much luck. By default the Edit menu appears, but does >not seem to be attached to anything. "Effective Tcl/Kt Programming" >(a great book, by the way) suggests binding to the <>, <> >and <> virtual events, but they don't seem to exist in the >Python world. > >I suspect I'll have to build my own Edit menu to replace the one >that normally appears, which brings up the second question...how >does one implement key accelerators in menus? > >Finally, has anybody found the Tkinter equivalent to Tk's "event >add", to create new events? > >-- Russell > >_______________________________________________ >Pythonmac-SIG maillist - Pythonmac-SIG@python.org >http://www.python.org/mailman/listinfo/pythonmac-sig From jack@oratrix.nl Thu Aug 10 09:26:03 2000 From: jack@oratrix.nl (Jack Jansen) Date: Thu, 10 Aug 2000 10:26:03 +0200 Subject: [Pythonmac-SIG] MacPython, Qt4 & GWorlds In-Reply-To: Message by "rtrocca@libero.i" , Wed, 9 Aug 2000 18:20:29 +0200 , Message-ID: <20000810082603.6F006303181@snelboot.oratrix.nl> Riccardo, for reading QuickTime into offscreen bitmaps you definitely want 1.6a2. I've been busy with just that in spring, and I found a few nasty little bugs. I can send you the code I have to read quicktime movies, but I'll have to rip it out of another program, so it may need a bit of work to get it running. An, of course, if you would be willing to clean it up and make it fit for inclusion in the distribution that would be really neat! And, about the CVS snapshots: I wonder whether it is worth the trouble nowadays. CVS tools are easily obtained, and learning to use it is not a major undertaking. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From just@letterror.com Fri Aug 11 09:10:56 2000 From: just@letterror.com (Just van Rossum) Date: Fri, 11 Aug 2000 09:10:56 +0100 Subject: [Pythonmac-SIG] [Fwd: [ANN] Pepper, a new text editor for MacOS] Message-ID: <3993B506.CA28F615@letterror.com> I found this message on comp.sys.mac.programmer.tools; it claims to support Python syntax styling. Anyone care to check it out? It sounds pretty cool. Just "M.L. Hekkelman" wrote: > = > PRESS RELEASE > = > Hekkelman Programmatuur b.v. has released Pepper, a new and powerful > text editor for MacOS. Pepper is an editor targeted at programmers, > script coders and HTML writers, but since it is such a powerful and yet= > easy to use tool you can use it for any task that involves working with= > plain text. > = > Among the unique features offered by Pepper are: > = > =80=A0intelligent and extendable language support through addons with s= yntax > styling as opposed to mere syntax coloring. Currently supported > languages are: HTML (with JavaScript and PHP embedded), C/C++, Pascal, > Oberon-2, Perl, Python, Rez, Shell, TeX > =80 identifier completion > =80=A0incremental search > =80 ToolServer integration with stderr parsing > =80=A0extensions and script extensions (apply a perl script to a select= ion > e.g.) > =80=A0fully configurable keybindings > =80 rectangular selections > = > And of course Pepper offers all the features available in other major > commercial text editors currently known on MacOS. > = > Pepper is a descendant of the popular Pe for BeOS, an editor that has > been used extensively by many, not only to write code but also novels > and other books (Neal Stephenson and Scot Hacker e.g.). Pepper is more > than a port, it offers many new features and interface enhancements whe= n > compared to its predecessor. > = > System requirements for Pepper are a PowerMac running MacOS 8.6. > = > Pepper is sold as shareware, single license fee is USD 45, site license= > is USD 400 and upgrades from Pe for BeOS are available at USD 25. > = > To download pepper go to http://www.hekkelman.com/ > = > Hekkelman Programmatuur b.v. is a privately held company founded in 199= 6 > by Maarten Hekkelman and specializing in writing software for MacOS and= > BeOS. Other products developed by Hekkelman Programmatuur b.v. are > Sum-It, a spreadsheet for both MacOS and BeOS, Pe for BeOS and bdb, the= > source level debugger bundled with BeOS. > = > -maarten > = > -- > http://www.hekkelman.com/ From owen@astro.washington.edu Fri Aug 11 17:59:45 2000 From: owen@astro.washington.edu (Russell E Owen) Date: Fri, 11 Aug 2000 09:59:45 -0700 Subject: [Pythonmac-SIG] [Fwd: [ANN] Pepper, a new text editor for MacOS] In-Reply-To: <3993B506.CA28F615@letterror.com> References: <3993B506.CA28F615@letterror.com> Message-ID: >I found this message on comp.sys.mac.programmer.tools; it claims to >support Python syntax styling. Anyone care to check it out? It sounds >pretty cool. I'm really glad you posted this. I saw a different announcement that said MacOS 9 was required, so I'd ignored it. I run 8.6, and when I saw your posting (which claims 8.6 is required) I downloaded Pepper and tried it out. It's interesting. It seems to work well -- no crashes so far. Python language support is claimed to not necessarily be complete, but even if it's not, one can supposedly extensively tweak the language-specific support, so I doubt it'll be a problem. It recognizes Python subroutine definitions and such and provides a pop-up menu to go to them. Standard Good Things: - semi-infinite multiple undo - grep - handles files larger than memory - interfaces to CodeWarrior and ToolServer Unusual Good Things: - Very configurable and extensible, including: - language-sensitive support - key bindings (if you can figure it out) - Rectangular selections (but only if word wrap turned off, alas) - QuickFind: type to find Bad Things: - No apparent way to limit find or find/replace to the current selection. Nisus 4 uses the option key to do this, which is wonderful. BBEdit has a checkbox, which I dislike but is certainly better than nothing. - Key binding editor is incomprehensible to me. Many commands show whole strings of weird and/or unprintable characters as their key binding; I have no idea what they're supposed to be doing. If there's a way to see a summary of all key bindings, I've not found it. The documentation claims that multi-state bindings are supported, but that there is no way to enter them using the interface, and so an improved key binding editor is planned (probably a separate application, alas). - Move-by-word (option-arrow) is weird compared to BBEdit, Nisus and Eudora. I sincerely hope this will be fixed, as there doesn't seem to be any need to be different. Pepper doesn't stop at punctuation or at beginning-of-line. Perhaps the definition of a word can be edited, but I've not yet found it. - Very little documentation - No on-line help Minor Oddities: - Rectangular selection is rejected with a dialog box if word wrap is on. I wish it just worked (as it does in Nisus), but saving that, a dialog box is excessive. I'd suggest a beep for the first transgression, perhaps a dialog box if the user tries several times in a row. Comments: - Every window has a toolbar with icon+text buttons. Thankfully it's a very thin toolbar with tiny icons, because you can't turn it off (alas). Wish List: - Active spell checking, like Eudora. I realize this is not very useful within code (though if it could only spell-check comments and strings...!), but it's great for HTML, documentation and general text. - Discontiguous selections (like Nisus; useful for certain kinds of mass changes) It looks very promising. Well worth trying. If it can be trained to run the Python script one is editing (and it probably can) it could be an excellent Python development environment. I hope development continues. -- Russell From owen@astro.washington.edu Fri Aug 11 18:25:24 2000 From: owen@astro.washington.edu (Russell E Owen) Date: Fri, 11 Aug 2000 10:25:24 -0700 Subject: [Pythonmac-SIG] [Fwd: [ANN] Pepper, a new text editor for MacOS] (followup) In-Reply-To: References: <3993B506.CA28F615@letterror.com> Message-ID: I wrote: >- Key binding editor is incomprehensible to me. Many commands show >whole strings of weird and/or unprintable characters as their key >binding; but have since found out that this is a bug. When I tried the keybinding editor again it as expected. If I find a pattern I'll report it to the author. One hang so far: selecting Justify (just to see what it'd do) on a short python script hung Pepper. Perhaps it was just thinking but I left it alone it for several minutes. Forced exit worked fine. -- Russell From jaredu@its.caltech.edu Fri Aug 11 20:23:28 2000 From: jaredu@its.caltech.edu (Jared Updike) Date: Fri, 11 Aug 2000 12:23:28 -0700 (PDT) Subject: [Pythonmac-SIG] Deugging PythonCore Shared Lib Message-ID: So I finally got the PythonCore lib compiled so I can use the debug info. Now when I run my code and put a breakpoint at PyMac_Initialize(); and step into it, it doesn't show the C source in the PythonCore SL, just assembly. I tried it with the symbol file for PythonCorePPC open, and checked to make sure that it was using that Shared Lb (I deleted all other PythonCore shared libs) but I still can't get the source to show. Any advice would be appreciated (and thanks for all the advice to this point; it has been useful). --Jared Web: http://waffles.caltech.edu Phone: (626)395-1154 Campus Adress: Blacker Hovse, Room 31 Adress: MSC 935 Caltech Pasadena, CA 91126-0935 From owen@astro.washington.edu Sat Aug 12 00:15:42 2000 From: owen@astro.washington.edu (Russell E Owen) Date: Fri, 11 Aug 2000 16:15:42 -0700 Subject: [Pythonmac-SIG] Tkinter, hopefully simple questions (more followup) In-Reply-To: References: Message-ID: >So, the main questions remain: >* Any decent solutions to implementing the standard Cut, Copy and >Paste menu items and key accelerators in all relevant widgets? I'd >also like to add Select All, which brings up... >* Any way to add key accelerators to menu items? Accelerators are easy. Example: filemenu.add_command( label="Close", command=self.doClose, accelerator="Command-W") The rest is a nightmare. I've posted a partial solution in comp.lang.python, thanks to some help from John Grayson, under the topic "Tkinter question: cut, copy and paste?". Tkinter is so nice in so many ways, but it's handling of the basic editing operations leaves a *lot* to be desired. Perhaps this is not news to anybody else, but it was a shock to me. -- Russell From fgranger@altern.org Sat Aug 12 12:15:10 2000 From: fgranger@altern.org (Francois Granger) Date: Sat, 12 Aug 2000 13:15:10 +0200 Subject: [Pythonmac-SIG] rfc822 lib In-Reply-To: References: Message-ID: At 12:28 +0200 on 24/07/00, in message Re: [Pythonmac-SIG] rfc822 lib, you wrote: >on 23/07/00 23:01, Rod Morehead at rmore@rmore.net wrote: > > > I would guess that this is because if you open a file in text mode on > > the Mac CR and LF are swapped and CR-LF become LF-CR which confuses > > the code (if you open it in binary mode they aren't, but then '\n' > > isn't a mac newline '\r' is). > >I did not thought of this. If the rfc library can work with this, it will >not be a big issue since I never access the file directly. Only the content >of the message may be with wrong lines ending ? > > > > > If performance isn't too important an easy workaround would be to try > > opening the file in binary mode ('rb') and then if that fails fall > > back to text mode. If that still fails then I would suspect something > > else is the problem. I did try your advice of opening in binary. It works. Thanks. François Granger -- "Computers are like horses; they can sense fear and will act based on that. Or, look at it like this. If you have a premonition of danger, maybe you're right." - Adam Engst From jack@oratrix.nl Sun Aug 13 22:59:04 2000 From: jack@oratrix.nl (Jack Jansen) Date: Sun, 13 Aug 2000 23:59:04 +0200 Subject: [Pythonmac-SIG] Python appleevent support Message-ID: <20000813215909.A6AEB116391@oratrix.oratrix.nl> Howdy folks, I'm thinking of revamping OSA support in MacPython, now that i funally understand how packages work:-) Do you think the following would be a good idea? I'd like to have one package per application. The packages will contain modules for each terminology resource that gensuitemodule finds, and the package itself will glue everything together. One of the nice effects of this is that you don't have to find all the OSA event classes an application supports yourself, that'll be done by the package. Something like >>> from CodeWarrior import CodeWarrior will take care of the correct Standard_Suite being included, etc. It will also enable me to (finally!) handle terminology resources that extend Standard_Suite, something that is currently done by an ugly (i.e. user-visible) hack. Oh yes, and a final question: does anyone have any idea where I can find the AETE (or was that AEUT) resources for Standard Suite and it's friends under MacOS 9? They used to be somewhere in the Dialects folder of the Scripting Additions folder, but I can't seem to find them anymore on my MacOS 9 machine... -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | ++++ see http://www.xs4all.nl/~tank/ ++++ From redbird@rbisland.cx Tue Aug 15 03:40:08 2000 From: redbird@rbisland.cx (Gordon Worley) Date: Mon, 14 Aug 2000 22:40:08 -0400 Subject: [Pythonmac-SIG] Closing windows on quit Message-ID: I'm trying to impliment in my program a feature where, on quit, rather than just forcing the windows closed and not checking to see if they have unsaved data (which, I take it, means that my windows' close functions are being overrided or not called in some way). My original plan was to modify the _quit() function in my application object, making it close the Win.FrontWindow() until it gets an error (because there are no more windows), but this resulted in an AttributeError (the offending line of code was, and I quote, 'Win.FrontWindow().close()'). There is, in fact, a close() function in all of the windows opened, so either I am somehow not accessing a window (or one not created by my code) or FrontWindow() doesn't do what I think it does (return the front most window). Is it possible that it wouldn't recoginize my windows as windows (they inherit from W.Window, in case that might matter)? Stepping back for a moment, is there a better way to do this? I don't want to go through implimenting all of the code necessary for a windows menu, since my program mostly creates small windows and does not necessarily lead itself to having lots of windows open. I just want to be able to give users a chance to save their data before quiting without a time delay (the trick used when the Finder sends the quit event to my program (thanks to the WWidgets examples :-))). Now, for something not so Python related, has anyone used icns resources with BNDL resources? I'm wondering because I designed icons for my application that look best at 32-bit and just okay at anything less. It's easy to get around this with the application itself (since I can just past the icon on), but with documents the answer isn't so clear (if I paste on icons when the documents are created, the icons won't update if the icons are changed in future versions of the program). If this is not possible after all and it is something other people have been lusting after, I guess I'll just have to wait for Mac OS X. -- Gordon Worley http://www.rbisland.cx/ mailto:redbird@rbisland.cx PGP: C462 FA84 B811 3501 9010 20D2 6EF3 77F7 BBD3 B003 From just@letterror.com Tue Aug 15 09:44:57 2000 From: just@letterror.com (Just van Rossum) Date: Tue, 15 Aug 2000 09:44:57 +0100 Subject: [Pythonmac-SIG] Closing windows on quit In-Reply-To: Message-ID: At 10:40 PM -0400 14-08-2000, Gordon Worley wrote: >I'm trying to impliment in my program a feature where, on quit, >rather than just forcing the windows closed and not checking to see >if they have unsaved data (which, I take it, means that my windows' >close functions are being overrided or not called in some way). My >original plan was to modify the _quit() function in my application >object, making it close the Win.FrontWindow() until it gets an error >(because there are no more windows), but this resulted in an >AttributeError (the offending line of code was, and I quote, >'Win.FrontWindow().close()'). There is, in fact, a close() function >in all of the windows opened, so either I am somehow not accessing a >window (or one not created by my code) or FrontWindow() doesn't do >what I think it does (return the front most window). Is it possible >that it wouldn't recoginize my windows as windows (they inherit from >W.Window, in case that might matter)? Well, there's about three kinds of windows involved: the builtin Window type (which is what FrontWindow() returns, FrameWork.Window and W.Window. The latter is a subclass of the one in FrameWork. The application object has a dictionary (app._windows) that maps builtin windows to their Python conterparts. The builtin one doesn't have a close method; use the W.Window().close() method. Here's what a close method usually looks like: def close(self): if self.changed: import EasyDialogs import Qd Qd.InitCursor() # XXX should be done by dialog save = EasyDialogs.AskYesNoCancel( 'Save window "%s" before closing?' % self.title, 1) if save > 0: if self.domenu_save(): return 1 elif save < 0: return 1 self.globals = None W.Window.close(self) And here's what the domenu_quit() method of your app object could look like: def domenu_quit(self): for window in self._windows.values(): try: rv = window.close() # ignore any errors while quitting except: rv = 0 if rv and rv > 0: return # don't quit, a save dialog has been cancelled self.quitting = 1 Just From jaredu@its.caltech.edu Tue Aug 15 19:44:21 2000 From: jaredu@its.caltech.edu (Jared Updike) Date: Tue, 15 Aug 2000 11:44:21 -0700 (PDT) Subject: [Pythonmac-SIG] Abnormal program termination Message-ID: So when I debug into PythonCore when my code calls PyMac_Initialize(); and step through, static int getpreffilefss(FSSpec *fssp) { static int diditbefore=0; static int rv = 1; static FSSpec fss; short prefdirRefNum; long prefdirDirID; long pyprefdirDirID; Handle namehandle; OSErr err; if ( !diditbefore ) { if ( (namehandle=GetNamedResource('STR ', PREFFILENAME_NAME)) == NULL ) { (void)StopAlert(NOPREFNAME_ID, NULL); -->> exit(1); } it dies here __^ Is there an easy way to fix this (it looks trivial but I don't know that much Mac stuff) What is the issue here? --Jared Web: http://waffles.caltech.edu Phone: (626)395-1154 Campus Adress: Blacker Hovse, Room 31 Adress: MSC 935 Caltech Pasadena, CA 91126-0935 From just@letterror.com Tue Aug 15 20:57:08 2000 From: just@letterror.com (Just van Rossum) Date: Tue, 15 Aug 2000 20:57:08 +0100 Subject: [Pythonmac-SIG] Abnormal program termination In-Reply-To: Message-ID: At 11:44 AM -0700 15-08-2000, Jared Updike wrote: >So when I debug into PythonCore when my code calls PyMac_Initialize(); and >step through, > >static int >getpreffilefss(FSSpec *fssp) >{ > static int diditbefore=0; > static int rv = 1; > static FSSpec fss; > short prefdirRefNum; > long prefdirDirID; > long pyprefdirDirID; > Handle namehandle; > OSErr err; > > if ( !diditbefore ) { > if ( (namehandle=GetNamedResource('STR ', >PREFFILENAME_NAME)) == NULL ) { > (void)StopAlert(NOPREFNAME_ID, NULL); >-->> exit(1); > } > >it dies here __^ Is there an easy way to fix this (it looks trivial but I >don't know that much Mac stuff) What is the issue here? It means it cand find a 'STR ' resource with a name of whatever PREFFILENAME_NAME says.. You might need to include some of the MacPython resource files in your project. Just From mikel@reactivity.com Tue Aug 15 23:21:39 2000 From: mikel@reactivity.com (mikel evins) Date: Tue, 15 Aug 2000 15:21:39 -0700 Subject: [Pythonmac-SIG] SimpleHTTPServer doesn't work? Message-ID: Why does SimpleHTTPServer.test() fail on my Mac? In Python version 1.5.2 on a PowerBook G3 running MacOS9 I execute the following: import SimpleHTTPServer SimpleHTTPServer.test() The result is the following error: Traceback (innermost last): File "", line 1, in ? File "Cairagor:Programming:Python 1.5.2c1:Lib:SimpleHTTPServer.py", line 152, in test BaseHTTPServer.test(HandlerClass, ServerClass) File "Cairagor:Programming:Python 1.5.2c1:Lib:BaseHTTPServer.py", line 475, in test httpd = ServerClass(server_address, HandlerClass) File "Cairagor:Programming:Python 1.5.2c1:Lib:SocketServer.py", line 165, in __init__ self.server_bind() File "Cairagor:Programming:Python 1.5.2c1:Lib:BaseHTTPServer.py", line 97, in server_bind hostname, hostnames, hostaddrs = socket.gethostbyaddr(host) error: host not found Why? -- -- mikel evins mikel@reactivity.com From tmk@microscript.be Wed Aug 16 08:19:51 2000 From: tmk@microscript.be (tmk [microscript]) Date: Wed, 16 Aug 2000 09:19:51 +0200 Subject: [Pythonmac-SIG] socket.gethostbyaddr(socket.gethostname()) Message-ID: Yo, I'm finding that the call socket.gethostbyaddr(socket.gethostname()) (called all over the place in smtplib for example) generates an error (host not found) when the machine it's executed on doesn't have a DNS IP address reverse mapping PTR record (this record allows fo the reverse mapping from an IP address to a host name). This seems to be a too rude behavior: most machines do *not* have such a DNS record (or access to. That would be the case for a machine that's offline for example. Shouldn't it (the fully qualified hostname) default to the host IP address? This is a deal stopper. Any help would be appreciated. TIA = tmk = From jack@oratrix.nl Wed Aug 16 11:33:57 2000 From: jack@oratrix.nl (Jack Jansen) Date: Wed, 16 Aug 2000 12:33:57 +0200 Subject: [Pythonmac-SIG] Abnormal program termination In-Reply-To: Message by Just van Rossum , Tue, 15 Aug 2000 20:57:08 +0100 , Message-ID: <20000816103357.A8770303181@snelboot.oratrix.nl> > It means it cand find a 'STR ' resource with a name of whatever > PREFFILENAME_NAME says.. You might need to include some of the MacPython > resource files in your project. There's a copy of the PREFFILENAME_NAME resource in the PythonCore shared library. And the initialize entrypoint for the library is __initialize_with_resources, which should have added it to the resource file chain. But maybe that isn't correct in your debugging PythonCore, check that the settings for your debugging pythoncore are the same as for the non-debugging one (and in this case the PEF settings are probably the important one). -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From jack@oratrix.nl Wed Aug 16 11:38:27 2000 From: jack@oratrix.nl (Jack Jansen) Date: Wed, 16 Aug 2000 12:38:27 +0200 Subject: [Pythonmac-SIG] socket.gethostbyaddr(socket.gethostname()) In-Reply-To: Message by "tmk [microscript]" , Wed, 16 Aug 2000 09:19:51 +0200 , Message-ID: <20000816103827.7E0BE303181@snelboot.oratrix.nl> > Yo, > > I'm finding that the call socket.gethostbyaddr(socket.gethostname()) (called > all over the place in smtplib for example) generates an error (host not > found) when the machine it's executed on doesn't have a DNS IP address > reverse mapping PTR record (this record allows fo the reverse mapping from > an IP address to a host name). Well, the relevant internet standards speficially say that you _must_ have a PTR record for all machines. But, the fact that I get 3 messages a week from people who can't access ftp.cwi.nl shows that a lot of ISPs indeed happily ignore this:-( The solution is to add the PTR (and A, of course) record for your own machine to your hosts file. And, on smtplib: again by the standard it should pass the official name (fqdn) in the HELO command. It might be allowable, though, to pass [xx.xx.xx.xx] or so (rfc821 is a long time ago, I don't remember). -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From tmk@easynet.be Wed Aug 16 22:13:55 2000 From: tmk@easynet.be (tmk) Date: Wed, 16 Aug 2000 23:13:55 +0200 Subject: [Pythonmac-SIG] socket.gethostbyaddr(socket.gethostname()) In-Reply-To: <20000816103827.7E0BE303181@snelboot.oratrix.nl> Message-ID: > From: Jack Jansen > Date: Wed, 16 Aug 2000 12:38:27 +0200 > To: "tmk [microscript]" > Cc: Python Mac mailing list > Subject: Re: [Pythonmac-SIG] socket.gethostbyaddr(socket.gethostname()) > >> Yo, >> >> I'm finding that the call socket.gethostbyaddr(socket.gethostname()) (called >> all over the place in smtplib for example) generates an error (host not >> found) when the machine it's executed on doesn't have a DNS IP address >> reverse mapping PTR record (this record allows fo the reverse mapping from >> an IP address to a host name). > > Well, the relevant internet standards speficially say that you _must_ have a > PTR record for all machines. But, the fact that I get 3 messages a week from > people who can't access ftp.cwi.nl shows that a lot of ISPs indeed happily > ignore this:-( > Thanks for the correction Jack. Since I do have access to my DNS I could work around this "feature" :-/. > The solution is to add the PTR (and A, of course) record for your own machine > to your hosts file. I didn't know that the subset of features the Hosts file supports did include PTR record... I've dl'ed the OT FAQ version 2.3 and it seems to mention that the only record classes supported are A, CNAME and NS :-(. I'll test to see if PTR are nevertheless supported. > And, on smtplib: again by the standard it should pass the official name (fqdn) > in the HELO command. It might be allowable, though, to pass [xx.xx.xx.xx] or > so (rfc821 is a long time ago, I don't remember). I've tested this and with and most smtp server will accept happilly accept anything (e.g 'fubar'...) = tmk = > -- > Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ > Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ > www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm > > > From jack@oratrix.nl Wed Aug 16 23:17:55 2000 From: jack@oratrix.nl (Jack Jansen) Date: Thu, 17 Aug 2000 00:17:55 +0200 Subject: [Pythonmac-SIG] socket.gethostbyaddr(socket.gethostname()) In-Reply-To: Message by tmk , Wed, 16 Aug 2000 23:13:55 +0200 , Message-ID: <20000816221800.210BDE266F@oratrix.oratrix.nl> Recently, tmk said: > > The solution is to add the PTR (and A, of course) record for your own machi > ne > > to your hosts file. > > > I didn't know that the subset of features the Hosts file supports did > include PTR record... I've dl'ed the OT FAQ version 2.3 and it seems to > mention that the only record classes supported are A, CNAME and NS :-(. I'll > test to see if PTR are nevertheless supported. Hmm, you could be right there:-( > I've tested this and with and most smtp server will accept happilly accept > anything (e.g 'fubar'...) .. but with a smtp server run by a spam-conscious system manager you have a good chance that your mail is flagged as spam. Postfix, which is getting more and more popular, is one smtp server that makes this almost trivial to enable, and it saves _lots_ of spam (or at least flags it to the end-recipient). -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From jwblist@olympus.net Thu Aug 17 07:24:53 2000 From: jwblist@olympus.net (John W Baxter) Date: Wed, 16 Aug 2000 23:24:53 -0700 Subject: [Pythonmac-SIG] socket.gethostbyaddr(socket.gethostname()) In-Reply-To: References: Message-ID: At 23:13 +0200 8/16/2000, tmk wrote: >> From: Jack Jansen > > >> And, on smtplib: again by the standard it should pass the official name >>(fqdn) >> in the HELO command. It might be allowable, though, to pass [xx.xx.xx.xx] or >> so (rfc821 is a long time ago, I don't remember). > >I've tested this and with and most smtp server will accept happilly accept >anything (e.g 'fubar'...) "happily" may be too strong...grudgingly is a better description of what Exim--for one--does, since it logs a complaint for any form other than fqdn (matching the observed IP as often configured). --John -- John Baxter jwblist@olympus.net Port Ludlow, WA, USA From rtrocca@libero.it Thu Aug 17 14:58:16 2000 From: rtrocca@libero.it (Riccardo Trocca) Date: Thu, 17 Aug 2000 15:58:16 +0200 Subject: [Pythonmac-SIG] Making Imaging 1.1 work with MacPython Message-ID: Hello, I'm trying to make Imaging 1.1 work with MacPython. Anl older version of this library is included with the standard MacPython distribution (1.0bx). I'm able to compile everything and the coretest app works. But when I try to display on an image from Python it complains about error -8 (Bad config in decoder) or, in case of GIF images it chrashes everything and MacPython quits. Any hints? Riccardo Trocca From lmeyn@mail.arc.nasa.gov Thu Aug 17 16:08:23 2000 From: lmeyn@mail.arc.nasa.gov (Larry Meyn) Date: Thu, 17 Aug 2000 08:08:23 -0700 Subject: [Pythonmac-SIG] EditPythonPrefs.py in Release 1.6a2 In-Reply-To: <20000816160709.0FE921D15E@dinsdale.python.org> References: <20000816160709.0FE921D15E@dinsdale.python.org> Message-ID: --============_-1245597575==_ma============ Content-Type: text/plain; charset="us-ascii" ; format="flowed" I had a few problems running EditPythonPrefs in the 1.6a2 release. I made the following changes "nonavservices" was changed to "nonavservice" and "OD_HELP_ITEM = 22" was changed to "OD_HELP_ITEM = 21" to match what seemed to be the correct dialog item number. The section of code changed is given below. # Map dialog item numbers to option names (and the reverse) opt_dialog_map = [ None, "inspect", "verbose", "optimize", "unbuffered", "debugging", "keepopen", "keeperror", "nointopt", "noargs", "delayconsole", None, None, None, None, None, None, None, None, # 11-18 are different "tabwarn", "nosite", None, "nonavservice"] opt_dialog_dict = {} for i in range(len(opt_dialog_map)): if opt_dialog_map[i]: opt_dialog_dict[opt_dialog_map[i]] = i # 1 thru 10 are the options # The GUSI creator/type and delay-console OD_CREATOR_ITEM = 11 OD_TYPE_ITEM = 12 OD_OK_ITEM = 13 OD_CANCEL_ITEM = 14 OD_HELP_ITEM = 21 -- ------------------------------------------------------------------ Larry Meyn Aerospace Operations Modeling Office M/S 210-10 Phone: (650) 604-5038 NASA Ames Research Center FAX: (650) 604-0222 Moffett Field, CA 94035-1000 email: lmeyn@mail.arc.nasa.gov ------------------------------------------------------------------ --============_-1245597575==_ma============ Content-Type: text/html; charset="us-ascii" EditPythonPrefs.py in Release 1.6a2
I had a few problems running EditPythonPrefs in the 1.6a2 release.  I made the following changes  "nonavservices" was changed to "nonavservice"  and  "OD_HELP_ITEM = 22" was changed to "OD_HELP_ITEM = 21" to match what seemed to be the correct dialog item number.  The section of code changed is given below.




# Map dialog item numbers to option names (and the reverse)
opt_dialog_map = [
   None,
   "inspect",
      "verbose",
      "optimize",
     "unbuffered",
   "debugging",
    "keepopen",
     "keeperror",
    "nointopt",
     "noargs",
       "delayconsole",
None, None, None, None, None, None, None, None, # 11-18 are different
   "tabwarn",
      "nosite",
       None,
        "nonavservice"]
opt_dialog_dict = {}
for i in range(len(opt_dialog_map)):
if opt_dialog_map[i]:
           opt_dialog_dict[opt_dialog_map[i]] = i
# 1 thru 10 are the options
# The GUSI creator/type and delay-console
OD_CREATOR_ITEM = 11
OD_TYPE_ITEM = 12
OD_OK_ITEM = 13
OD_CANCEL_ITEM = 14
OD_HELP_ITEM = 21


--
------------------------------------------------------------------
Larry Meyn
Aerospace Operations Modeling Office

M/S 210-10                         Phone:  (650) 604-5038
NASA Ames Research Center          FAX:    (650) 604-0222
Moffett Field, CA 94035-1000       email:  lmeyn@mail.arc.nasa.gov
------------------------------------------------------------------
--============_-1245597575==_ma============-- From lmeyn@mail.arc.nasa.gov Thu Aug 17 17:52:30 2000 From: lmeyn@mail.arc.nasa.gov (Larry Meyn) Date: Thu, 17 Aug 2000 09:52:30 -0700 Subject: [Pythonmac-SIG] More on EditPythonPrefs.py Message-ID: Another EditPythonPrefs anomaly in the 1.6a2 release. The default file creator and type gets swapped from what is specified in the dialog. I changed the dialog resource, but a code change would probably be cleaner. (By the way, in version 1.5.2c1, the dialog defaults are ignored and the defaults are always 'Pyth' and 'TEXT'.) -- ------------------------------------------------------------------ Larry Meyn Aerospace Operations Modeling Office M/S 210-10 Phone: (650) 604-5038 NASA Ames Research Center FAX: (650) 604-0222 Moffett Field, CA 94035-1000 email: lmeyn@mail.arc.nasa.gov ------------------------------------------------------------------ From lmeyn@mail.arc.nasa.gov Thu Aug 17 18:09:49 2000 From: lmeyn@mail.arc.nasa.gov (Larry Meyn) Date: Thu, 17 Aug 2000 10:09:49 -0700 Subject: [Pythonmac-SIG] More on EditPythonPrefs.py addendum Message-ID: I didn't check that my change took. It turns out that the dialog defaults are ignored in version 1.6a2 also. The type is always set to 'ttxt' and the creator to 'TEXT', which confuses applications that want a file with type = 'TEXT'. -- ------------------------------------------------------------------ Larry Meyn Aerospace Operations Modeling Office M/S 210-10 Phone: (650) 604-5038 NASA Ames Research Center FAX: (650) 604-0222 Moffett Field, CA 94035-1000 email: lmeyn@mail.arc.nasa.gov ------------------------------------------------------------------ From jack@oratrix.nl Thu Aug 17 21:05:29 2000 From: jack@oratrix.nl (Jack Jansen) Date: Thu, 17 Aug 2000 22:05:29 +0200 Subject: [Pythonmac-SIG] More on EditPythonPrefs.py addendum In-Reply-To: Message by Larry Meyn , Thu, 17 Aug 2000 10:09:49 -0700 , Message-ID: <20000817200534.26169E2670@oratrix.oratrix.nl> Recently, Larry Meyn said: > I didn't check that my change took. It turns out that the dialog defaults ar > e ignored in version 1.6a2 also. The type is always set to 'ttxt' and the cre > ator to 'TEXT', which confuses applications that want a file with type = 'TEX > T'. Oops, you're right: this debug code was still in there. I've just fixed it (in the CVS tree). -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From jaredu@its.caltech.edu Sat Aug 19 02:20:51 2000 From: jaredu@its.caltech.edu (Jared Updike) Date: Fri, 18 Aug 2000 18:20:51 -0700 (PDT) Subject: [Pythonmac-SIG] pythonpath.r Message-ID: It looks like the runtime problems I was having before were caused when the code in PyMac_Initialize(); tried to get some resources that weren't there, and the corresponding resources (I think) are in pythonpath.r The problem that occurs now is that when I add pythonpath.r to my project, Codewarrior reports that it cant find 'MW Rez'. I tried adding the path to the Code Warrior:Plugins:Compilers but nothing changed. I don't completely understand what I need to do to get these resources added, or if I need to add them to PythonCodePPC, or even how to get that to work. I may need to somehow compile pythonpath.r and then add the outputted file to my project or something, but what, I don't know. Any help here would be appreciated. --Jared Web: http://waffles.caltech.edu Phone: (626)395-1154 Campus Adress: Blacker Hovse, Room 31 Adress: MSC 935 Caltech Pasadena, CA 91126-0935 From bob@heeter.net Sun Aug 20 04:08:46 2000 From: bob@heeter.net (Bob Heeter) Date: Sat, 19 Aug 2000 20:08:46 -0700 Subject: [Pythonmac-SIG] PythonCGISlave conflict with SMTPlib? (MacOS 9, Pers. Web Sharing) In-Reply-To: References: <200003261936.VAA22323@leidschenveen.denhaag.dataweb.net> Message-ID: Dear Python Gurus - I've been lurking on the list for several months while learning python and building up some hobby-scale code. I was very happy when the PythonCGIslave came out, and I've been successfully running CGI applets under MacOS 9 and Personal Web Sharing. I want to say up front that working with Python has been a lot more fun than any other programming I've done (I'm a physicist by trade and do a fair amount of software work for my job), but I've run into a problem that has got me stumped. I had the idea that it would be nice to upgrade the exception handler in my CGI so that it would email me some kind of notification whenever a user ran into a bug in the CGI (in addition to logging any exceptions (bugs) to the errors file). This would be nice because (a) I want to fix any bugs promptly, but (b) I don't want to have to check on the errors file all the time. I'd used the smtplib calls frequently in some of my other code, but when I tried to use them from within the CGI applet, it caused the CGI to freeze up whenever it tries to send the email. I had to go and force-quit the CGI. The CGI works just fine when I comment out the SMTP calls (which go to an smtp server on the same machine as the web server). I've tried putting the smtplib calling code in an exception handler inside my CGI, putting it in the body of the CGI, putting it in the exception handler inside PythonCGIslave, and (as a test) putting it in the main code of the PythonCGIslave cgihandler, and even putting it in the __init__ function of the PythonCGIslave class, but the CGI applet still crashes every time. Does anyone have any ideas how I can get past this problem? Is there something about the way the web server calls the cgi applet that prevents the SMTP lib calls from working? The only thing I can think of is to write a separate "monitor" applet that just watches the CGI's .errors file and emails me the contents whenever something is written to the file, but that is an ugly solution. I'd really like to have the email call inside the CGI code, and if possible I'd like to solve the problem in a platform-independent way. Thanks in advance for everyone's wisdom. I hope to be able to contribute back to the list as I get more up to speed, but for now it looks like I'm mainly a consumer of advice rather than a producer. :) -- Bob Heeter Bob Heeter Livermore, California From just@letterror.com Sun Aug 20 10:28:04 2000 From: just@letterror.com (Just van Rossum) Date: Sun, 20 Aug 2000 10:28:04 +0100 Subject: [Pythonmac-SIG] PythonCGISlave conflict with SMTPlib? (MacOS 9, Pers. Web Sharing) In-Reply-To: References: <200003261936.VAA22323@leidschenveen.denhaag.dataweb.net> Message-ID: Hm, interesting... MacPython is not very good at doing socket stuff on one machine (ie. smtp client as well as server on the same machine), but the current default settings of PythonCGISlave probably makes it worse than neccesary. What you could try to do as an experiment is wrap you smtp call in something like this: import MacOS, Events old = MacOS.SchedParams(1, Events.osMask, 1, 0.25, 0.25) try: ...smtp stuff... finally: apply(MacOS.SetSchedParams, old) (I'm not 100% sure whether these are the best settings, though.) There's at least one gotcha: I think this will only work well if the PythonCGISlave app is in the background. Jack: in PyMac_Yield(), maxsleep is set to 0 when in the Python app is in the foreground; I think this might explain some of the AE lockups or slowdowns people have been experiencing. Would it be an idea to simply set it to 1 when in the foreground? And why isn't there fg_yield in SchedParams? Just At 8:08 PM -0700 19-08-2000, Bob Heeter wrote: >Dear Python Gurus - > >I've been lurking on the list for several months while learning python >and building up some hobby-scale code. I was very happy when the >PythonCGIslave came out, and I've been successfully running CGI applets >under MacOS 9 and Personal Web Sharing. I want to say up front that >working with Python has been a lot more fun than any other programming >I've done (I'm a physicist by trade and do a fair amount of software >work for my job), but I've run into a problem that has got me stumped. > >I had the idea that it would be nice to upgrade the exception >handler in my CGI so that it would email me some kind of notification >whenever a user ran into a bug in the CGI (in addition to logging any >exceptions (bugs) to the errors file). This would be nice because >(a) I want to fix any bugs promptly, but (b) I don't want to have to >check on the errors file all the time. I'd used the smtplib calls >frequently in some of my other code, but when I tried to use them >from within the CGI applet, it caused the CGI to freeze up whenever >it tries to send the email. I had to go and force-quit the CGI. >The CGI works just fine when I comment out the SMTP calls (which go >to an smtp server on the same machine as the web server). >I've tried putting the smtplib calling code in an exception handler >inside my CGI, putting it in the body of the CGI, putting it >in the exception handler inside PythonCGIslave, and (as a test) >putting it in the main code of the PythonCGIslave cgihandler, and even >putting it in the __init__ function of the PythonCGIslave class, >but the CGI applet still crashes every time. > >Does anyone have any ideas how I can get past this problem? >Is there something about the way the web server calls the cgi applet >that prevents the SMTP lib calls from working? > >The only thing I can think of is to write a separate "monitor" >applet that just watches the CGI's .errors file and emails me >the contents whenever something is written to the file, but that >is an ugly solution. I'd really like to have the email call >inside the CGI code, and if possible I'd like to solve the problem >in a platform-independent way. > >Thanks in advance for everyone's wisdom. I hope to be able to >contribute back to the list as I get more up to speed, but for now >it looks like I'm mainly a consumer of advice rather than a producer. :) > >-- Bob Heeter > >Bob Heeter >Livermore, California > >_______________________________________________ >Pythonmac-SIG maillist - Pythonmac-SIG@python.org >http://www.python.org/mailman/listinfo/pythonmac-sig From bob@heeter.org Sun Aug 20 17:58:51 2000 From: bob@heeter.org (Bob Heeter) Date: Sun, 20 Aug 2000 09:58:51 -0700 Subject: [Pythonmac-SIG] PythonCGISlave conflict with SMTPlib? (MacOS 9, Pers. Web Sharing) In-Reply-To: References: <200003261936.VAA22323@leidschenveen.denhaag.dataweb.net> Message-ID: Hi again - Many, many thanks, Just, for the speedy response. That solution works like a charm, except the call to apply uses MacOS.SchedParams and not MacOS.SetSchedParams (at least for me - I'm running Python 1.5.2c1). I've been running my CGI applets in the background, so that was no problem. FWIW, in addition to putting this email notification bit into PythonCGIslave's exception-handling code, I've also added some code so that, when a PythonCGISlave-based CGI applet is launched in LONG_RUNNING mode, it loads in some persistent data from a file, and then periodically reloads the data according to a programmable update schedule. The CGI can then use the data without having to reload it every time it gets asked to handle an event, which speeds up the response (on my poor sluggish server at least). I've also written a utility function for easily sending email attachments. If anyone's interested I'd be happy to share, but being relatively new to Python I assume these sorts of things are old hat to the experts here? -- Bob Bob Heeter Livermore, California From just@letterror.com Sun Aug 20 19:22:42 2000 From: just@letterror.com (Just van Rossum) Date: Sun, 20 Aug 2000 19:22:42 +0100 Subject: [Pythonmac-SIG] PythonCGISlave conflict with SMTPlib? (MacOS 9, Pers. Web Sharing) In-Reply-To: References: <200003261936.VAA22323@leidschenveen.denhaag.dataweb.net> Message-ID: At 9:58 AM -0700 20-08-2000, Bob Heeter wrote: >Hi again - > >Many, many thanks, Just, for the speedy response. That solution works like >a charm, except the call to apply uses MacOS.SchedParams and not >MacOS.SetSchedParams (at least for me - I'm running Python 1.5.2c1). Oops, sorry, I thought I had corrected that before I sent it... >I've been running my CGI applets in the background, so that was no problem. It's good to know that it works! >FWIW, in addition to putting this email notification bit into PythonCGIslave's >exception-handling code, (It's wiser to put your notifier in your CGI code, or write a module that does it for you, since it's very application specific: I don't think this stuff belongs in PythonCGISlave.) >I've also added some code so that, when >a PythonCGISlave-based CGI applet is launched in LONG_RUNNING mode, >it loads in some persistent data from a file, and then periodically >reloads the data according to a programmable update schedule. >The CGI can then use the data without having to reload it every time it >gets asked to handle an event, which speeds up the response (on my poor >sluggish server at least). I've also written a utility function for >easily sending email attachments. Same comment: you could do the same in a module (and modules don't get reloaded at each request, so you can store semi-persistent data there). Just From bob@heeter.org Mon Aug 21 00:10:32 2000 From: bob@heeter.org (Bob Heeter) Date: Sun, 20 Aug 2000 16:10:32 -0700 Subject: [Pythonmac-SIG] PythonCGISlave conflict with SMTPlib? (MacOS 9, Pers. Web Sharing) In-Reply-To: References: <200003261936.VAA22323@leidschenveen.denhaag.dataweb.net> Message-ID: At 7:22 PM +0100 2000/08/20, Just van Rossum wrote: > >I've been running my CGI applets in the background, so that was no problem. > >It's good to know that it works! :) > >FWIW, in addition to putting this email notification bit into >PythonCGIslave's > >exception-handling code, > >(It's wiser to put your notifier in your CGI code, or write a module that >does it for you, since it's very application specific: I don't think this >stuff belongs in PythonCGISlave.) I had just come to that conclusion after remembering that I'd originally wanted to put the email notification in my CGI code. I had resorted to trying to put it in PythonCGISlave when it didn't work in my CGI, and then (after spending hours trying to figure out why it still didn't work) I'd forgotten what I was originally doing... :) > >I've also added some code so that, when > >a PythonCGISlave-based CGI applet is launched in LONG_RUNNING mode, > >it loads in some persistent data from a file, and then periodically > >reloads the data according to a programmable update schedule. > >The CGI can then use the data without having to reload it every time it > >gets asked to handle an event, which speeds up the response (on my poor > >sluggish server at least). I've also written a utility function for > >easily sending email attachments. > >Same comment: you could do the same in a module (and modules don't get >reloaded at each request, so you can store semi-persistent data there). Ahh... but that requires letting my brain get blown away (again) by the subtle powers of Python! I had no idea I could store data in a module attribute without having it get reloaded on me every time the module was imported. :) Habits from the bad old days of C, C++, etc. die hard... :) That was an excellent suggestion. Everything now works beautifully here. For those who are still watching, here is what worked: In the CGI code: import cgiData [...] myData = cgiData.theData myData = cgiData.reload(myData) # reloads my persistent data if necessary In the cgiData module: theData = myDataClass() # default instance of my data object def timeToRefresh(theData): # [...] def reload(theData): if ( notloaded(theData) or timeToRefresh(theData) ): theData = [ do a bunch of stuff ] return theData N.B. I tried this (seemingly more intuitive) version, but without success: import data_module [...] cgi_data = data_module.getdata(mydata) and then in data_module: MYDATA = 0 def getdata(): if ( (not MYDATA) or time_to_update() ): # need to load database MYDATA = get_cgi_data() else: return MYDATA Whenever I tried to run this, I got a Name Error exception on MYDATA, at the if statement in the getdata function. I was under the impression that the function would be aware of the global variable in the module, but that doesn't seem to be the case. In the first version (above) I just passed in the data attribute of the module explicitly. Now that I've got the first version working I kind of like it, but it wasn't the sort of solution that popped into mind immediately. - YAHPP (Yet Another Happy Python Programmer!) Bob Heeter Livermore, California From just@letterror.com Mon Aug 21 09:19:29 2000 From: just@letterror.com (Just van Rossum) Date: Mon, 21 Aug 2000 09:19:29 +0100 Subject: [Pythonmac-SIG] PythonCGISlave conflict with SMTPlib? (MacOS 9, Pers. Web Sharing) In-Reply-To: References: <200003261936.VAA22323@leidschenveen.denhaag.dataweb.net> Message-ID: At 4:10 PM -0700 20-08-2000, Bob Heeter wrote: >and then in data_module: > > MYDATA = 0 > > def getdata(): > if ( (not MYDATA) or time_to_update() ): # need to load >database > MYDATA = get_cgi_data() > else: > return MYDATA > >Whenever I tried to run this, I got a Name Error exception on MYDATA, >at the if statement in the getdata function. I was under the impression >that the function would be aware of the global variable in the module, >but that doesn't seem to be the case. [ ... ] Python's scoping rule (short version ;-): "a variable is local to a function if it is assgined to *somewhere* in the function. Otherwise it's global." So your MYDATA = ... line makes MYDATA local to the function. You need to decalre MYDATA global like so: MYDATA = 0 def getdata(): global MYDATA if ( (not MYDATA) or time_to_update() ): # need to load database MYDATA = get_cgi_data() else: return MYDATA Just From jack@oratrix.nl Mon Aug 21 09:19:55 2000 From: jack@oratrix.nl (Jack Jansen) Date: Mon, 21 Aug 2000 10:19:55 +0200 Subject: [Pythonmac-SIG] PythonCGISlave conflict with SMTPlib? (MacOS 9, Pers. Web Sharing) In-Reply-To: Message by Just van Rossum , Sun, 20 Aug 2000 10:28:04 +0100 , Message-ID: <20000821081956.D3511303181@snelboot.oratrix.nl> > import MacOS, Events > old = MacOS.SchedParams(1, Events.osMask, 1, 0.25, 0.25) > try: > ...smtp stuff... > finally: > apply(MacOS.SetSchedParams, old) > > (I'm not 100% sure whether these are the best settings, though.) > > There's at least one gotcha: I think this will only work well if the > PythonCGISlave app is in the background. Jack: in PyMac_Yield(), maxsleep > is set to 0 when in the Python app is in the foreground; I think this might > explain some of the AE lockups or slowdowns people have been experiencing. > Would it be an idea to simply set it to 1 when in the foreground? And why > isn't there fg_yield in SchedParams? You're right, but setting the "max yield" to anything other than zero for foreground operation will result in a serious slowdown. At least, it did when I wrote the new Yield and SchedParams and stuff (around MacOS 8). The event handling code inside MacOS seems to have changed drastically, so it might be worth a try. Could you try this mod and compare Pystone results? A better option is to make a distinction based on why we are getting to PyMac_Yield. If we're there because we are waiting for I/O to complete (or for an AppleEvent to come in) we could pass a nonzero maxsleep, but if the call comes from the once-in-a-while check from the main python loop we should pass 0. I tried to do something like this, but apparently it doesn't work. If someone feels the urge to look into this and suggest fixes: please do so! -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From jack@oratrix.nl Mon Aug 21 09:56:29 2000 From: jack@oratrix.nl (Jack Jansen) Date: Mon, 21 Aug 2000 10:56:29 +0200 Subject: [Pythonmac-SIG] pythonpath.r In-Reply-To: Message by Jared Updike , Fri, 18 Aug 2000 18:20:51 -0700 (PDT) , Message-ID: <20000821085629.F0C74303181@snelboot.oratrix.nl> > > It looks like the runtime problems I was having before were caused when > the code in PyMac_Initialize(); tried to get some resources that weren't > there, and the corresponding resources (I think) are in pythonpath.r > The problem that occurs now is that when I add pythonpath.r to my project, > Codewarrior reports that it cant find 'MW Rez'. I haven't used the debug targets for ages, so it could be that "MW Rez" is the wrong name (the CodeWarrior rez compiler changed names at some point in the past). Check what is in the settings for the non-debug target and copy that. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From smith@oe.fau.edu Mon Aug 21 14:32:26 2000 From: smith@oe.fau.edu (Samuel Smith) Date: Mon, 21 Aug 2000 09:32:26 -0400 Subject: [Pythonmac-SIG] PythonCGISlave conflict with SMTPlib? (MacOS 9, Pers. Web Sharing) In-Reply-To: References: <200003261936.VAA22323@leidschenveen.denhaag.dataweb.net> Message-ID: I have the same problem when the email server is the same as the web server but it works fine if I route the email thru my isp's server and then back to the email server running on the same machine as my web server. I use eims 3.0 and personal web sharing 1.5 ox9.04 >Dear Python Gurus - > >I've been lurking on the list for several months while learning python >and building up some hobby-scale code. I was very happy when the >PythonCGIslave came out, and I've been successfully running CGI applets >under MacOS 9 and Personal Web Sharing. I want to say up front that >working with Python has been a lot more fun than any other programming >I've done (I'm a physicist by trade and do a fair amount of software >work for my job), but I've run into a problem that has got me stumped. > >I had the idea that it would be nice to upgrade the exception >handler in my CGI so that it would email me some kind of notification >whenever a user ran into a bug in the CGI (in addition to logging any >exceptions (bugs) to the errors file). This would be nice because >(a) I want to fix any bugs promptly, but (b) I don't want to have to >check on the errors file all the time. I'd used the smtplib calls >frequently in some of my other code, but when I tried to use them >from within the CGI applet, it caused the CGI to freeze up whenever >it tries to send the email. I had to go and force-quit the CGI. >The CGI works just fine when I comment out the SMTP calls (which go >to an smtp server on the same machine as the web server). >I've tried putting the smtplib calling code in an exception handler >inside my CGI, putting it in the body of the CGI, putting it >in the exception handler inside PythonCGIslave, and (as a test) >putting it in the main code of the PythonCGIslave cgihandler, and even >putting it in the __init__ function of the PythonCGIslave class, >but the CGI applet still crashes every time. > >Does anyone have any ideas how I can get past this problem? >Is there something about the way the web server calls the cgi applet >that prevents the SMTP lib calls from working? > >The only thing I can think of is to write a separate "monitor" >applet that just watches the CGI's .errors file and emails me >the contents whenever something is written to the file, but that >is an ugly solution. I'd really like to have the email call >inside the CGI code, and if possible I'd like to solve the problem >in a platform-independent way. > >Thanks in advance for everyone's wisdom. I hope to be able to >contribute back to the list as I get more up to speed, but for now >it looks like I'm mainly a consumer of advice rather than a producer. :) > >-- Bob Heeter > >Bob Heeter >Livermore, California > >_______________________________________________ >Pythonmac-SIG maillist - Pythonmac-SIG@python.org >http://www.python.org/mailman/listinfo/pythonmac-sig -- ********************************** Samuel M. Smith Ph.D. Professor Director Advanced Marine Systems Lab **************(Dania SeaTech Building)*********************** Institute for Ocean and Systems Engineering Florida Atlantic University Rm. 225 B, SeaTech Bldg. 101 North Beach Road, Dania, FL 33004 (voice) 954-924-7232 (secretary Paula) 954-924-7230 (fax) 954-924-7233 (mobile) 561-251-2114 (email) smith@oe.fau.edu (web) http://www.oe.fau.edu From tom@othermedia.com Thu Aug 24 14:50:44 2000 From: tom@othermedia.com (othertom POP) Date: Thu, 24 Aug 2000 14:50:44 +0100 Subject: [Pythonmac-SIG] tkinter Message-ID: does tkinter work with macpython? when I import Tkinter, it says module not found thanks tom From Roman.Fischer@teleweb.at Thu Aug 24 18:43:03 2000 From: Roman.Fischer@teleweb.at (Ing. Roman Fischer) Date: Thu, 24 Aug 2000 19:43:03 +0200 Subject: [Pythonmac-SIG] tkinter Message-ID: I am also a newbie to pyhton and installed macpython a few days before. I had the same problems. I did 3 things: 1. There is a system-extension called _tkinter.ppc.slb which I moved to the system-extensions folder. 2. I started EditPythonPrefs-programm and included the lib-tk (the big main-field of that displays the referenced lib is editable!) 3. I reinstalled macpython with the "custom install" way. There are Tk options. Then restarted my mac. I do not know what did the magic but now tkinter seems to work now! Hope that helps Roman Fischer From clwash@dragonsguild.com Thu Aug 24 19:00:19 2000 From: clwash@dragonsguild.com (C.L) Date: Thu, 24 Aug 2000 13:00:19 -0500 Subject: [Pythonmac-SIG] tkinter References: Message-ID: <010701c00df5$2afa9df0$b3670ea9@mmm.com> I too am a Python newbie, but what I don't understand is why this problem is not fixed in the 1.6 beta...? I downloaded 1.6b that in hopes it would fix the problem, but it did not. ----- Original Message ----- From: "Ing. Roman Fischer" To: ; Sent: Thursday, August 24, 2000 12:43 PM Subject: Re: [Pythonmac-SIG] tkinter > I am also a newbie to pyhton and installed macpython a few days before. I > had the same problems. I did 3 things: > > 1. There is a system-extension called _tkinter.ppc.slb which I moved to the > system-extensions folder. > > 2. I started EditPythonPrefs-programm and included the lib-tk (the big > main-field of that displays the referenced lib is editable!) > > 3. I reinstalled macpython with the "custom install" way. There are Tk > options. Then restarted my mac. > > I do not know what did the magic but now tkinter seems to work now! > > Hope that helps > > Roman Fischer > > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG@python.org > http://www.python.org/mailman/listinfo/pythonmac-sig > > From kantel@mpiwg-berlin.mpg.de Thu Aug 24 19:09:44 2000 From: kantel@mpiwg-berlin.mpg.de (=?iso-8859-1?Q?J=F6rg?= Kantel) Date: Thu, 24 Aug 2000 20:09:44 +0200 Subject: [Pythonmac-SIG] tkinter In-Reply-To: References: Message-ID: Once again: I wrote a little How To about that problem and published at on my weblog - one in english at and one in german at . (The english version with a little help from Russell E. Owen.) HTH J"org -- http://www.kantel.de/ # http://homepage.mac.com/jkantel/homepage.html joerg@kantel.de # jkantel@mac.com visit: http://www.rollberg.de/ - die WebSite fuer unmoegliche Nachrichten und http://DerSchockwellenreiter.editthispage.com, mein Web-Tagebuch in Manila http://www.die-herforder.de - linke Politik online - nur im Internet From dma@andrew.cmu.edu Fri Aug 25 16:44:05 2000 From: dma@andrew.cmu.edu (David Andersen) Date: Fri, 25 Aug 2000 11:44:05 -0400 Subject: [Pythonmac-SIG] Multi-threaded extension ? Message-ID: <836204390.967203845@DAWSON.WV.CC.CMU.EDU> I'm looking at writing a multi-threaded extension to Pythonmac, and my first question is "is this doable at all?" Does Python call YieldToAnyThread? Do I need to work with 1.6 as opposed to 1.5? From jack@oratrix.nl Fri Aug 25 21:42:22 2000 From: jack@oratrix.nl (Jack Jansen) Date: Fri, 25 Aug 2000 22:42:22 +0200 Subject: [Pythonmac-SIG] Multi-threaded extension ? In-Reply-To: Message by David Andersen , Fri, 25 Aug 2000 11:44:05 -0400 , <836204390.967203845@DAWSON.WV.CC.CMU.EDU> Message-ID: <20000825204227.DD2D4D71F9@oratrix.oratrix.nl> Recently, David Andersen said: > > I'm looking at writing a multi-threaded extension to Pythonmac, and my > first question is "is this doable at all?" Does Python call > YieldToAnyThread? Do I need to work with 1.6 as opposed to 1.5? Python 1.6a2 has multithreading. It uses the GUSI pthreads implementation, but as that is based on macos threads it does call YieldToAnyThread at the right times. But, as it doesn't know about your thread you may well starve your thread (although your extension module could of course also call YieldToAnyThread). And, of course, you're on your own if you need to do I/O in your thread. And you can't use Python in it. And, of course, if you can live with pthreads then you can use that and have your thread be a first class citizen. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From p.agapow@ic.ac.uk Tue Aug 29 14:53:39 2000 From: p.agapow@ic.ac.uk (Paul-Michael Agapow) Date: Tue, 29 Aug 2000 14:53:39 +0100 Subject: [Pythonmac-SIG] Pythondoc on the Mac Message-ID: Has anyone got Pythondoc working on a Macintosh? So far, it's defeated my admittedly superficial Python knowledge (I'm not even sure how you run a package on the interpreter) and it sure would be nice to have a decent documenting tool ... p-m -- Paul-Michael Agapow (p.agapow@ic.ac.uk), Dept. Biology, Imperial College From stephenm@humongous.com Thu Aug 31 00:59:00 2000 From: stephenm@humongous.com (Magladry, Stephen) Date: Wed, 30 Aug 2000 16:59:00 -0700 Subject: [Pythonmac-SIG] Doctor, Doctor, It hurts when I do this Message-ID: <3124AB5C4D11D31187DC005004185D1B4CD36B@BIGPIG> I just started using Python a few days ago and came across something you don't want to do. I was building an extension. Being it was my first, I started out with the starter project posted in April by Louis Pecora (BTW, thanks). For one reason or other, it wasn't working. I can't remember quite what was wrong, but something was. So, I started fiddling with stuff to see if I could get things to work. One thing I did was to merge the PythonCorePPC lib with my extension. This leads to the title of the e-mail and the answer is, "DON"T DO THAT!" I finally got the test extension functioning, but after seeing that everything was working and quitting the interpreter or the IDE, I was unable to start up anything associated with Python. No IDE, no interpreter, no EditPythonPrefs, no ConfigurePhython, even after a restart. The only workaround I found was to trash the Python prefs folder and reinstall Python. Something had to be wrong. So I started to unroll the changes that I had done. Low and behold, when I unrolled the merging of the PythonCorePPC lib, I could quit and restart the IDE without a problem. So the moral of the story is, "DO NOT merge the PythonCorePPC lib in with your extension. You will hate yourself for it." From jaredu@its.caltech.edu Thu Aug 31 02:43:48 2000 From: jaredu@its.caltech.edu (Jared Updike) Date: Wed, 30 Aug 2000 18:43:48 -0700 (PDT) Subject: [Pythonmac-SIG] Embedding Python w/o SIOUX popping up Message-ID: I am embedding Python in a Code Resource that loads as an extension to the program Igor. My extension loads the PythonCore Shared Library. When I call my command from the Igor command window and the code in my extension calls PyMac_Initialize() a SIOX window pops up and another apple menu is added at the top of the screen. There is porbably some way to use the funcitonality of PythonCode without loading the Window/menubar, and if there is, I would love any advice anyone may have on this situation. Thanks. --Jared Web: http://waffles.caltech.edu Phone: (626)395-1154 Campus Adress: Blacker Hovse, Room 31 Adress: MSC 935 Caltech Pasadena, CA 91126-0935 From etienne@alias.it Thu Aug 31 09:30:45 2000 From: etienne@alias.it (Etienne Antoniutti Di Muro) Date: Thu, 31 Aug 2000 10:30:45 +0200 Subject: [Pythonmac-SIG] Distributing Python Applications References: <20000829160125.F3E841D15C@dinsdale.python.org> Message-ID: <39AE17B5.41EB9901@alias.it> List members, hello there! :-) I'm interested in shipping an application. MyApp usese two technologies: Python and C++. I've built some modules (MyMods.py) for the Python side of MyApp, that work along with the standard python modules. MyApp C++ side uses those modules quite like a shared library (intensive use of embedding/extending python), having PythonCore linked to the code and initializing the Python interpreter at startup. Well the *BIG* deal is: I would like to ship MyApp to an average Mac User, hiding the python technology throughout the whole use of MyApp. This mostly deals with: installation of PythonCore & base Python Modules & managing PythonPrefs. My Idea is: 1- Python is alredy present on the Mac that will host MyApp (do I detect this just reading "Python Preferences", if any, in the System Folder??): no problem, I will add the path to MyMods.py to python prefs. 2- Python is not present on MyApp User Mac:I need to install PythonCore+basic Modules+MyMods.py +write python preferences. step 1: MyApp Installer will copy python essentials onto the User HD, step 2: How does MyApp Installer set up Python Preferences (using whether C++ or Python), before PythonCore is properly initialized in its new location? question: Should I compile any of python essential modules (= generate '.pyc' files) for the specific Mac, before the first run?? step "user friendly": Into the Macintosh Word a user feels free to move around his HD folders and application, keeping them working in any location. This implies a big work "behind the scenes" to keep track of paths in all that moving. How to let MyApp do this for me and MyApp User?? I've always in mind my first sperimentation with python: after every move of PYTHON HOME, nothing worked until PythonPrefs were correctly updated . How to avoid this boring chore? That's it!! Any suggestion ??? thanx etienne -- it's time to leave this town it's time to steal away let's go get lost anywhere in the U.S.A. (RHCP) From jack@oratrix.nl Thu Aug 31 09:43:30 2000 From: jack@oratrix.nl (Jack Jansen) Date: Thu, 31 Aug 2000 10:43:30 +0200 Subject: [Pythonmac-SIG] Embedding Python w/o SIOUX popping up In-Reply-To: Message by Jared Updike , Wed, 30 Aug 2000 18:43:48 -0700 (PDT) , Message-ID: <20000831084330.D3FFF303181@snelboot.oratrix.nl> > I am embedding Python in a Code Resource that loads as an extension to the > program Igor. My extension loads the PythonCore Shared Library. When I > call my command from the Igor command window and the code in my extension > calls PyMac_Initialize() a SIOX window pops up and another apple menu is > added at the top of the screen. There is porbably some way to use the > funcitonality of PythonCode without loading the Window/menubar, and if > there is, I would love any advice anyone may have on this > situation. Thanks. Your application needs python preferences resources (a "Popt" and a "GU I" resource). The easiest way to get these is dropping your application on EditPythonPrefs. An alternative (often handier because you don't have to do it after every build) is to create a resource file that includes the Popt and GUSI resource and include this in your build. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From jack@oratrix.nl Thu Aug 31 09:46:49 2000 From: jack@oratrix.nl (Jack Jansen) Date: Thu, 31 Aug 2000 10:46:49 +0200 Subject: [Pythonmac-SIG] Distributing Python Applications In-Reply-To: Message by Etienne Antoniutti Di Muro , Thu, 31 Aug 2000 10:30:45 +0200 , <39AE17B5.41EB9901@alias.it> Message-ID: <20000831084649.AA503303181@snelboot.oratrix.nl> Etienne, have a look at BuildApplication. It won't do what you want out-of-the-box, because you need to extend a C++ application, but you can probably hack it a little so that it takes your application as the main (C) application in stead of PythonInterpreter, as it normally does. Then you'll end up with a single binary that has everything you need included. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From erik@letterror.com Thu Aug 31 11:46:51 2000 From: erik@letterror.com (Erik van Blokland) Date: Thu, 31 Aug 2000 11:46:51 +0100 Subject: [Pythonmac-SIG] Claris Emailer mailbox format Message-ID: <200008310948.LAA15593@leidschenveen.denhaag.dataweb.net> Hi, has anyone heard of a python mailbox interface for Claris Emailer mailboxes? Erik -- letterror From dma@andrew.cmu.edu Thu Aug 31 15:00:41 2000 From: dma@andrew.cmu.edu (David Andersen) Date: Thu, 31 Aug 2000 10:00:41 -0400 Subject: [Pythonmac-SIG] C++ extensions, exceptions? In-Reply-To: <20000826160544.988C41CFB8@dinsdale.python.org> Message-ID: <1348399840.967716041@DAWSON.WV.CC.CMU.EDU> The following very simple C++ Python extension fails on the Mac if the line "test();" is included. (Metrowerks C/C++ 5.3). It appears that exception handling is simply broken. I can't find anything wrong with the code or the project settings. Has anyone written an extension to Pythonmac in C++ ? #include "python.h" void test() { try { throw 3; } catch( ... ) { } } extern "C" PyObject *dmaxtnd(PyObject *self,PyObject *args) { int xx,yy,cc; if (!PyArg_ParseTuple(args,"ii",&xx,&yy)) return(NULL); cc = xx+yy; test(); return(Py_BuildValue("i",cc)); } /* dmaxtnd */ /* method table */ static PyMethodDef dmamethods[] = { {"dmaxtnd",dmaxtnd,METH_VARARGS}, {NULL,NULL} }; extern "C" void __declspec(dllexport) initdmaxtnd() { Py_InitModule("dmaxtnd",dmamethods); }