Can't import PyObjC CoreData module when using mod_wsgi with Apache - objective-c

Just ported a webapp from TurboGears to Django and going through the process of getting a proper server running (i.e. not runserver). Tried going the recommended Apache + mod_wsgi route that the Django docs talk about, but for some reason the thread stalls out with no error message or anything as soon as you try to import CoreData anywhere in a module that Apache is loading.
Specifically, the point at which it stalls out is in the CoreData/__init__.py file here:
__bundle__ = _objc.initFrameworkWrapper("CoreData",
frameworkIdentifier="com.apple.CoreData",
frameworkPath=_objc.pathForFramework(
"/System/Library/Frameworks/CoreData.framework"),
globals=globals())
Not sure what it is about CoreData that makes this fail, since import Foundation works fine (i.e. it doesn't seem to be that all the PyObjC stuff is broken under Apache, just CoreData).
I'm kinda looking into going the lighttpd route now instead, but if anyone could shed light on how to make the mod_wsgi way work that would be good, as I would prefer to stick as close to the suggested simplest deployment method as possible.
Thanks in advance for any insights.
Also: I'm on OSX 10.6.4 with whatever latest version of PyObjC & Apache comes with that, plus the latest mod_wsgi I grabbed from the Google Code website.

Try forcing WSGI application to run in main interpreter. Sounds like PyObjC is not implemented correctly so as to be used in sub interpreters. See:
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Python_Simplified_GIL_State_API

Related

What is the best method to set a session cookie using Python 3.x and Cgi on Apache?

I develop in Php, Perl and now am liking Python so much that I want to use it on the web. I can get things working that I need except for a good method for setting/managing sessions. Any help out there? Point me to a library? or ideally post some working python code for my technology stack?
(looking for updated information on how to do this without depending on any framework)

Is there a decent, standalone, cross-platform webserver that will work in concert with Autorun on USB Jump Drives?

I'm trying to find a decent standalone webserver that I can load up on a jump drive.
My wife is a photographer, and I'd like to present the clients with their images on usb. When they plug it in, I'd like a web page to load up, and run some jQuery magic to show them a nice carousel of all there images.
So far, this is all fine since it can all be done client side and doesn't need a server at all.
The problem I'm facing is that I'd like some server-side code to be able to read the images out of the directory so that once the interface is built, I don't need to manually create all of the <img /> tags.
If it was primarily going to be used in a Windows environment, I'd have no problem going with IIS Express, since I'm mainly a .NET MVC developer and this would be perfect for me... However, the fact of the matter is that a large amount of our client base is also OS X users.
I did find this Java one jlHttp, and I also found this thread here on SO, but I don't think I understand enough about either one of them to accomplish what I'm looking for.
Thanks in advance for your suggestions.
I'm looking for the same thing, and the two best options I've found were Flying Ant cd web server and Stunnix. Of the two, Flying Ant is cheaper, and I've tested it with success on my project.
I found Mongoose very convenient for this exact purpose. It's crossplatform, lightweight and requires minimum configuration. You may be interested in this project that uses Mongoose to display pictures in a folder tree or FTP directory.
How about Node.js
It says it runs on Linux, OS X, and Windows.

Getting Orbited to work with my Twisted app

I can't seem to get Orbited working with my Twisted app. I have a page, served by Twisted (say localhost:8000/page) which includes Orbited.js from the orbited server (localhost:8001/static/Orbited.js). I then have a TCP chat server example running on port 7777. I try to use Orbited.TCPSocket to connect to the chat server:
conn=new Orbited.TCPSocket();
conn.open("localhost", 7777);
conn.send("test\r\n"); //error: bad readyState
It works fine when Orbited is serving the page, but not when twisted serves it from a different port. My orbited.cfg looks like this:
[listen]
http://:8001
[access]
* -> localhost:7777
And before (which worked) I had this in it as well:
[static]
test=index.html
Where index.html was another page grabbing localhost:8001/static/Orbited.js, and was accessed from localhost:8001/test.
How do I need to change my config file to work with requests from my twisted site on another port?
Update
I tried changing Orbited.settings.port to 8001 before trying to open the connection, but I got an error: "unsafe javascript attempt to access frame with url http://localhost:8000/page from frame with url http://localhost:8001/static/xsdrBridge.html#1. Domains, protocols and ports must match."
Hmm, also, I just looked at the orbited wiki, and apparently, setting Orbited.settings.port is exactly what I'm supposed to do. but I'm getting horrible errors
You can call send() only after the connection is in opened state.
Put a handler for .onopen() and do a .send() from there.
I have used Orbited in the past. It works in general but there are several quirks to get it set up and running smoothly. The project itself seems to be in a state of flux (it seems to be moving to node.js). Both of these points lead me to suggest that - if you can avoid it - not to use Orbited.
Are there alternatives that are cleaner? I would say, yes. You can pretty much emulate Orbited with Websockets on stock Twisted. This will clearly work for newer browsers. What about older ones? Well, there are open-source projects that wrap websockets and fall back to flash as a transport for older browsers. The setup works quite well, and actually feels cleaner than using a solution like orbited.
If you check out http://github.com/rlotun/txWebSocket you'll find the current state of Twisted's websocket implementation, as well as an example of how to fall back to flash on older browsers. Hopefully this will be useful enough for you to serve as a drop in replacement to Orbited.

Web server which supports removing a file immediately after it has been downloaded once?

I need a web server that allows me to remove a file after it has been successfully downloaded once. Is there any way to do this with apache?
Is there another web server I can use for this task? I had already looked into Tornado for this purpose, but couldn't find a way to get an event to fire as soon as the download finished. the on_connection_close would only fire when I shut down the server.
I'd prefer something PHP or Python-based if I have to code it myself.
you might be able to accomplish this with LUA (lighttpd + mod_magnet) - but im not sure... besides that im not aware of any modules that has event triggers on "downloads" there are some that work with uploads like the mod_uploadprogress in lighttpd. im sure nginx has some similar modules... besides that... i think the only solution here is:
http://redmine.lighttpd.net/wiki/lighttpd/HowToWriteALighttpdPlugin

Spell Checking Service with python using mod_python

What is the best available method for developing a spell check engine (for example, with aspell_python), that works with apache mod_python?
apache 2.0.59+RHEL4+mod_python+aspell_python seems to crash.
Is there any alternative to using aspell_python?
Looks like RHEL4 is the culprit. Works well on Fedore 7 (the version of apache is newer and there is no crash)