Permission Issues in python cgi scripts on Apache 2.2 on OSX Leopard
Using Apache 2.2 on my local OSX machine, I;ve set up a virtual host to serve a directory that a project of mine is in. In this directory, I have some python .cgi scripts that I use to dynamically generated locally-used html code. In several places,scripts that work fine when not run as .cgi scripts via the webserver (but just as regular .py scripts in the Python interpreter) break when run by Apache because of what look like permissions related issues. Specifically: 1) When a script attempts to make a directory, it fails to do so unless writing is enabled on the superdirectory for all users, not just owner or group. I see a "permission denied" error via the cgitb output. and, 2) Some operating system stat modification functions, like os.utim, fail -- with the error message being that "Operation is Not Permitted".I've put permissions to 777 for all the involved files but to no avail. (Am I right in thinking that this problem is also a permissions issue? I know the first one is, because the error message says so explicitly.) My computer is running off-line and this only ever going to be a local development task. So, my basic question is: is there some way, for the directories that I'm serving, to turn of all the permissions protections whatsoever? E.g. to run my cgi scripts as if the process running the scripts had all root privileges? And so that I can run scripts via cgi without having to worry about problems like the "Operation Not Permitted Errror"? (I want to be able to take advantage of using pythong for dynamic web-page generation without worrying about permission and security issues, since these files will never be near anything online.) I've tried to do things like put the proper things in my Apache configuration files (e.g the virtual host conf fil, the httpd.conf file, etc...), but this failed to achieve my goal. I apologize if I'm sending this mail to the wrong list, Thanks, Dan -- http://mail.python.org/mailman/listinfo/python-list
Building python 64-bit on OS 10.5?
Dear all: I've two questions: 1) I've been trying to building python as a 64-bit version on OS 10.5. I'm not too familiar with building python from scratch, and a number of basic attempts made from piecing together things I've seen on the web have failed. (For instance, ./configure --enable-framework --disable-toolbox-glue --with-universal-archs=all --with-gcc="gcc -m64" leads to a failure when I try to do "make", as do all other similar variants I've tried.) So, is there a good source where I can find step-by-step 64-bit build instructions? (I'd like to do it if possible as a framework build.) I've looked it up a lot on google but am mostly getting fragments of descriptions of errors with other people's builds. 2) I often use a number of python extensions like matplot, pylab, and ipython. Will these (especially the graphics parts) be able to build on top of my 64-bit installation? Is there some way to find out if they will likely work without actually having to build them? Thanks, Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: Building python 64-bit on OS 10.5?
Dear all: I've two questions: 1) I've been trying to building python as a 64-bit version on OS 10.5. I'm not too familiar with building python from scratch, and a number of basic attempts made from piecing together things I've seen on the web have failed. (For instance, ./configure --enable-framework --disable-toolbox-glue --with-universal-archs=all --with-gcc="gcc -m64" leads to a failure when I try to do "make", as do all other similar variants I've tried.) So, is there a good source where I can find step-by-step 64-bit build instructions? (I'd like to do it if possible as a framework build.) I've looked it up a lot on google but am mostly getting fragments of descriptions of errors with other people's builds. 2) I often use a number of python extensions like matplot, pylab, and ipython. Will these (especially the graphics parts) be able to build on top of my 64-bit installation? Is there some way to find out if they will likely work without actually having to build them? Thanks! Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: Python -> R?
> > If so, what are you using? I have read about RPy, is that a good > solution? Yes, I think it's quite a good solution. It's not exactly 100% as convenient as working directly in R, but that's IMO more than compensated by the ability to use Python's syntax. Make sure you use Rpy2 (the successor to Rpy) -- I find it significantly better. However, the online documentation is in IMHO a little thin -- at least, in terms of examples -- so I once wrote up a little 5-minute tutorial to show a friend how to use Rpy2. I've attached it to this message -- you may find it useful. best Dan R_stuff.py Description: Binary data -- http://mail.python.org/mailman/listinfo/python-list
A package import question
I'm having a problem importing a package in python, deleting some of what's been imported, and then reimporting. (I'm the sure the problem is trivial, but I just don't understand it.) I have a directory of python modules called Operations. It contains a python module called archive.py.Here's a import of the archive module via package import: Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import Operations.archive >>> Operations.archive So far, so good. But now, suppose I want to delete Operations.archive. then, I can't reimport it. instead, I >>> del Operations.archive >>> import Operations.archive >>> dir() ['Operations', '__builtins__', '__doc__', '__name__'] >>> Instead of getting 'Operations.archive', I just seem to get 'Operations'. I can't seem to be able to import Operations.archive without quitting the python interpreter and starting again. What's going on here, and how do I fix it? Thanks, Dan -- http://mail.python.org/mailman/listinfo/python-list
Another (perhaps similar) import question
I also have noticed another (to me) strange thing about module imports. If anyone could explain this to me, that would be great (I apologize if it's too elementary for this list.) Suppose I have a module #file: testmodule.py a = 1 When importing this module, obviously 'a' becomes an attribute of testmodule: >>> import testmodule >>> dir(testmodule) ['__builtins__', '__doc__', '__file__', '__name__', 'a'] Now, supposed I modify the file to: #file: testmodule.py A = 1 and then reload: >>> reload(testmodule) Now, the reported attributes still include the old 'a': >>> dir(testmodule) ['A', '__builtins__', '__doc__', '__file__', '__name__', 'a'] Why does this happen? Moreover, even if I delete the module from memory and then reload, I _still_ get the old attribute 'a': >>> del testmodule >>> import testmodule >>> dir(testmodule) ['A', '__builtins__', '__doc__', '__file__', '__name__', 'a'] What is the principle behind this? And, is there some simple way (other than restarting the interpreter) of "reloading" that wipes out the old attributes associated with a given name so that spurious attributes do not remain? Thanks again (and apologies of this is a stupid question) Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: A package import question
You have removed the "archive" attribute from the object to which the > "Operations" name is referring to. > >>>> import Operations.archive >> > > Python keeps a reference to all imported modules in sys.modules; if a > module was already imported, any subsequent imports of the same module just > return the existing reference. > If you want to force Python to re-read the module from file, use the reload > function. But please read the warnings at > http://docs.python.org/lib/built-in-funcs.html#l2h-61 > > Gabriel, thanks. I understood about the fact that import only loads the first time, but didn't realize that "del" only removes the bound reference to the object, not as I had hoped the thing from the namespace itself. Also, I did _try_ to use reload. however, that failed since .archive was no longer an attribute associated with Operations: >>> import Operations.archive >>> del Operations.archive >>> reload(Operations.archive) Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'archive' It seems unfortunately that the "del" operation on the one hand doesn't really remove the .archive from memory but just it's bound name, but nonetheless prevents me from reloading the object kept in memory. I guess I'm trying to find a clean way to remove all the attributes associated with a module when I reload it. Is there any way to do this? (The operation of recursively searching through the attributes of the module and deleting those first seems to be bad since when I did that and then try to _reload_ the module, the attributes I deleted are _not_ reloaded.) On Fri, Jun 13, 2008 at 9:09 PM, Gabriel Genellina <[EMAIL PROTECTED]> wrote: > En Fri, 13 Jun 2008 20:01:56 -0300, Dan Yamins <[EMAIL PROTECTED]> > escribió: > > I'm having a problem importing a package in python, deleting some of >> what's >> been imported, and then reimporting. (I'm the sure the problem is >> trivial, >> but I just don't understand it.) >> >> I have a directory of python modules called Operations. It contains a >> python module called archive.py.Here's a import of the archive module >> via package import: >> >> Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53) >> [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin >> Type "help", "copyright", "credits" or "license" for more information. >> >>> import Operations.archive >> >>> Operations.archive >> >> >> So far, so good. >> > > Note that if you execute dir() at this point, you'll see the Operations > name, *not* Operations.archive. > The statement "import Operations.archive" first tries to locate and load a > module named Operations - and *that* name is added to the current namespace, > not Operations.archive (which is an invalid name by itself). > > But now, suppose I want to delete Operations.archive. then, I can't >> reimport it. instead, I >> >> >>> del Operations.archive >> > > You have removed the "archive" attribute from the object to which the > "Operations" name is referring to. > >>>> import Operations.archive >> > > Python keeps a reference to all imported modules in sys.modules; if a > module was already imported, any subsequent imports of the same module just > return the existing reference. > If you want to force Python to re-read the module from file, use the reload > function. But please read the warnings at > http://docs.python.org/lib/built-in-funcs.html#l2h-61 > >>>> dir() >> ['Operations', '__builtins__', '__doc__', '__name__'] >> >>> >> >> Instead of getting 'Operations.archive', I just seem to get 'Operations'. >> > > You would never get a dotted name from dir(), unless you play tricks with > locals()/globals() > > I can't seem to be able to import Operations.archive without quitting the >> python interpreter and starting again. >> >> What's going on here, and how do I fix it? >> > > reload() may be what you need, but again, make sure you read the > documentation before using it. reload is not a magic wand. Remember that > names imported from the old module definition continue to be bound to the > old objects, and all instances of classes defined in the old module continue > to use the old class definitions, among other things. > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: Another (perhaps similar) import question
>> >> > > Please keep responses to python-list discussion on python-list, not my > personal mail box. -- Thanks. > Sorry. When I hit "reply" on gmail to your message, your personal email comes up as opposed to the python list address. My apologies for not looking for closely. > I'd suggest using modules for your system's code, and exec (or execfile) to > read and parse user supplied code snippets. The result of an exec of user > supplied code will be very similar to a module import, and it will be using > import and exec as they were intended. Wow, thanks very much for introducing my to the execfile command, I've been looking for something like it. I see how this removes the issue of needing reload. Great. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Execfile issue
I'm having (what I assume is) a simple problem regarding the way import and execfile interact. I apologize in advance for my naivete. Lets say I have the function: def Func1(): print dir() execfile('testfile') print dir() X and the file #file: testfile X = 3 Then, when I run Func1 , I get the output: >>> Func1() [] ['X'] Traceback (most recent call last): File "", line 1, in File "", line 5, in Func1 NameError: global name 'X' is not defined SO, I have three questions: 1) Naively, I would think that the call to "execfile" in Func1 would act as if the line was replaced with the lines of 'testfile'. But obviously not, in some way that has to do with the subtlety of the python compilation process. Can someone explain exactly what the problem is? 2) Why would something show up in the dir() call, but not be defined (e.g. like 'X' did in the second dir() call in Func1()) ? 3) Is there any way to fix this that does not involved (essentially in one way or another) importing "testfile" as a py module? I would like to avoid that scenario for a variety of reasons ... Thanks! Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: An idiom for code generation with exec
On Fri, Jun 20, 2008 at 3:17 AM, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: Just to make things clear: you do know that you can dynamically build > functions without exec, do you ? Actually, I don't know how to do this, but would like to. Can you point me to a place where I can read more about how (and to a discussion of the flaws of the exec-based approach)? Thanks! Dan -- http://mail.python.org/mailman/listinfo/python-list
Good approximate static function call analyzer
I'm looking for a reasonable static function call analysis tool for python functions -- something that will look at code (and possibly import the module it's in) and return a reasonable guess at the functions that might be called by the code. For my purposes, approximations are totally fine -- e.g. the analyzer doesn't have to analyze and pare out calls that won't actually get made due to the deep semantics of the function -- and it doesn't have to be able to see function calls made inside exec statements &c.The key thing is that I have to be able to run the analyzer without calling the function. Any tips on where I can look to find such or thing (or build it myself) would be great. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Wrap and intercept function calls
Hi: I'm wondering what the best way to wrap and modify function calls is. Essentially what I want to achieve is to have a function like this: def Wrap(frame,event,arg): if event == 'call': result = PerformCheck(GetArgumentsFromFrame(frame)) if Condition(result): return result else: return [normal function call] called whenever a "call" event is about to occur. When I say "return result" I mean: return that data object instead of what the function would have returned, and prevent execution of the function. Is there any way to do this using sys.settrace? Or perhaps something from the bdb or pbd module? Thanks! Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: Wrap and intercept function calls
Really, nobody has any idea about this? (Sorry to repost.) On Tue, Feb 16, 2010 at 7:29 PM, Dan Yamins wrote: > Hi: > > I'm wondering what the best way to wrap and modify function calls is. > Essentially what I want to achieve is to have a function like this: > > def Wrap(frame,event,arg): > if event == 'call': > result = PerformCheck(GetArgumentsFromFrame(frame)) > if Condition(result): > return result > else: > return [normal function call] > > called whenever a "call" event is about to occur. > > When I say "return result" I mean: return that data object instead of what > the function would have returned, and prevent execution of the function. > > > Is there any way to do this using sys.settrace? Or perhaps something from > the bdb or pbd module? > > In other words, what I'm looking for is a way to intercept all function calls with a "wrapper" -- like one can do using settrace and other debugging methods -- but, unlike the debugging methods, have the "wrapping" function actually be able to intervene in the stack and, for instance, conditionally replace the function call's return with something determined in the wrapping function and prevent the function call's execution. I want to be able to do this by setting a single system-wide (or at any rate, thread-wide) value, like with settrace, and not have to modify individual functions one by one. Could I, for example, set a settrace function that somehow modifies the stack? Or is there some much better way to do this? Or, if someone can tell me that this can't be done without having to roll my own implementation of the Python interpreter, that would be great to know too. Thanks again, Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: Wrap and intercept function calls
> For CPython, alternative 1 is to create a custom interpreter to change > (wrap) the interpretation of the call-function bytecode in the ceval loop. > That is its 'call event', and I believe this would catch every explicit > f(args) call and only such calls. > > > Python has no general metasyntax for changing the semantics of its syntax. > The __xx__ methods are special cases for the corresponding operators *and* > the corresponding user-defined class. The '__call__' method of a class > applies to instances of that class. Alternative 2: > > Terry thanks for your response. My hoped-for spec explicitly prohibits wrapping required each (user-defined) function to be wrapped individual, since I want to be able to have this wrapping behavior apply to many functions created by many users on the fly, and such users can't be asked to remember to wrap each function. (At most, they can be asked to set a single evironment variable or the like at the beginning of modules or interpreter sessions that should the "turn on wrapping" for all future function calls.) So I suppose the situation is as I feared? That the only way to achieve my goal without having to wrap every (user-defined) function call individually is to modify the interpreter. Is there no way to edit frame objects from inside a function? if I could do that in a settrace function, would it even help? Also: am I right in thinking that the "modified interpreter" approach would mean that my resulting software couldn't be used as a 3-rd party module, that could be easily integrated into existing python installations? Or is there some standard way of integrating dynamically loadable modifications to the interpreter in python? (e.g. so that users of my code wouldn't have to re-install of their existing modules in a separate new python installation?) Thanks! Dan > >> > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
PyPI upload documentation
Dear all: I'm trying to upload documentation to the PyPI site for a project I'm working on (there's a "new feature" on the PyPI site that allows admins of projects to upload a zip file of the pages of documentation.) If you have admin access to a PyPI project, you can see this on the admin page for that project, at the bottom. However, it's failing do to what appears to be a permissions error. When I press "Upload documentation", I get the following error: Forbidden You don't have permission to access /tabular/ on this server. -- Apache/2.2.9 (Debian) mod_fastcgi/2.4.6 mod_python/3.3.1 Python/2.5.2 mod_wsgi/2.3 Server at packages.python.org Port 80 If anyone could clue me into what's going wrong, that would be great. I know that this list might not be the right thing to write to -- I tried writing to the python.org webmester, but got only the automated reply. If there's a more appropriate list that I should write to instead, I'd be happy to learn of it. Thanks, Dan -- http://mail.python.org/mailman/listinfo/python-list
Re: PyPI upload documentation
Sorry to write again, but really nobody on the Python list knows how to get in touch with the people running PyPI's website in an effective way? Thanks! Dan On Tue, Sep 8, 2009 at 6:25 PM, Dan Yamins wrote: > Dear all: > > I'm trying to upload documentation to the PyPI site for a project I'm > working on (there's a "new feature" on the PyPI site that allows admins of > projects to upload a zip file of the pages of documentation.) > > If you have admin access to a PyPI project, you can see this on the admin > page for that project, at the bottom. > > However, it's failing do to what appears to be a permissions error. When I > press "Upload documentation", I get the following error: > > Forbidden > > You don't have permission to access /tabular/ on this server. > -- > Apache/2.2.9 (Debian) mod_fastcgi/2.4.6 mod_python/3.3.1 Python/2.5.2 > mod_wsgi/2.3 Server at packages.python.org Port 80 > > > If anyone could clue me into what's going wrong, that would be great. > > I know that this list might not be the right thing to write to -- I tried > writing to the python.org webmester, but got only the automated reply. > If there's a more appropriate list that I should write to instead, I'd be > happy to learn of it. > > > Thanks, > Dan > -- http://mail.python.org/mailman/listinfo/python-list
Re: PyPI upload documentation
On Wed, Sep 9, 2009 at 4:29 PM, Robert Kern wrote: > On 2009-09-09 15:14 PM, Dan Yamins wrote: > >> Sorry to write again, but really nobody on the Python list knows how to >> get in touch with the people running PyPI's website in an effective way? >> > > http://www.python.org/community/sigs/current/catalog-sig/ > > I'm sorry to be a dunce -- but I'm not sure how this addresses my question. I've been having a problem with a feature of the PyPI website (the feature which is supposed to allow me to upload documentation as a .zip file of html documentation of my project), but I can't get the python webmaster to reply to me.Are you saying that I should look at PEP 301? Or write to catalog-...@python.org? Or are you saying that I should be using my distutils to do this? Sorry for not understanding, Dan -- > Robert Kern > > "I have come to believe that the whole world is an enigma, a harmless > enigma > that is made terrible by our own mad attempt to interpret it as though it > had > an underlying truth." > -- Umberto Eco > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list