Python in web development
Hello All, I have been using Python as a scripting language for my office tasks. Now I have been thinking of using (and learning as well) for web development. For my tasks, I need to perform some tasks and report on the web. Now I have no experience of web development with Python. So, I want to conform first whether Python is best for web development. Python is my personal choice for my automation works and I want to extend it for web development. REQUIREMENT: I need to develop a html form which would take user input and perform some operations (generate intermediate files) and report result on web. Some guys in my organization are using Perl for this purpose and thus I could get the setup for free.But I want to learn and use Python as substitute for Perl. (PHP could also be an option. I have worked on PHP once for handling the form data.) So my questions are:- 1. Can I use Python (I want to use personally :)) over PHP/Perl? 2. If Yes, I want to know the modules that I should learn for achieving my requirement. I searched internet and found Python provides CGI, Django etc. I don't much about Django/CGI, please suggest which module I should learn and use. Thanks Sarbjit -- http://mail.python.org/mailman/listinfo/python-list
Re: How to install development package on linux?
On Saturday, March 2, 2013 2:15:08 PM UTC+5:30, Kwpolska wrote: On Sat, Mar 2, 2013 at 7:24 AM, Sarbjit singh sarbjit1...@gmail.com wrote: Sorry for this basic question but I am having problem compiling mod_wsgi on Linux. As per mod_wsgi package site, user must have python development package installed on system. I had installed Python2.7 on my Linux system from source code, using the following configuration few months back :- ./configure –prefix=path --enable-shared Make –i install But I am not able to find how to install development package from source code. Can some one please conform if I can install the development package from the same source code (Downloaded from Python Website for Unix) and please share the configuration switch for the same. Thanks, Sarbjit -- http://mail.python.org/mailman/listinfo/python-list Why do you use source tarballs? Your distro should provide nice binary packages for Python and mod_wsgi. And in case it doesn’t, your distro sucks and you should find a better one. The development things are usually installed by default by most things. Distributions offer them in -dev or -devel packages. -- Kwpolska http://kwpolska.tk | GPG KEY: 5EAAEA16 stop html mail| always bottom-post http://asciiribbon.org| http://caliburn.nl/topposting.html I am using Red Hat 5, could you please give some pointers on how to install these packages? -- http://mail.python.org/mailman/listinfo/python-list
Re: How to install development package on linux?
On Sunday, March 3, 2013 1:22:50 AM UTC+5:30, Kwpolska wrote: On Sat, Mar 2, 2013 at 7:00 PM, Sarbjit singh sarbjit1...@gmail.com wrote: On Saturday, March 2, 2013 2:15:08 PM UTC+5:30, Kwpolska wrote: On Sat, Mar 2, 2013 at 7:24 AM, Sarbjit singh sarbjit1...@gmail.com wrote: Sorry for this basic question but I am having problem compiling mod_wsgi on Linux. As per mod_wsgi package site, user must have python development package installed on system. I had installed Python2.7 on my Linux system from source code, using the following configuration few months back :- ./configure –prefix=path --enable-shared Make –i install But I am not able to find how to install development package from source code. Can some one please conform if I can install the development package from the same source code (Downloaded from Python Website for Unix) and please share the configuration switch for the same. Thanks, Sarbjit -- http://mail.python.org/mailman/listinfo/python-list Why do you use source tarballs? Your distro should provide nice binary packages for Python and mod_wsgi. And in case it doesn’t, your distro sucks and you should find a better one. The development things are usually installed by default by most things. Distributions offer them in -dev or -devel packages. -- Kwpolska http://kwpolska.tk | GPG KEY: 5EAAEA16 stop html mail| always bottom-post http://asciiribbon.org| http://caliburn.nl/topposting.html I am using Red Hat 5, could you please give some pointers on how to install these packages? -- http://mail.python.org/mailman/listinfo/python-list Impossible, unless you: (a) build such packages yourself (Fedora .spec files may help you); or (b) upgrade to RHEL 6, which offers packages for python 2.6 and mod_wsgi; or (c) look for such packages on the Internet (you probably won’t find any). So, get back to compiling from source. Have you actually tried building those packages before asking? Because, according to the Arch Linux PKGBUILDs for python2 and mod_wsgi2, it doesn’t have any specific switches to enable anything “devel-related” (also, Arch Linux doesn’t bother with the dumb -dev(el) packages, which make no sense in real life). -- Kwpolska http://kwpolska.tk | GPG KEY: 5EAAEA16 stop html mail| always bottom-post http://asciiribbon.org| http://caliburn.nl/topposting.html Its not possible for me to switch to Red Hat6 at the moment. Yes, I did tried compiling these from the source code and got some errors. I am using Xaamp for linux and following the below link for configuring python/mod_wsgi :- http://www.apachefriends.org/f/viewtopic.php?f=17t=42975 When I initially tried to compile mod_wsgi, I was getting errors which got resolved by using development package fro Xammp for linux. (Solution found on google) Now I am getting the following compiling errors:- # mod_wsgi.c:14967: error: expected expression before ')' token mod_wsgi.c:14974: error: expected ';' before 'do' mod_wsgi.c:14979: error: expected ';' before '}' token mod_wsgi.c:14984: error: too many arguments to function 'wsgi_log_python_error' mod_wsgi.c:14989: error: expected expression before 'module' mod_wsgi.c: In function 'wsgi_allow_access': mod_wsgi.c:15003: error: 'PyObject' undeclared (first use in this function) mod_wsgi.c:15003: error: 'modules' undeclared (first use in this function) mod_wsgi.c:15004: error: expected expression before 'module' mod_wsgi.c:15051: error: 'Py_BEGIN_ALLOW_THREADS' undeclared (first use in this function) mod_wsgi.c:15052: error: expected ';' before 'apr_thread_mutex_lock' mod_wsgi.c:15053: error: 'Py_END_ALLOW_THREADS' undeclared (first use in this function) mod_wsgi.c:15056: error: expected ';' before 'modules' mod_wsgi.c:15057: error: expected identifier or '(' before '=' token mod_wsgi.c:15059: error: expected expression before 'module' mod_wsgi.c:15061: error: expected expression before 'module' mod_wsgi.c:15070: error: expected expression before 'module' mod_wsgi.c:15071: error: expected expression before 'module' mod_wsgi.c:15082: error: expected expression before 'module' mod_wsgi.c:15083: error: expected identifier or '(' before '=' token mod_wsgi.c:15089: error: expected expression before 'module' mod_wsgi.c:15090: error: expected identifier or '(' before '=' token mod_wsgi.c:15105: error: expected expression before 'module' mod_wsgi.c:15106: error: 'module_dict' undeclared (first use in this function) mod_wsgi.c:15107: error: 'object' undeclared (first use in this function) mod_wsgi.c:15109: error: expected expression before 'module' mod_wsgi.c
Re: How to install development package on linux?
On Sunday, March 3, 2013 11:53:50 AM UTC+5:30, Benjamin Kaplan wrote: On Sat, Mar 2, 2013 at 10:14 PM, Sarbjit singh sarbjit1...@gmail.com wrote: I searched on google and found these errors could be due to missing python header files which would be available in development package. So I am struggling to make it work. A development package is meaningless when you aren't installing it from a package. Debian's binary packages don't include the header files, so they put them in a different package. Since you compiled from source, you already have the header files. Did you include the directory you installed Python into on your library and includes paths? Yes, I configured the makefile for mod_wsgi as without any error : ./configure --prefix=/opt/lampp/ --with-apxs=/opt/lampp/bin/apxs --with-python=/opt/lampp/python/bin/python2.7 --with-mutex-dir=/opt/lampp/var/run/wsgi -- http://mail.python.org/mailman/listinfo/python-list
Re: How to install development package on linux?
On Sunday, March 3, 2013 12:09:46 PM UTC+5:30, Sarbjit singh wrote: On Sunday, March 3, 2013 11:53:50 AM UTC+5:30, Benjamin Kaplan wrote: On Sat, Mar 2, 2013 at 10:14 PM, Sarbjit singh sarbjit1...@gmail.com wrote: I searched on google and found these errors could be due to missing python header files which would be available in development package. So I am struggling to make it work. A development package is meaningless when you aren't installing it from a package. Debian's binary packages don't include the header files, so they put them in a different package. Since you compiled from source, you already have the header files. Did you include the directory you installed Python into on your library and includes paths? Yes, I configured the makefile for mod_wsgi as without any error : ./configure --prefix=/opt/lampp/ --with-apxs=/opt/lampp/bin/apxs --with-python=/opt/lampp/python/bin/python2.7 --with-mutex-dir=/opt/lampp/var/run/wsgi Also my LD_LIBRARY_PATH does have path as : /opt/lammp/python/lib Just one more point, while initially I was trying to compiling the mod_wsgi, I was getting error for libpython2.7.1.0.so Shared library error. I resolved it by creating a soft link to this file in my /usr/lib and /usr/lib64. At that point also my LD_LIBRARY_PATH was having path for python lib but was resolved with soft link only. -- http://mail.python.org/mailman/listinfo/python-list
How to install development package on linux?
Sorry for this basic question but I am having problem compiling mod_wsgi on Linux. As per mod_wsgi package site, user must have python development package installed on system. I had installed Python2.7 on my Linux system from source code, using the following configuration few months back :- ./configure –prefix=path --enable-shared Make –i install But I am not able to find how to install development package from source code. Can some one please conform if I can install the development package from the same source code (Downloaded from Python Website for Unix) and please share the configuration switch for the same. Thanks, Sarbjit -- http://mail.python.org/mailman/listinfo/python-list
[issue17027] support for drag and drop of files to tkinter application
New submission from Sarbjit singh: It would be nice to have a support to drop the files (files from the file explorer i.e. from outside the application) to the tkinter application which could then set the file path/ directory path depending upon the configuration set in the module. This feature would be very helpful in applications where user need to select some file/directory. -- components: Tkinter messages: 180554 nosy: Sarbjit.singh priority: normal severity: normal status: open title: support for drag and drop of files to tkinter application type: enhancement versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17027 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16823] Python crashes on running tkinter code with threads
New submission from Sarbjit singh: I have written a python tkinter code using threads so as the tkinter wizard updates automatically by tkinter mainloop running in the main thread and background process running in separate thread. But I noticed, that python crashes after some time when running the code. Moreover its random in nature but python crashes most of the time. I have written a small test code which can show this problem (My original code is similar to this but having some real processes and many other features, so I am sharing the test code). ## # Test Code for Tkinter with threads import Tkinter import threading import Queue import time # Data Generator which will generate Data def GenerateData(q): for i in range(100): #print Generating Some Data, Iteration %s %(i) time.sleep(0.01) q.put(Some Data from iteration %s. Putting this data in the queue for testing %(i)) # Queue which will be used for storing Data q = Queue.Queue() def QueueHandler(widinst, q): linecount = 0 while True: print Running if not q.empty(): str = q.get() linecount = linecount + 1 widinst.configure(state=normal) str = str + \n widinst.insert(end, str) if linecount 100: widinst.delete('1.0', '2.0') linecount = linecount - 1 widinst.see('end') widinst.configure(state=disabled) # Create a thread and run GUI QueueHadnler in it tk = Tkinter.Tk() scrollbar = Tkinter.Scrollbar(tk) scrollbar.pack(side='right', fill='y' ) text_wid = Tkinter.Text(tk,yscrollcommand=scrollbar.set) text_wid.pack() t1 = threading.Thread(target=GenerateData, args=(q,)) t2 = threading.Thread(target=QueueHandler, args=(text_wid,q)) t2.start() t1.start() tk.mainloop() ## TO REPRODUCE: If you open this code in IDLE and run it, it will sometimes appeared to be in hang state. So to reproduce, modify the sleep time to 0.1 from 0.01 and run it. After this stop the application, and modify it back to 0.01, do save and run it. This time it will run and after some time, python will stop working. I am using windows 7 (64 bit). NOTE: I am getting different stack trace's when it crashes on console: Please refer to the attached file for the stack traces. -- components: Tkinter files: debugstack.txt messages: 178642 nosy: Sarbjit.singh priority: normal severity: normal status: open title: Python crashes on running tkinter code with threads type: crash versions: Python 2.7 Added file: http://bugs.python.org/file28503/debugstack.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16823 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15586] Provide some examples for usage of ElementTree methods/attributes
New submission from Sarbjit singh: Please provide some basic usage examples for ElementTree module documentation. While parsing an xml, most common scenarios will be reading elements from xml, modifying elements, removal of elements. Though there are few examples given for modification of xml element. But if you look from beginners learning point of view, its very hard to just get any idea from the example that is currently provided. There is lot of text there, but what would be more helpful is some small examples for each function so that user can quickly understand its usage there only. I myself is learning Python, but in order to start using this module, i had to search lot of articles on internet on usage of this module. If we could have provided some basic use cases in Python doc itself, user would not have to rely on external sources for learning its usage. Some Basic Scenarios: 1) Parsing an xml and finding some elements of xml 2) deletion of an element from an xml and writing back 3) Modification of an xml element 4) Usage of XPath queries (some basic usage) -- assignee: docs@python components: Documentation messages: 167670 nosy: Sarbjit.singh, docs@python, eli.bendersky priority: normal severity: normal status: open title: Provide some examples for usage of ElementTree methods/attributes type: enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15586 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15583] Provide examples in Python doc for usage of various modules
New submission from Sarbjit singh: For beginners who are learning Python, it would be very helpful if Python doc could provide examples on usage of various methods/attributes of different modules. For eg: If you look at ElementTree XMl module or take any other standard module, examples which are provided are very limited making it hard for new users to learn those modules and have to search internet for its usage. Providing examples on usage of module attributes/methods will help users to quickly understand it. -- assignee: docs@python components: Documentation messages: 167657 nosy: Sarbjit.singh, docs@python priority: normal severity: normal status: open title: Provide examples in Python doc for usage of various modules type: enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15583 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
How to print stdout before writing stdin using subprocess module in Python?
I am writing a script in which in the external system command may sometimes require user input. I am not able to handle that properly. I have tried using os.popen4 and subprocess module but could not achieve the desired behavior. Below mentioned example would show this problem using cp command. (cp command is used to show this problem, i am calling some different exe which may similarly prompt for user response in some scenarios). In this example there are two files present on disk and when user tries to copy file1 to file2, an conformer message comes up. proc = subprocess.Popen(cp -i a.txt b.txt, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,) stdout_val, stderr_val = proc.communicate() print stdout_val b.txt? proc.communicate(y) Now in this example if i read only stdout/stderr and prints it, later on if i try to write y or n based on user's input, i got an error that channel is closed. Can some one please help me on achieving this behavior in python such that i can print stdout first, then should take user input and write stdin later on. -- http://mail.python.org/mailman/listinfo/python-list
How to configure Tkinter Listbox to disable state keeping selected item highlighted
I am having a problem configuring a listbox widget such that the selection remains highlighted even while it is set (programmatically) to the DISABLED state. Below code shows the problem: from Tkinter import * master = Tk() listbox = Listbox(master) listbox.pack() listbox.insert(END, Text1) listbox.insert(END, Text2) listbox.insert(END, Text3) listbox.selection_set(first=0, last=None) listbox.configure(exportselection=False) listbox.configure(state=DISABLED) Now when I change state to NORMAL, selected item is being highlighted. Is there a way I could disable widget (i.e. No response on mouse clicks) but keep the selected object remain highlighted? Intent: I want to utilise this widget on wizard App that I am creating. I would like this widget to indicate the current page / wizard number which the user selected. Is there any other widget I could use instead of it? (Labels possibly?) -- http://mail.python.org/mailman/listinfo/python-list