Re: [Pythonmac-SIG] Namespace conflict with WebWare and PyObjC / Import safety (Was: how do I use twisted cfreactor?)

2005-01-15 Thread Bob Ippolito
On Jan 14, 2005, at 17:57, Bob Ippolito wrote:
On Jan 14, 2005, at 17:14, Bob Ippolito wrote:
On Jan 14, 2005, at 16:56, Kevin Dangoor wrote:
Bob Ippolito wrote:
(Kevin sent me the test off-list, and I took a look at it).
I'm not sure exactly why your example crashes (somehow a retain  
message gets sent to a dead or non-object), however, the problem is  
that you are using an import statement from inside the  
implementation of the action.  Don't do that.  Do your imports in  
module level code.
Wow. That was quick!
I didn't realize that there was a gotcha with the imports. That was  
just a premature optimization, so I can easily avoid that :)

Thanks for your help... that's certainly not the kind of thing I  
would have just guessed...
I don't think there is typically a gotcha with imports, I've  
certainly never seen this happen before, and I have done imports from  
applicationDidFinishLaunching: (pygame, in particular) before.  I  
have no idea if I should be blaming Cheetah, PyObjC or Python 2.3.0  
(haven't tested with 2.4 or CVS), but I will try and remember to dig  
in later.
I have traced the problem.  It is a two-parter:
(1) There is a module namespace conflict:
WebWare has a package named WebKit
PyObjC has a package named WebKit
(2) Cheetah.Servlet checks to see if WebWare's WebKit is available,  
and ends up importing PyObjC's WebKit.

(3) For whatever reason, it is not safe to import the WebKit wrapper  
from inside of an action (unless it's already imported, of course).   
Now this issue I will have to look further into.

---
So apparently it's more or less undefined behavior if you have both  
WebWare and PyObjC installed!  Fun :)
I've filed a bug against WebWare  
http://sourceforge.net/tracker/index.php? 
func=detailaid=1102868group_id=4866atid=104866, hopefully they'll  
change the name of WebKit, I don't think we will do it in PyObjC --  
because then we'd have to change the names of every wrapped framework  
for consistency.

The actual crash is due to the fact that WebKit/__init__.py recycles  
the PyObjC global autorelease pool.  God knows why.  I've reverted this  
behavior in svn trunk r1337.

-bob
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] Re: Namespace conflict with WebWare and PyObjC / Import safety (Was: how do I use twisted cfreactor?)

2005-01-15 Thread has
Kevin Dangoor wrote:
What I like about Cheetah
is that it's concise (unlike TAL), is pleasant to work with (subjective
to be sure, but I don't like ClearSilver's syntax), is reasonably
performant, and strikes a nice balance between functionality and
separation of concerns.
Utterly shameless self-plug here, but HTMLTemplate 
http://freespace.virgin.net/hamish.sanderson/htmltemplate.html is a 
mature, powerful and flexible DOM-like HTML templating system that's 
also refreshingly simple and unintrusive in both implementation and 
use. I've also just posted an update to its plain text-oriented 
sibling, texttemplate 
http://freespace.virgin.net/hamish.sanderson/texttemplate.html (the 
documentation isn't quite done yet, but the module itself should be 
quite usable).

Cheers,
has
--
http://freespace.virgin.net/hamish.sanderson/
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Namespace conflict with WebWare and PyObjC / Import safety (Was: how do I use twisted cfreactor?)

2005-01-15 Thread Jack Jansen
On 14-jan-05, at 23:57, Bob Ippolito wrote:
I have traced the problem.  It is a two-parter:
(1) There is a module namespace conflict:
WebWare has a package named WebKit
PyObjC has a package named WebKit
As far as I know this is the first time this potential problem with 
python's naming convention is seen in the wild. Maybe it's worth it to 
report it to python-dev?
--
Jack Jansen, [EMAIL PROTECTED], http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma 
Goldman

___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pyobjc-dev] Re: [Pythonmac-SIG] Namespace conflict with WebWare and PyObjC / Import safety (Was: how do I use twisted cfreactor?)

2005-01-15 Thread Bob Ippolito
On Jan 15, 2005, at 18:26, Jack Jansen wrote:
On 14-jan-05, at 23:57, Bob Ippolito wrote:
I have traced the problem.  It is a two-parter:
(1) There is a module namespace conflict:
WebWare has a package named WebKit
PyObjC has a package named WebKit
As far as I know this is the first time this potential problem with 
python's naming convention is seen in the wild. Maybe it's worth it to 
report it to python-dev?
Well I filed a bug with Webware, let's wait a couple days and see if 
they say anything.

-bob
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] accessing my modules from within Python

2005-01-15 Thread Kirk Durston
Title: accessing my modules from within Python



I'm just starting to learn Python. When I write a module in one of my text programs (MSWord, or Textedit) and save it as a text file in on my harddrive, and then go to the terminal window to import it, I get a message saying it either can't find the file or can't open it. I do put the .py suffix on when I save the module, but no success. I have been saving my modules in different places, the last of which was in library/python/2.3/sitepackages ... no success. The test module Ive written is called bogus.py

If I start python in the terminal window and then type 'import bogus' I get a message saying 'Import error: No module named bogus'

If I try and launch the python module by typing 'python bogus.py' I get a message python: can't open file 'bogus.py' 

Question: Can I use TextEdit or MS Word to write modules just so long as I put a .py suffix on the file?

Question: How can I save a module such that Python can find and open it?




___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] accessing my modules from within Python

2005-01-15 Thread Bob Ippolito
On Jan 15, 2005, at 21:43, Kirk Durston wrote:
I'm just starting to learn Python. When I write a module in one of my 
text programs (MSWord, or Textedit) and save it as a text file in on 
my harddrive, and then go to the terminal window to import it, I get a 
message saying it either can't find the file or can't open it. I do 
put the .py suffix on when I save the module, but no success. I have 
been saving my modules in different places, the last of which was in 
library/python/2.3/sitepackages ... no success. The test module Ive 
written is called bogus.py

 If I start python in the terminal window and then type 'import bogus' 
I get a message saying 'Import error: No module named bogus'

 If I try and launch the python module by typing 'python bogus.py' I 
get a message python: can't open file 'bogus.py' 

 Question: Can I use TextEdit or MS Word to write modules just so long 
as I put a .py suffix on the file?
If and only if the file is saved as plain text.
I wouldn't recommend using either of these editors as they don't have 
any built-in support for programming (syntax highlighting, completion, 
indentation, etc.) and you will probably have the tabs vs. spaces 
problem.  You should ideally use a text editor more suitable for 
programming, such as Xcode.  If you use Xcode, make sure to uncheck 
Editor uses tabs in the Text Editing preference pane before writing 
any code.

 Question: How can I save a module such that Python can find and open 
it?
There is some useful information about how Python modules are located 
in the Python tutorial http://docs.python.org/tut/node8.html.

The global location where add-on modules should be placed is dependent 
on which Python you are using.  If you are using the Python 2.3.0 that 
comes with Mac OS X 10.3.x, then this location is 
file:///Library/Python/2.3.  Otherwise, it depends on which 
distribution of Python you installed and how you installed it.

If you would like to place your modules somewhere else, you can create 
a plain-text pth file that points to this other desired location.  
Documentation for this feature is described in the site module 
documentation http://www.python.org/doc/lib/module-site.html.

Running Python files from the command line is like running anything 
else from the command line.  When you say python bogus.py, bogus.py 
MUST be in the current directory, or else it won't work.  Either you 
need to change to the directory that bogus.py is in, or pass in the 
complete path to bogus.py.  A quick way to do this is to just type 
python , drag bogus.py to your Terminal window to paste the file's 
full path, and press return.

-bob
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig