Title
stringlengths
11
150
A_Id
int64
518
72.5M
Users Score
int64
-42
283
Q_Score
int64
0
1.39k
ViewCount
int64
17
1.71M
Database and SQL
int64
0
1
Tags
stringlengths
6
105
Answer
stringlengths
14
4.78k
GUI and Desktop Applications
int64
0
1
System Administration and DevOps
int64
0
1
Networking and APIs
int64
0
1
Other
int64
0
1
CreationDate
stringlengths
23
23
AnswerCount
int64
1
55
Score
float64
-1
1.2
is_accepted
bool
2 classes
Q_Id
int64
469
42.4M
Python Basics and Environment
int64
0
1
Data Science and Machine Learning
int64
0
1
Web Development
int64
1
1
Available Count
int64
1
15
Question
stringlengths
17
21k
Using IronPython to learn the .NET framework, is this bad?
1,504,904
5
4
477
0
c#,.net,ironpython
You can definitely do that to learn the class library, but I'm not sure if it's such a good idea when it comes to fundamental CLR concepts (e.g. delegates and events). You'll need to pay attention and distinguish what is strictly an IronPython feature, and what is CLR feature exposed in IronPython in a way that matches its dynamic semantics better.
0
0
0
1
2009-10-01T15:55:00.000
4
0.244919
false
1,504,804
1
0
1
3
Because I'm a Python fan, I'd like to learn the .NET framework using IronPython. Would I be missing out on something? Is this in some way not recommended? EDIT: I'm pretty knowledgeable of Java ( so learning/using a new language is not a problem for me ). If needed, will I be able to use everything I learned in IronPython ( excluding language featurs ) to write C# code?
Network programming abstraction, decomposition
1,506,213
0
0
290
0
python,networking,network-programming,twisted
Why not use a database instead of "just a structure"? Both relational and non-relational DBs offer many practical advantages (separate processes using them, take care of replication [[and/or snapshots, backups, ...]], rich functionality if you need it for the "queries", and so on, and so forth). Worst case, the "just a structure" can be handled by a third process that's entirely dedicated to it (basically mimicking what any DB engine would offer -- though the engine would probably do it better and faster;-), allowing you to at least keep a good decomposition (with the two server processes both interacting with the "datastore process").
0
1
0
0
2009-10-01T18:45:00.000
3
0
false
1,505,744
0
0
1
1
I have a problem as follows: Server process 1 Constantly sends updates that occur to a datastore Server process 2 Clients contact the server, which queries the datastore, and returns a result The thing is, the results that process 1 and process 2 are sending back the client are totally different and unrelated. How does one decompose this? Do you just have one process constantly sending data, and define the protocol to have a bit which corresponds to whether the return type is 1 or 2? Do you have two processes? How do they share the datastore then (it is just a structure not a database)? Thanks!
Converting urls into lowercase?
1,512,414
3
0
344
0
python,google-app-engine,web-applications
You'd have to wrap the instance of WSGIApplication with your own WSGI app that lowercases the URL in the WSGI environment -- but then the environment would just stay modified, which may have other unpleasant effects. Why not just add (?i) to the regex patterns you use in urlpatterns instead?
0
0
0
0
2009-10-03T00:21:00.000
2
1.2
true
1,512,389
0
0
1
1
Is there any straightforward to convert all incoming urls to lowercase before they get matched against urlpatterns in run_wsgi_app(webapp.WSGIApplication(urlpatterns))?
Deploying a web service to my Google App Engine application
1,514,062
1
0
369
0
iphone,python,web-services,google-app-engine
Looks like you're not setting the Content-Type header correctly in your service (assuming you ARE actually trying to send XML -- e.g. SOAP, XML-RPC, &c). What code are you using to set that header? Without some indication about what protocol you're implementing and via what framework, it's impossible to help in detail...!
0
1
0
0
2009-10-03T07:04:00.000
2
0.099668
false
1,513,038
0
0
1
2
We made a simple application and using GoogleAppEngineLauncher (GAEL) ran that locally. Then we deployed, using GAEL again, to our appid. It works fine. Now, we made a web service. We ran that locally using GAEL and a very thin local python client. It works fine. We deployed that, and we get this message when we try to visit our default page: "Move along people, there is nothing to see here" We modified our local client and tried to run that against our google site and we got an error that looked like: Response is "text/plain", not "text/xml" Any ideas where we are falling down in our deployment or config for using a web service with google app engine? Any help appreciated! Thanks // :)
Deploying a web service to my Google App Engine application
1,604,138
0
0
369
0
iphone,python,web-services,google-app-engine
Looks like we aren't going to get to the bottom of this one. Just not enough information available at debug time. We've managed to affect a fix on the service, although I hate ot admit it we never found out what was causing this bug.
0
1
0
0
2009-10-03T07:04:00.000
2
1.2
true
1,513,038
0
0
1
2
We made a simple application and using GoogleAppEngineLauncher (GAEL) ran that locally. Then we deployed, using GAEL again, to our appid. It works fine. Now, we made a web service. We ran that locally using GAEL and a very thin local python client. It works fine. We deployed that, and we get this message when we try to visit our default page: "Move along people, there is nothing to see here" We modified our local client and tried to run that against our google site and we got an error that looked like: Response is "text/plain", not "text/xml" Any ideas where we are falling down in our deployment or config for using a web service with google app engine? Any help appreciated! Thanks // :)
How to get a http page using mechanize cookies?
1,513,899
2
3
1,699
0
python,mechanize
Some wild ideas: Fetch the second page before filling in the form? Or fetch the new page and then goBack()? Although maybe that will reset the values.
0
0
1
0
2009-10-03T14:08:00.000
3
0.132549
false
1,513,823
0
0
1
1
There is a Python mechanize object with a form with almost all values set, but not yet submitted. Now I want to fetch another page using cookies from mechanize instance, but without resetting the page, forms and so on, e.g. so that the values remain set (I just need to get body string of another page, nothing else). So is there a way to: Tell mechanize not to reset the page (perhaps, through UserAgentBase)? Make urllib2 use mechanize's cookie jar? NB: urllib2.HTTPCookieProcessor(self.br._ua_handlers["_cookies"].cookiejar) doesn't work Any other way to pass cookie to urllib?
CherryPy vs Django
1,514,830
5
35
26,287
0
python,django,cherrypy
CherryPy is web server "http framework", while Django supports web application front-to-end: it provides object-relational mapper, template, session management, automagically generates DB schema and all CRUD screens, and more.
0
0
0
0
2009-10-03T20:26:00.000
7
0.141893
false
1,514,755
0
0
1
7
CherryPy vs Django, which would you use and why?
CherryPy vs Django
13,001,017
4
35
26,287
0
python,django,cherrypy
I think they're both great, but I'm not a fan of full stack frameworks. CherryPy is a lot easier to use and much more flexible.
0
0
0
0
2009-10-03T20:26:00.000
7
0.113791
false
1,514,755
0
0
1
7
CherryPy vs Django, which would you use and why?
CherryPy vs Django
1,514,816
45
35
26,287
0
python,django,cherrypy
They're not exactly comparable. CherryPy provides url routing and a request/response abstraction, which makes prototyping very easy (although I find vanilla mod_python just as convenient). Django is a complete web application "stack", including a templating system and an object-relational mapper.
0
0
0
0
2009-10-03T20:26:00.000
7
1.2
true
1,514,755
0
0
1
7
CherryPy vs Django, which would you use and why?
CherryPy vs Django
1,514,785
6
35
26,287
0
python,django,cherrypy
I would use Django because of its large user base and existing modules (including the built-in admin interface) but I would imaging that CherryPy is more flexible than Django. You just have to look at the available options, figure out what you want to do and choose the platform that supports that the best.
0
0
0
0
2009-10-03T20:26:00.000
7
1
false
1,514,755
0
0
1
7
CherryPy vs Django, which would you use and why?
CherryPy vs Django
1,514,768
6
35
26,287
0
python,django,cherrypy
Django, because the community is so much larger. You'll find more 3rd-party modules you can use and you'll find much more support.
0
0
0
0
2009-10-03T20:26:00.000
7
1
false
1,514,755
0
0
1
7
CherryPy vs Django, which would you use and why?
CherryPy vs Django
1,520,944
11
35
26,287
0
python,django,cherrypy
Though e.e. coli has already provided the accepted answer (and a good one at that), one thing I'll say in favor of CherryPy is that it is also implements WSGI out of the box. What this means is that, unlike the mod_python approach mentioned (which I believe is still an Apache-only solution)*, it provides abstraction from your web server. If you are all Apache all the time, this isn't so much a win, but if you ever think you may want to try alternate web servers, such as Lighttpd, then you can swap your web server w/o also having to make adjustments in your Python app. This was a big win for me personally. *I don't mention Django here because I'm not a Django user (I don't like "full stack" frameworks) and so will leave any comments regarding it to it's many fans - all of whom are more qualified than I to answer questions about it.
0
0
0
0
2009-10-03T20:26:00.000
7
1
false
1,514,755
0
0
1
7
CherryPy vs Django, which would you use and why?
CherryPy vs Django
7,599,911
13
35
26,287
0
python,django,cherrypy
Django is vast, and difficult to learn, functions, tags and what not, you will absolutely are a computational genius if you have figured Django out completely. "full-stack" means every thing is available, you just have to spend the time looking for it :( CherryPy is light and clean and far less complex. Compare the starter tutorials 1pg vs 4pgs you know what I mean. Its the difference between the "full-stack" java and the light and easy perl. PS: the Django admin interface ROCKS!!
0
0
0
0
2009-10-03T20:26:00.000
7
1
false
1,514,755
0
0
1
7
CherryPy vs Django, which would you use and why?
Need help in designing a phone book application on python running on google app engine
1,519,020
0
0
420
1
python,google-app-engine,bulk-load
I think you're going to need to be more specific as to what problem you're having. As far as bulk loading goes, there's lots of bulkloader documentation around; or are you asking about model design? If so, we need to know more about how you plan to search for users. Do you need partial string matches? Sorting? Fuzzy matching?
0
0
0
0
2009-10-05T07:50:00.000
2
0
false
1,518,725
0
0
1
1
Hi I want some help in building a Phone book application on python and put it on google app engine. I am running a huge db of 2 million user lists and their contacts in phonebook. I want to upload all that data from my servers directly onto the google servers and then use a UI to retrieve the phone book contacts of each user based on his name. I am using MS SQL sever 2005 as my DB. Please help in putting together this application. Your inputs are much appreciated.
Basic Comet in Python using just std lib
1,751,708
0
1
719
0
python,comet
Extending what lost-theory has said, if you want to use comet for a passing messages between clients then you need to implement something like pubsub. Using something like tornado for the pubsub is much simpler than with the single threaded wsgiref servers.
0
1
0
0
2009-10-05T16:04:00.000
3
0
false
1,520,953
0
0
1
2
I'm developing a web interface for an already existing desktop application. I've been looking for a way to allow the server to push content to the browser and ended up reaching Comet. Navigating through the internet, and most of the questions here, I got answers like twisted, orbited, tornado and most of them even point to java applications like Jetty or StreamHub. Without going too much deeper in this, I'd like to know is there's a chance to implement Comet-like communication using just standard lib modules like BaseHTTPServer and keep things as simple as possible as I don't need so much power and efficiency. Note: Jython is a possibility, but I'd like to keep it with as less requirements as possible.
Basic Comet in Python using just std lib
1,520,980
0
1
719
0
python,comet
This is possible. Just don't close the connection to the client.
0
1
0
0
2009-10-05T16:04:00.000
3
0
false
1,520,953
0
0
1
2
I'm developing a web interface for an already existing desktop application. I've been looking for a way to allow the server to push content to the browser and ended up reaching Comet. Navigating through the internet, and most of the questions here, I got answers like twisted, orbited, tornado and most of them even point to java applications like Jetty or StreamHub. Without going too much deeper in this, I'd like to know is there's a chance to implement Comet-like communication using just standard lib modules like BaseHTTPServer and keep things as simple as possible as I don't need so much power and efficiency. Note: Jython is a possibility, but I'd like to keep it with as less requirements as possible.
flup/fastcgi cpu usage under no-load conditions
1,531,138
2
1
792
0
python,django,fastcgi,lighttpd,flup
I've looked at this on django running as fastcgi on both Slicehost (django 1.1, python 2.6) and Dreamhost (django 1.0, python 2.5), and I can say this: Running the top command shows the processes use a large amount of CPU to start up for ~2-3 seconds, then drop down to 0 almost immediately. Running the ps aux command after starting the django app shows something similar to what you describe, however this is actually misleading. From the Ubuntu man pages for ps: CPU usage is currently expressed as the percentage of time spent running during the entire lifetime of a process. This is not ideal, and it does not conform to the standards that ps otherwise conforms to. CPU usage is unlikely to add up to exactly 100%. Basically, the %CPU column shown by ps is actually an average over the time the process has been running. The decay you see is due to the high initial spike followed by inactivity being averaged over time.
0
0
0
0
2009-10-05T23:02:00.000
2
1.2
true
1,522,844
0
0
1
2
I'm running Django as threaded fastcgi via flup, served by lighttpd, communicating via sockets. What is the expected CPU usage for each fastcgi thread under no load? On startup, each thread runs at 3-4% cpu usage for a while, and then backs off to around .5% over the course of a couple of hours. It doesn't sink below this level. Is this much CPU usage normal? Do I have some bug in my code that is causing the idle loop to require more processing than it should? I expected the process to use no measurable CPU when it was completely idle. I'm not doing anything ridiculously complicated with Django, definitely nothing that should require extended processing. I realize that this isn't a lot of load, but if it's a bug I introduced, I would like to fix it.
flup/fastcgi cpu usage under no-load conditions
1,526,653
0
1
792
0
python,django,fastcgi,lighttpd,flup
Your fast-cgi threads must not consume any (noticeable) CPU if there are no requests to process. You should investigate the load you are describing. I use the same architecture and my threads are completely idle.
0
0
0
0
2009-10-05T23:02:00.000
2
0
false
1,522,844
0
0
1
2
I'm running Django as threaded fastcgi via flup, served by lighttpd, communicating via sockets. What is the expected CPU usage for each fastcgi thread under no load? On startup, each thread runs at 3-4% cpu usage for a while, and then backs off to around .5% over the course of a couple of hours. It doesn't sink below this level. Is this much CPU usage normal? Do I have some bug in my code that is causing the idle loop to require more processing than it should? I expected the process to use no measurable CPU when it was completely idle. I'm not doing anything ridiculously complicated with Django, definitely nothing that should require extended processing. I realize that this isn't a lot of load, but if it's a bug I introduced, I would like to fix it.
Update a gallery webpage via Dropbox?
2,074,899
2
2
4,092
0
php,python,html,dropbox
If you can install the DropBox client on the webserver then it would be simple to let it sync your folder and then iterate over the contents of the folder with a programming language (PHP, Python, .NET etc) and produce the gallery page. This could be done every time the page is requested or as a scheduled job which recreayes a static page. This is all dependent on you having access to install the client on your server.
0
0
1
0
2009-10-05T23:43:00.000
3
0.132549
false
1,522,951
0
0
1
1
I'd like to know if the following situation and scripts are at all possible: I'm looking to have a photo-gallery (Javascript) webpage that will display in order of the latest added to the Dropbox folder (PHP or Python?). That is, when someone adds a picture to the Dropbox folder, there is a script on the webpage that will check the Dropbox folder and then embed those images onto the webpage via the newest added and the webpage will automatically be updated. Is it at all possible to link to a Dropbox folder via a webpage? If so, how would I best go about using scripts to automate the process of updating the webpage with new content? Any and all help is very appreciated, thanks!
Werkzeug in General, and in Python 3.1
1,622,505
1
2
2,259
1
python,python-3.x,werkzeug
I can only answer question one: I started using it for some small webstuff but now moved on to rework larger apps with it. Why Werkzeug? The modular concept is really helpful. You can hook in modules as you like, make stuff easily context aware and you get good request file handling for free which is able to cope with 300mb+ files by not storing it in memory. Disadvantages... Well sometimes modularity needs some upfront thought (django f.ex. gives you everything all at once, stripping stuff out is hard to do there though) but for me it works fine.
0
1
0
0
2009-10-06T05:13:00.000
3
0.066568
false
1,523,706
0
0
1
3
I've been looking really hard at all of the way**(s)** one can develop web applications using Python. For reference, we are using RHEL 64bit, apache, mod_wsgi. History: PHP + MySQL years ago PHP + Python 2.x + MySQL recently and current Python + PostgreSQL working on it We use a great library for communicating between PHP and Python (interface in PHP, backend in Python)... However, with a larger upcoming project starting, using 100% python may be very advantagous. We typically prefer not to have a monolithic framework dictating how things are done. A collection of useful helpers and utilities are much preferred (be it PHP or Python). Question 1: In reading a number of answers from experienced Python users, I've seen Werkzeug recommended a number of times. I would love it if several people with direct experience using Werkzeug to develop professional web applications could comment (in as much detail as their fingers feel like) why they use it, why they like it, and anything to watch out for. Question 2: Is there a version of Werkzeug that supports Python 3.1.1. I've succefully installed mod_wsgi on Apache 2.2 with Python 3.1.1. If there is not a version, what would it take to upgrade it to work on Python 3.1? Note: I've run 2to3 on the Werkzeug source code, and it does python-compile without Edit: The project that we are starting is not slated to be finished until nearly a year from now. At which point, I'm guessing Python 3.X will be a lot more mainstream. Furthermore, considering that we are running the App (not distributing it), can anyone comment on the viability of bashing through some of the Python 3 issues now, so that when a year from now arrives, we are more-or-less already there? Thoughts appreciated!
Werkzeug in General, and in Python 3.1
1,523,934
1
2
2,259
1
python,python-3.x,werkzeug
I haven't used Werkzeug, so I can only answer question 2: No, Werkzeug does not work on Python 3. In fact, very little works on Python 3 as of today. Porting is not difficult, but you can't port until all your third-party libraries have been ported, so progress is slow. One big stopper has been setuptools, which is a very popular package to use. Setuptools is unmaintained, but there is a maintained fork called Distribute. Distribute was released with Python 3 support just a week or two ago. I hope package support for Python 3 will pick up now. But it will still be a long time, at least months probably a year or so, before any major project like Werkzeug will be ported to Python 3.
0
1
0
0
2009-10-06T05:13:00.000
3
0.066568
false
1,523,706
0
0
1
3
I've been looking really hard at all of the way**(s)** one can develop web applications using Python. For reference, we are using RHEL 64bit, apache, mod_wsgi. History: PHP + MySQL years ago PHP + Python 2.x + MySQL recently and current Python + PostgreSQL working on it We use a great library for communicating between PHP and Python (interface in PHP, backend in Python)... However, with a larger upcoming project starting, using 100% python may be very advantagous. We typically prefer not to have a monolithic framework dictating how things are done. A collection of useful helpers and utilities are much preferred (be it PHP or Python). Question 1: In reading a number of answers from experienced Python users, I've seen Werkzeug recommended a number of times. I would love it if several people with direct experience using Werkzeug to develop professional web applications could comment (in as much detail as their fingers feel like) why they use it, why they like it, and anything to watch out for. Question 2: Is there a version of Werkzeug that supports Python 3.1.1. I've succefully installed mod_wsgi on Apache 2.2 with Python 3.1.1. If there is not a version, what would it take to upgrade it to work on Python 3.1? Note: I've run 2to3 on the Werkzeug source code, and it does python-compile without Edit: The project that we are starting is not slated to be finished until nearly a year from now. At which point, I'm guessing Python 3.X will be a lot more mainstream. Furthermore, considering that we are running the App (not distributing it), can anyone comment on the viability of bashing through some of the Python 3 issues now, so that when a year from now arrives, we are more-or-less already there? Thoughts appreciated!
Werkzeug in General, and in Python 3.1
1,525,943
3
2
2,259
1
python,python-3.x,werkzeug
mod_wsgi for Python 3.x is also not ready. There is no satisfactory definition of WSGI for Python 3.x yet; the WEB-SIG are still bashing out the issues. mod_wsgi targets a guess at what might be in it, but there are very likely to be changes to both the spec and to standard libraries. Any web application you write today in Python 3.1 is likely to break in the future. It's a bit of a shambles. Today, for webapps you can only realistically use Python 2.x.
0
1
0
0
2009-10-06T05:13:00.000
3
0.197375
false
1,523,706
0
0
1
3
I've been looking really hard at all of the way**(s)** one can develop web applications using Python. For reference, we are using RHEL 64bit, apache, mod_wsgi. History: PHP + MySQL years ago PHP + Python 2.x + MySQL recently and current Python + PostgreSQL working on it We use a great library for communicating between PHP and Python (interface in PHP, backend in Python)... However, with a larger upcoming project starting, using 100% python may be very advantagous. We typically prefer not to have a monolithic framework dictating how things are done. A collection of useful helpers and utilities are much preferred (be it PHP or Python). Question 1: In reading a number of answers from experienced Python users, I've seen Werkzeug recommended a number of times. I would love it if several people with direct experience using Werkzeug to develop professional web applications could comment (in as much detail as their fingers feel like) why they use it, why they like it, and anything to watch out for. Question 2: Is there a version of Werkzeug that supports Python 3.1.1. I've succefully installed mod_wsgi on Apache 2.2 with Python 3.1.1. If there is not a version, what would it take to upgrade it to work on Python 3.1? Note: I've run 2to3 on the Werkzeug source code, and it does python-compile without Edit: The project that we are starting is not slated to be finished until nearly a year from now. At which point, I'm guessing Python 3.X will be a lot more mainstream. Furthermore, considering that we are running the App (not distributing it), can anyone comment on the viability of bashing through some of the Python 3 issues now, so that when a year from now arrives, we are more-or-less already there? Thoughts appreciated!
Is an applet a proper solution for hardware detection and driver install?
1,524,622
0
0
101
0
c#,python,ruby
Applet should be better if your application is not depended on IE. If for IE only then use COM/ActiveX
0
0
0
0
2009-10-06T09:45:00.000
1
0
false
1,524,606
0
0
1
1
Can I use applets to inform me which hardware is installed on client system (fingerprint reader)? And if it is installed, can it tell me its version, so that it can download the proper plugin from a site? So that after everything is OK, the user can use his fingerprint reader to authenticate himself?
How do I display images at different times on webpage
1,524,724
0
1
328
0
python,django
You could make a Date object in javascript. Check the current time and depending on the time, you set the img src to whatever image you want for that time of day :) or hide the image through myimg.style.visibility = "hidden" if you dont want to display an image at that moment.
0
0
1
0
2009-10-06T10:15:00.000
4
0
false
1,524,713
0
0
1
2
I'm supposed to display images at certain times of the day on the webpage, Please can anyone tell me how to go about it
How do I display images at different times on webpage
1,524,812
0
1
328
0
python,django
If you need to change the image before a page refresh, you could use jquery ajax call to get the correct image. jquery has some interval functionality which would allow this.
0
0
1
0
2009-10-06T10:15:00.000
4
0
false
1,524,713
0
0
1
2
I'm supposed to display images at certain times of the day on the webpage, Please can anyone tell me how to go about it
Django Vote Up/Down method
1,528,617
11
29
12,621
0
python,django,voting
Whatever you do, make sure that it's submitted by POST and not GET; GET requests should never alter database information.
0
0
0
0
2009-10-06T23:10:00.000
4
1
false
1,528,583
0
0
1
1
I am making a small app that lets users vote items either up or down. I'm using Django (and new to it!). I am just wondering, what is the best way to present the upvote link to the user. As a link, button or something else? I have already done something like this in php with a different framework but I'm not sure if I can do it the same way. Should I have a method for up/down vote and then display a link to the user to click. When they click it, it performs the method and refreshes the page?
Can a WIN32 program authenticate into Django authentication system, using MYSQL?
1,529,146
0
1
203
1
python,windows,django,authentication,frameworks
If the only thing the WIN32 app uses the MS-SQL Server for is Authentication/Authorization then you could write a new Authentication/Authorization provider that uses a set of Web Services (that you would have to create) that expose the Django provider.
0
0
0
0
2009-10-07T01:59:00.000
2
0
false
1,529,128
0
0
1
1
I have a web service with Django Framework. My friend's project is a WIN32 program and also a MS-sql server. The Win32 program currently has a login system that talks to a MS-sql for authentication. However, we would like to INTEGRATE this login system as one. Please answer the 2 things: I want scrap the MS-SQL to use only the Django authentication system on the linux server. Can the WIN32 client talk to Django using a Django API (login)? If not, what is the best way of combining the authentication?
Can a WIN32 program authenticate into Django authentication system, using MYSQL?
1,581,622
1
0
103
1
python,mysql,windows,django
The Win32 client can act like a web client to pass the user's credentials to the server. You will want to store the session cookie you get once you are authenticated and use that cookie in all following requests
0
0
0
0
2009-10-07T02:00:00.000
1
1.2
true
1,533,259
0
0
1
1
I have a web service with Django Framework. My friend's project is a WIN32 program and also a MS-sql server. The Win32 program currently has a login system that talks to a MS-sql for authentication. However, we would like to INTEGRATE this login system as one. Please answer the 2 things: I want scrap the MS-SQL to use only the Django authentication system on the linux server. Can the WIN32 client talk to Django using a Django API (login)? If not, what is the best way of combining the authentication?
Python: how to show results on a web page?
1,537,103
2
11
29,818
0
python
Whose web server? If it is a web server provided by a web hosting company or someone else and you don't have control over it, you need to ascertain in what way they support the use of Python for writing web applications. It isn't enough to know just that they have Python available. As pointed out by others, is likely that at least CGI scripts which use Python will be supported. CGI however is not really practical for running large Python web frameworks such as Django. It is possible though that the web server might also support FASTCGI. If that is the case it becomes possible to use such larger Python web frameworks as FASTCGI uses persistent processes where as CGI creates a process for each request, where the overhead of large Python web frameworks generally makes the use of CGI impractical as a result. If the Apache server is controlled by others using a standalone Python web server such as wsgiref and proxying to it from Apache isn't going to be doable either as you can't setup Apache to do it. So, find out how use of Python for web applications is supported and work out whether you are just a user of the Apache instance, or whether you have some measure of control of changing its global configuration files and restarting it. This will dictate what you can do and use.
0
0
0
0
2009-10-07T20:40:00.000
8
0.049958
false
1,534,070
0
0
1
1
Most likely it's a dumb question for those who knows the answer, but I'm a beginner, and here it goes: I have a Python script which I run in a command-line with some parameter, and it prints me some results. Let's say results are some HTML code. I never done any Python programming for web, and couldn't figure it out... I need to have a page (OK, I know how to upload files to a server, Apache is running, Python is installed on the server...) with an edit field, which will accept that parameter, and Submit button, and I need it to "print" the results on a web page after the user submitted a proper parameter, or show any output that in a command-line situation are printed. I've read Dive Into Python's chapters about "HTML Processing" and "HTTP Web Services", but they do not describe what I'm looking for. If the answer isn't short, I would very much appreciate links to the more relevant stuff to read or maybe the key words to google for it.
What do I need to know/learn for automated python deployment?
1,537,585
2
2
1,087
0
python,deployment,virtualenv
You already mentioned buildout, and it's all you need. Google for example buildouts for the different parts. Takes a while to set it up the first time, but then you can reuse the setup between different projects too. Let supervisord start everything, not just the python server. Then start supervisord at reboot either fron cron or init.d.
0
0
0
1
2009-10-08T11:40:00.000
3
1.2
true
1,537,298
0
0
1
1
I'm starting a new webapp project in Python to get into the Agile mind-set and I'd like to do things "properly" with regards to deployment. However, I'm finding the whole virtualenv/fabric/zc.buildout/etc stuff a little confusing - I'm used to just FTP'ing PHP files to a server and pointing a webserver at it. After deployment the server set-up would look something like: Nginx --proxy-to--> WSGI Webserver (Spawning) --> WSGI Middleware --> WSGI App (probably MNML or similar) with the python webserver being managed by supervisord. What sort of deployment set-up/packages/apps should I be looking into? And is there a specific directory structure I need to stick to with my app to ease deployment?
Difference between GET and FILTER in Django model layer
1,541,322
48
20
9,344
0
python,django
I don't know if you really need an example, it's quite easy: if you know it's one object that matches your query, use get. It will fail if it's more than one. otherwise use filter, which gives you a list of objects. To be more precise: MyTable.objects.get(id=x).whatever gives you the whatever property of your object. get() raises MultipleObjectsReturned if more than one object was found. The MultipleObjectsReturned exception is an attribute of the model class. get() raises a DoesNotExist exception if an object wasn’t found for the given parameters. This exception is also an attribute of the model class. MyTable.objects.filter(somecolumn=x) is not only usable as a list, but you can also query it again, something like MyTable.objects.filter(somecolumn=x).order_by('date'). The reason is that it's not actually a list, but a query object. You can iterate through it like through a list: for obj in MyTable.objects.filter(somecolumn=x)
0
0
0
0
2009-10-09T00:21:00.000
1
1.2
true
1,541,249
0
0
1
1
What is the difference, please explain them in laymen's terms with examples. Thanks!
A .net wrapper for Google App Engine?
17,356,271
0
3
3,521
0
java,.net,python,web-services,google-app-engine
Python has a .NET alternative called IronPython. But I don't think it will work in GAE as it supports only pure python. I am also facing a similar problem trying to port a source written in C#.net into GAE compatible code. I'm going to work around it by re-inventing the spokes of the wheel (not the wheel itself) by re-doing the UI using SVG or some other method. Have you considered that?
0
1
0
0
2009-10-09T03:59:00.000
3
0
false
1,541,722
0
0
1
1
Does anyone know of a .net wrapper around either python or java Google App Engine services? Any help appreciated // :)
Why does this happen in my template for Django?
1,549,656
1
0
180
0
python,django
Try removing the space between the rec.artist_name and the |. So you should have this: {{ rec.artist_name|safe }} That'll fix the autoescaping, but I think the other commentors are correct in saying that you're storing the %20 into the db. So you'll probably have to fix it on that end of things.
0
0
0
0
2009-10-11T01:42:00.000
2
0.099668
false
1,549,606
0
0
1
1
simple%20minds is displayed when do this: {{ rec.artist_name }} How do I remove the %20...and make it spaces? When I put | safe as a fitler, the error is: Could not parse the remainder: ' | safe' from 'active.artist_name | safe' Thanks.
URLs stored in database for Django site
1,563,359
1
1
3,215
1
python,database,django,url,content-management-system
Your question is a little bit twisted, but I think what you're asking for is something similar to how django.contrib.flatpages handles this. Basically it uses middleware to catch the 404 error and then looks to see if any of the flatpages have a URL field that matches. We did this on one site where all of the URLs were made "search engine friendly". We overrode the save() method, munged the title into this_is_the_title.html (or whatever) and then stored that in a separate table that had a URL => object class/id mapping.ng (this means it is listed before flatpages in the middleware list).
0
0
0
0
2009-10-13T21:43:00.000
2
0.099668
false
1,563,088
0
0
1
1
I've produced a few Django sites but up until now I have been mapping individual views and URLs in urls.py. Now I've tried to create a small custom CMS but I'm having trouble with the URLs. I have a database table (SQLite3) which contains code for the pages like a column for header, one for right menu, one for content.... so on, so on. I also have a column for the URL. How do I get Django to call the information in the database table from the URL stored in the column rather than having to code a view and the URL for every page (which obviously defeats the purpose of a CMS)? If someone can just point me at the right part of the docs or a site which explains this it would help a lot. Thanks all.
What pure Python library should I use to scrape a website?
1,563,177
11
2
1,959
0
python,google-app-engine,xpath,beautifulsoup,mechanize
Beautiful Soup.
0
0
1
0
2009-10-13T21:58:00.000
5
1
false
1,563,165
0
0
1
2
I currently have some Ruby code used to scrape some websites. I was using Ruby because at the time I was using Ruby on Rails for a site, and it just made sense. Now I'm trying to port this over to Google App Engine, and keep getting stuck. I've ported Python Mechanize to work with Google App Engine, but it doesn't support DOM inspection with XPATH. I've tried the built-in ElementTree, but it choked on the first HTML blob I gave it when it ran into '&mdash'. Do I keep trying to hack ElementTree in there, or do I try to use something else? thanks, Mark
What pure Python library should I use to scrape a website?
1,563,301
6
2
1,959
0
python,google-app-engine,xpath,beautifulsoup,mechanize
lxml -- 100x better than elementtree
0
0
1
0
2009-10-13T21:58:00.000
5
1
false
1,563,165
0
0
1
2
I currently have some Ruby code used to scrape some websites. I was using Ruby because at the time I was using Ruby on Rails for a site, and it just made sense. Now I'm trying to port this over to Google App Engine, and keep getting stuck. I've ported Python Mechanize to work with Google App Engine, but it doesn't support DOM inspection with XPATH. I've tried the built-in ElementTree, but it choked on the first HTML blob I gave it when it ran into '&mdash'. Do I keep trying to hack ElementTree in there, or do I try to use something else? thanks, Mark
How can I make Zenoss recognize skin changes?
1,578,608
1
0
433
0
python,zope,zenoss
The problem turned out to be that none of the template changes I made actually had any impact on the final page output. The changes were picked up, they just didn't matter.
0
0
0
0
2009-10-15T14:16:00.000
1
1.2
true
1,572,661
0
0
1
1
I'm writing a ZenPack for Zenoss which includes a new DataSource. The DataSource has a ToOne relationship with another persistent object and I'm trying to construct the user interface to allow a user to specify the value of this relationship. I've given the DataSource a factory_type_information attribute with an "immediate_view" key mapped to the name of a skin/template - "viewAgentScriptDataSource". In my ZenPack's skins directory, I created viewAgentScriptDataSource.pt. Zenoss seems to have liked this and now when I view an instance of the DataSource, I see a page based on viewAgentScriptDataSource.pt. However, after this first success, any edits I make to the skin/template file are ignored. I tried replacing the dummy content of the file with something more realistic and reloading the data source view. The dummy content still appears. I tried restarting Zenoss and reloading the view. The dummy content still appears. I tried deleting my ZenPack and re-installing it. The dummy content still appears. How do I get Zenoss to load the new contents of the skin file?
What is the typical workflow for development of a Zenoss ZenPack?
7,033,005
2
2
1,306
0
python,database,zenoss
I am working on this very problem this week with Zenoss 3.1. Caveat- If you make a bad zenpack - no wait - when you make a bad one, it can get stuck in Zope's db, and there is no way to get it out AFAIK. So- First use the GUI to make a complete backup of a clean Zenoss site. Later you will need to restore using zenrestore to clean up the mess. There are two answers, I think: 1) if its a portlet- Portlets can only be installed using an egg. Normally Zenoss docs recommend you create eggs using the GUI interface, but that makes for a ridiculous development iteration. However there are explanations in the docs of other ways. If your code, possibly starting with a well-know community portlet like Show Graph or Google Maps, is correct for portlets as opposed to regular zenpacks, then you name the top directory of your code in the standard zenpack form, with versions. cd into that directory and run python setup.py bdist_egg which will create dist and build directories. The egg will be in the dist directory. Install the egg using the GUI. Notice its not fully installed... grrrrrr. Restart the daemons - zopectl restart ; zenhub restart Test. Delete the portlet using the GUI. Repeat. Gotchas: - You must have setup.py and maybe one or more of- INSTALL.txt MANIFEST.in README.txt in the top directory. Setup.py must match your directory names. If you are using old or copied init.py files with their init.pyc versions, then you may need to delete these pyc files to force the python script to re-create them. I like to run the script as follows just to be certain: rm -f ./dist ./build ; python setup.py bdist_egg 2) If it's a regular zenpack The docs tell you how to do this. Get your zenpack installed from whatever source; often you will just start with the empty one created by the GUI. Copy the files from /usr/local/zenoss/zenoss/Zenpacks/yourzenpack into your code development area. Un-install the zenpack using the GUI. On the command line as zenoss user, run the zpack install --link command ( look up syntax) to install the zenpack thats actually in your code area. Test Update your code. On the command line as zenoss, run zopectl restart ; zenhub restart Test. Repeat. Be Happy.
0
0
0
0
2009-10-15T15:35:00.000
2
0.197375
false
1,573,166
0
0
1
1
ZenPack development seems to involve the creation of a variety of persistent state. There are model classes which represent explicitly persistent state. There are skins which are associated with model objects. There are organizers and instances of persistent classes (data sources, graphs, etc). Considering that during development, many things are done wrong before they're done right, and considering that loading up a ZenPack that does things wrong has persistent consequences on the Zenoss instance it is loaded into and that these consequences are hard to undo, what is the usual approach for development of a ZenPack?
Long, slow operation in Django view causes timeout. Any way for Python to speak AJAX instead?
1,582,971
7
5
3,585
0
python,ajax,django,timeout
Ajax doesn't require any particular technology on the server side. All you need is to return a response in some form that some Javascript on the client side can understand. JSON is an excellent choice here, as it's easy to create in Python (there's a json library in 2.6, and Django has django.utils.simplejson for other versions). So all you need to do is to put your data in JSON form then send it just as you would any other response - ie by wrapping it in an HTTPResponse.
0
0
0
0
2009-10-17T17:19:00.000
3
1.2
true
1,582,708
0
0
1
1
I've been programming Python a while, but DJango and web programming in general is new to me. I have a very long operation performed in a Python view. Since the local() function in my view takes so long to return, there's an HTTP timeout. Fair enough, I understand that part. What's the best way to give an HTTPresponse back to my users immediately, then dynamically show the results of some python code within the page? I suspect the answer may lie in AJAX but I;m not sure how AJAX on the client can be fed from Python on the server, or even the modules one would commonly use to do such a thing.
positioning sound with pygame?
1,583,298
0
2
2,176
0
python,audio,pygame
I think setting the separate channel volume is the only way. Pygame doesn't seem to have any notion of world space or positioning for sounds.
1
0
0
0
2009-10-17T21:32:00.000
3
0
false
1,583,284
0
0
1
1
Is there a way to do panning or 3d sound in Pygame? The only way I've found to control sound playback is to set the volume for both the left and right channels.
PHP, Python, Ruby application with multiple RDBMS
1,586,035
0
2
369
1
php,python,ruby-on-rails,database
It would be great if code written for one platform would work on every other without any modification whatsoever, but this is usually not the case and probably never will be. What the current frameworks do is about all anyone can.
0
0
0
0
2009-10-18T20:56:00.000
4
0
false
1,586,008
0
0
1
3
I start feeling old fashioned when I see all these SQL generating database abstraction layers and all those ORMs out there, although I am far from being old. I understand the need for them, but their use spreads to places they normally don't belong to. I firmly believe that using database abstraction layers for SQL generation is not the right way of writing database applications that should run on multiple database engines, especially when you throw in really expensive databases like Oracle. And this is more or less global, it doesn't apply to only a few languages. Just a simple example, using query pagination and insertion: when using Oracle one could use the FIRST_ROWS and APPEND hints(where appropriate). Going to advanced examples I could mention putting in the database lots of Stored Procedures/Packages where it makes sense. And those are different for every RDBMS. By using only a limited set of features, commonly available to many RDBMS one doesn't exploit the possibilities that those expensive and advanced database engines have to offers. So getting back to the heart of the question: how do you develop PHP, Python, Ruby etc. applications that should run on multiple database engines? I am especially interested hearing how you separate/use the queries that are especially written for running on a single RDBMS. Say you've got a statement that should run on 3 RDBMS: Oracle, DB2 and Sql Server and for each of these you write a separate SQL statement in order to make use of all features this RDBMS has to offer. How do you do it? Letting this aside, what is you opinion walking this path? Is it worth it in your experience? Why? Why not?
PHP, Python, Ruby application with multiple RDBMS
1,586,105
2
2
369
1
php,python,ruby-on-rails,database
If you want to leverage the bells and whistles of various RDBMSes, you can certainly do it. Just apply standard OO Principles. Figure out what kind of API your persistence layer will need to provide. You'll end up writing a set of isomorphic persistence adapter classes. From the perspective of your model code (which will be calling adapter methods to load and store data), these classes are identical. Writing good test coverage should be easy, and good tests will make life a lot easier. Deciding how much abstraction is provided by the persistence adapters is the trickiest part, and is largely application-specific. As for whether this is worth the trouble: it depends. It's a good exercise if you've never done it before. It may be premature if you don't actually know for sure what your target databases are. A good strategy might be to implement two persistence adapters to start. Let's say you expect the most common back end will be MySQL. Implement one adapter tuned for MySQL. Implement a second that uses your database abstraction library of choice, and uses only standard and widely available SQL features. Now you've got support for a ton of back ends (everything supported by your abstraction library of choice), plus tuned support for mySQL. If you decide you then want to provide an optimized adapter from Oracle, you can implement it at your leisure, and you'll know that your application can support swappable database back-ends.
0
0
0
0
2009-10-18T20:56:00.000
4
0.099668
false
1,586,008
0
0
1
3
I start feeling old fashioned when I see all these SQL generating database abstraction layers and all those ORMs out there, although I am far from being old. I understand the need for them, but their use spreads to places they normally don't belong to. I firmly believe that using database abstraction layers for SQL generation is not the right way of writing database applications that should run on multiple database engines, especially when you throw in really expensive databases like Oracle. And this is more or less global, it doesn't apply to only a few languages. Just a simple example, using query pagination and insertion: when using Oracle one could use the FIRST_ROWS and APPEND hints(where appropriate). Going to advanced examples I could mention putting in the database lots of Stored Procedures/Packages where it makes sense. And those are different for every RDBMS. By using only a limited set of features, commonly available to many RDBMS one doesn't exploit the possibilities that those expensive and advanced database engines have to offers. So getting back to the heart of the question: how do you develop PHP, Python, Ruby etc. applications that should run on multiple database engines? I am especially interested hearing how you separate/use the queries that are especially written for running on a single RDBMS. Say you've got a statement that should run on 3 RDBMS: Oracle, DB2 and Sql Server and for each of these you write a separate SQL statement in order to make use of all features this RDBMS has to offer. How do you do it? Letting this aside, what is you opinion walking this path? Is it worth it in your experience? Why? Why not?
PHP, Python, Ruby application with multiple RDBMS
1,587,887
2
2
369
1
php,python,ruby-on-rails,database
You cannot eat a cake and have it, choose on of the following options. Use your database abstraction layer whenever you can and in the rare cases when you have a need for a hand-made query (eg. performance reasons) stick to the lowest common denominator and don't use stored procedures or any proprietary extensions that you database has to offer. In this case deploying the application on a different RDBMS should be trivial. Use the full power of your expensive RDBMS, but take into account that your application won't be easily portable. When the need arises you will have to spend considerable effort on porting and maintenance. Of course a decent layered design encapsulating all the differences in a single module or class will help in this endeavor. In other words you should consider how probable is it that your application will be deployed to multiple RDBMSes and make an informed choice.
0
0
0
0
2009-10-18T20:56:00.000
4
1.2
true
1,586,008
0
0
1
3
I start feeling old fashioned when I see all these SQL generating database abstraction layers and all those ORMs out there, although I am far from being old. I understand the need for them, but their use spreads to places they normally don't belong to. I firmly believe that using database abstraction layers for SQL generation is not the right way of writing database applications that should run on multiple database engines, especially when you throw in really expensive databases like Oracle. And this is more or less global, it doesn't apply to only a few languages. Just a simple example, using query pagination and insertion: when using Oracle one could use the FIRST_ROWS and APPEND hints(where appropriate). Going to advanced examples I could mention putting in the database lots of Stored Procedures/Packages where it makes sense. And those are different for every RDBMS. By using only a limited set of features, commonly available to many RDBMS one doesn't exploit the possibilities that those expensive and advanced database engines have to offers. So getting back to the heart of the question: how do you develop PHP, Python, Ruby etc. applications that should run on multiple database engines? I am especially interested hearing how you separate/use the queries that are especially written for running on a single RDBMS. Say you've got a statement that should run on 3 RDBMS: Oracle, DB2 and Sql Server and for each of these you write a separate SQL statement in order to make use of all features this RDBMS has to offer. How do you do it? Letting this aside, what is you opinion walking this path? Is it worth it in your experience? Why? Why not?
how to determine if webpage has been modified
1,588,461
-1
6
2,946
0
python,diff,webpage,snapshot
just take snapshots of the files with MD5 or SHA1...if the values differ the next time you check, then they are modified.
0
0
1
0
2009-10-19T10:13:00.000
4
-0.049958
false
1,587,902
0
0
1
1
I have snapshots of multiple webpages taken at 2 times. What is a reliable method to determine which webpages have been modified? I can't rely on something like an RSS feed, and I need to ignore minor noise like date text. Ideally I am looking for a Python solution, but an intuitive algorithm would also be great. Thanks!
What are the use cases for non relational datastores?
1,588,748
2
3
587
1
python,google-app-engine,couchdb
Consider the situation where you have many entity types but few instances of each entity. In this case you will have many tables each with a few records so a relational approach is not suitable.
0
1
0
0
2009-10-19T13:36:00.000
3
0.132549
false
1,588,708
0
0
1
2
I'm looking at using CouchDB for one project and the GAE app engine datastore in the other. For relational stuff I tend to use postgres, although I much prefer an ORM. Anyway, what use cases suit non relational datastores best?
What are the use cases for non relational datastores?
1,589,186
0
3
587
1
python,google-app-engine,couchdb
In some cases that are simply nice. ZODB is a Python-only object database, that is so well-integrated with Python that you can simply forget that it's there. You don't have to bother about it, most of the time.
0
1
0
0
2009-10-19T13:36:00.000
3
0
false
1,588,708
0
0
1
2
I'm looking at using CouchDB for one project and the GAE app engine datastore in the other. For relational stuff I tend to use postgres, although I much prefer an ORM. Anyway, what use cases suit non relational datastores best?
Google App Engine compatibility layer
4,219,064
0
6
702
0
python,google-app-engine
If you develop with web2py your code will run GAE other architectures wihtout changes using any of the 10 supported relational databases. The compatibility layer covers database api (including blobs and listproperty), email, and fetching).
0
1
0
0
2009-10-19T16:33:00.000
5
0
false
1,589,743
0
0
1
1
I'm planning an application running on Google App Engine. The only worry I would have is portability. Or just the option to have the app run on a local, private cluster. I expected an option for Google App Engine applications to run on other systems, a compatibility layer, to spring up. I could imagine a GAE compatible framework utilizing Amazon SimpleDB or CouchDB to offer near 100% compatibility, if needs be through an abstraction layer. I prefer Python though Java would be acceptable. However, as far as I know, none such facility exists today. Am I mistaken and if so where could I find this Googe App Engine compatibility layer. If I'm not, the questions is "why"? Are there unforetold technical issues or is there just no demand from the market (which would potentially hint at low rates of GAE adoption). Regards, Iwan
Get the request uri outside of a RequestHandler in Google App Engine (Python)
1,593,985
2
1
786
0
python,google-app-engine
You should generally be doing everything within some sort of RequestHandler or the equivalent in your non-WebApp framework. However, if you really insist on being stuck in the early 1990s and writing plain CGI scripts, the environment variables SERVER_NAME and PATH_INFO may be what you want; see a CGI reference for more info.
0
1
1
0
2009-10-20T09:33:00.000
2
1.2
true
1,593,483
0
0
1
1
So, within a webapp.RequestHandler subclass I would use self.request.uri to get the request URI. But, I can't access this outside of a RequestHandler and so no go. Any ideas? I'm running Python and I'm new at it as well as GAE.
How do you convert a Word Document into very simple html in Python?
1,597,120
2
13
26,350
0
python,html,django,ms-word
It depends how much formatting and images you're dealing with. I do one of a couple things: Google Docs: Probably the closest you'll get to the original formatting and usable HTML. Markdown: Abandon formatting. Paste it into a plain text editor, run it through Markdown and fix the rest by hand.
0
0
0
0
2009-10-20T19:52:00.000
6
0.066568
false
1,596,911
0
0
1
2
Every now and then I receive a Word Document that I have to display as a web page. I'm currently using Django's flatpages to achieve this by grabbing the html content generated by MS Word. The generated html is quite messy. Is there a better way that can generate very simple html to solve this issue using Python?
How do you convert a Word Document into very simple html in Python?
8,174,432
2
13
26,350
0
python,html,django,ms-word
Word 2010 has the ability to "save as filtered web page". This will eliminate the overwhelming majority of the HTML that Word inserts.
0
0
0
0
2009-10-20T19:52:00.000
6
0.066568
false
1,596,911
0
0
1
2
Every now and then I receive a Word Document that I have to display as a web page. I'm currently using Django's flatpages to achieve this by grabbing the html content generated by MS Word. The generated html is quite messy. Is there a better way that can generate very simple html to solve this issue using Python?
starting my own threads within python paste
1,843,498
0
1
862
0
python,pylons,paste
To answer your basic question directly, you should be able to use threads just as you'd like. The "killing hung threads" part is paste cleaning up its own threads, not yours. There are other packages that might help, etc, but I'd suggest you start with simple threads and see how far you get. Only then will you know what you need next. (Note, "Thread.daemon" should be mostly irrelevant to you here. Setting that true will ensure a thread you start will not prevent the entire process from exiting. Doing so would mean, however, that if the process exited "cleanly" (as opposed to being forced to exit) your thread would be terminated even if it wasn't done its work. Whether that's a problem, and how you handle things like that, depend entirely on your own requirements and design.
0
0
0
0
2009-10-21T22:43:00.000
4
0
false
1,604,079
1
0
1
2
I'm writing a web application using pylons and paste. I have some work I want to do after an HTTP request is finished (send some emails, write some stuff to the db, etc) that I don't want to block the HTTP request on. If I start a thread to do this work, is that OK? I always see this stuff about paste killing off hung threads, etc. Will it kill my threads which are doing work? What else can I do here? Is there a way I can make the request return but have some code run after it's done? Thanks.
starting my own threads within python paste
1,768,292
0
1
862
0
python,pylons,paste
Take a look at gearman, it was specifically made for farming out tasks to 'workers' to handle. They can even handle it in a different language entirely. You can come back and ask if the task was completed, or just let it complete. That should work well for many tasks. If you absolutely need to ensure it was completed, I'd suggest queuing tasks in a database or somewhere persistent, then have a separate process that runs through it ensuring each one gets handled appropriately.
0
0
0
0
2009-10-21T22:43:00.000
4
0
false
1,604,079
1
0
1
2
I'm writing a web application using pylons and paste. I have some work I want to do after an HTTP request is finished (send some emails, write some stuff to the db, etc) that I don't want to block the HTTP request on. If I start a thread to do this work, is that OK? I always see this stuff about paste killing off hung threads, etc. Will it kill my threads which are doing work? What else can I do here? Is there a way I can make the request return but have some code run after it's done? Thanks.
django syncdb and an updated model
37,202,110
1
86
51,126
0
python,django,django-models
In django 1.6 At first we have run - python manage.py sql <app name> Then we have to run - python manage.py syncdb
0
0
0
0
2009-10-22T08:04:00.000
7
0.028564
false
1,605,662
0
0
1
3
I have recently updated my model, added a BooleanField to it however when I do python manage.py syncdb, it doesn't add the new field to the database for the model. How can I fix this ?
django syncdb and an updated model
27,652,020
0
86
51,126
0
python,django,django-models
If you run Django with Apache and MySQL, restart apache after making migration with makemigrations.
0
0
0
0
2009-10-22T08:04:00.000
7
0
false
1,605,662
0
0
1
3
I have recently updated my model, added a BooleanField to it however when I do python manage.py syncdb, it doesn't add the new field to the database for the model. How can I fix this ?
django syncdb and an updated model
1,605,670
2
86
51,126
0
python,django,django-models
Havent used django in a while, but i seem to remember that syncdb does perform alter commands on db tables. you have to drop the table then run again and it will create again. edit: sorry does NOT perform alter.
0
0
0
0
2009-10-22T08:04:00.000
7
0.057081
false
1,605,662
0
0
1
3
I have recently updated my model, added a BooleanField to it however when I do python manage.py syncdb, it doesn't add the new field to the database for the model. How can I fix this ?
Django: How to detect if translation is activated?
2,450,262
0
2
735
0
python,django,internationalization
Depends on application and architecture... Hack provided by Ignacio should works, but what is you will run in non activated yet thread? I would use Ignacio solution + add Queue visible by all threads, monkeypatch trans_real.activate function and set attribute in queue.
0
0
0
0
2009-10-22T08:18:00.000
3
0
false
1,605,706
0
0
1
1
django.utils.translation.get_language() returns default locale if translation is not activated. Is there a way to find out whether the translation is activated (via translation.activate()) or not?
Python debugging in Netbeans
1,606,803
1
4
2,156
0
python,netbeans
I just installed Python for NetBeans yesterday and hadn't tried the debugger, so just tried it, and I got the same error. So I thought maybe it's a Firewall issue, disabled my Firewall and retried it, and then it worked. However I restarted the Firewall and now it's still working, so I don't know. I saw the Netbeans options for Python have an input to specify the beginning listening port (which mine was 29000 not 11111 like yours).
0
1
0
0
2009-10-22T12:02:00.000
2
0.099668
false
1,606,746
0
0
1
2
I have a problem with debugging Python programs under the Netbeans IDE. When I start debugging, the debugger writes the following log and error. Thank you for help. [LOG]PythonDebugger : overall Starting >>>[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ... [LOG]This window is an interactive debugging context aware Python Shell [LOG]where you can enter python console commands while debugging >>>c:\documents and settings\aster\.netbeans\6.7\config\nbpython\debug\nbpythondebug\jpydaemon.py args = ['C:\\Documents and Settings\\aster\\.netbeans\\6.7\\config\\nbPython\\debug\\nbpythondebug\\jpydaemon.py', 'localhost', '11111'] localDebuggee= None JPyDbg connecting localhost on in= 11111 /out= 11112 ERROR:JPyDbg connection failed errno(10061) : Connection refused Debug session normal end ERROR :: Server Socket listen for debuggee has timed out (more than 20 seconds wait) java.net.SocketTimeoutException: Accept timed out thanks for answer
Python debugging in Netbeans
1,636,617
1
4
2,156
0
python,netbeans
For Python I like WingIDE from Wingware.
0
1
0
0
2009-10-22T12:02:00.000
2
0.099668
false
1,606,746
0
0
1
2
I have a problem with debugging Python programs under the Netbeans IDE. When I start debugging, the debugger writes the following log and error. Thank you for help. [LOG]PythonDebugger : overall Starting >>>[LOG]PythonDebugger.taskStarted : I am Starting a new Debugging Session ... [LOG]This window is an interactive debugging context aware Python Shell [LOG]where you can enter python console commands while debugging >>>c:\documents and settings\aster\.netbeans\6.7\config\nbpython\debug\nbpythondebug\jpydaemon.py args = ['C:\\Documents and Settings\\aster\\.netbeans\\6.7\\config\\nbPython\\debug\\nbpythondebug\\jpydaemon.py', 'localhost', '11111'] localDebuggee= None JPyDbg connecting localhost on in= 11111 /out= 11112 ERROR:JPyDbg connection failed errno(10061) : Connection refused Debug session normal end ERROR :: Server Socket listen for debuggee has timed out (more than 20 seconds wait) java.net.SocketTimeoutException: Accept timed out thanks for answer
What is a light python library that can eliminate HTML tags? (and only text)
1,620,413
4
0
746
0
python
python standard module html.parser should allow you to parse simple html content and eliminate tags. you only have to derive HTMLParser, then overload all handle_*() methods so that they output or discard content, depending on the surrounding element tags.
0
0
0
0
2009-10-25T08:31:00.000
4
1.2
true
1,620,363
0
0
1
1
I know that NLTK has it. But any else?
How do I display real-time python script output on a website?
11,067,328
0
3
5,553
0
python,ajax,cgi,web-applications,fastcgi
As suggested by a few of the others you can use a keep alive connection and instead of "return" statements use yield statements and instead of "print" statements also use yield statements. This will basically show everything that happens in the python script onto the website page. After extensive searching and testing I would advise nginx as a reverse proxy with gevent & bottle as the backend which allows for peace of mind as nginx will not serve up the python source file ever.
0
0
0
1
2009-10-25T17:10:00.000
5
0
false
1,621,430
0
0
1
1
I have a Python script that outputs something every second or two, but takes a long while to finish completely. I want to set up a website such that someone can directly invoke the script, and the output is sent to the screen while the script is running. I don't want the user to wait until the script finishes completely, because then all the output is displayed at once. I also tried that, and the connection always times out. I don't know what this process is called, what terms I'm looking for, and what I need to use. CGI? Ajax? Need some serious guidance here, thanks! If it matters, I plan to use Nginx as the webserver.
Find Monday's date with Python
1,622,263
54
87
60,733
0
python,django
ChristopheD's post is close to what you want. I don't have enough rep to make a comment :( Instead of (which actually gives you the next upcoming monday): >>> today + datetime.timedelta(days=-today.weekday(), weeks=1) datetime.date(2009, 10, 26) I would say: >>> last_monday = today - datetime.timedelta(days=today.weekday()) If you want the previous week, add the 'weeks=1' parameter. This makes the code more readable since you are subtracting a timedelta. This clears up any confusion caused by adding a timedelta that has negative and positive offsets.
0
0
0
0
2009-10-25T20:53:00.000
8
1
false
1,622,038
1
0
1
1
How do I find the previous Monday's date, based off of the current date using Python? I thought maybe I could use: datetime.weekday() to do it, but I am getting stuck. I basically want to find today's date and Mondays date to construct a date range query in django using: created__range=(start_date, end_date).
Restrict access to images on my website except through my own htmls
1,623,338
6
2
4,621
1
php,python,linux,perl
Any method you choose to determine the source of a request is only as reliable as the HTTP_REFERER information that is sent by the user's browser, which is not very. Requiring authentication is the only good way to protect content.
0
0
0
0
2009-10-26T06:06:00.000
5
1
false
1,623,311
0
0
1
2
On my website I store user pictures in a simple manner such as: "image/user_1.jpg". I don't want visitors to be able to view images on my server just by trying user_ids. (Ex: www.mydomain.com/images/user_2.jpg, www.mydomain.com/images/user_3.jpg, so on...) So far I have three solutions in mind: I tried using .htaccess to password protect the "images" folder. That helped me up to some point but some of the images started popping up a username and password request on my htmls (while amazingly some images did not) so this seems to be an unpredictable method. I can start converting my user_id's to an md5 hash with some salt. The images would be named as: /image/user_e4d909c290d0fb1ca068ffaddf22cbd0.jpg. I don't like this solution. It makes the file system way complicated. or I can user PHP's readfile() function or maybe something similar in Perl or Python. For instance I could pass a password using an md5 string to validate visitors as loggedin users with access to that image. I'm leaning towards option 3 but with a Perl or Python angle (assuming they would be faster than PHP). However I would like to see other ideas on the matter. Maybe there is a simple .htaccess trick to this? Basically all I want to make sure is that no one can view images from my website unless the images are directly called from within htmls hosted on my site. Thanks a lot, Haluk
Restrict access to images on my website except through my own htmls
1,623,325
2
2
4,621
1
php,python,linux,perl
You are right considering option #3. Use service script that would validate user and readfile() an image. Be sure to set correct Content-Type HTTP header via header() function prior to serving an image. For better isolation images should be put above web root directory, or protected by well written .htaccess rules - there is definitely a way of protecting files and/or directories this way.
0
0
0
0
2009-10-26T06:06:00.000
5
0.07983
false
1,623,311
0
0
1
2
On my website I store user pictures in a simple manner such as: "image/user_1.jpg". I don't want visitors to be able to view images on my server just by trying user_ids. (Ex: www.mydomain.com/images/user_2.jpg, www.mydomain.com/images/user_3.jpg, so on...) So far I have three solutions in mind: I tried using .htaccess to password protect the "images" folder. That helped me up to some point but some of the images started popping up a username and password request on my htmls (while amazingly some images did not) so this seems to be an unpredictable method. I can start converting my user_id's to an md5 hash with some salt. The images would be named as: /image/user_e4d909c290d0fb1ca068ffaddf22cbd0.jpg. I don't like this solution. It makes the file system way complicated. or I can user PHP's readfile() function or maybe something similar in Perl or Python. For instance I could pass a password using an md5 string to validate visitors as loggedin users with access to that image. I'm leaning towards option 3 but with a Perl or Python angle (assuming they would be faster than PHP). However I would like to see other ideas on the matter. Maybe there is a simple .htaccess trick to this? Basically all I want to make sure is that no one can view images from my website unless the images are directly called from within htmls hosted on my site. Thanks a lot, Haluk
Does using Psyco with django make any sense?
1,623,547
4
4
1,160
0
python,django,psyco
You should be using fastcgi or wsgi with django, so the process won't be starting up for each request. You really need to write your code to be psyco friendly if you want decent gains, and you will not benefit if your bottleneck is the database.
0
0
0
0
2009-10-26T07:50:00.000
3
0.26052
false
1,623,538
0
0
1
2
I know the benefits of Psyco for a Desktop app, but in a Web app where a process ( = a web page or an AJAX call) dies immediately after been fired, isn't it pointless ?
Does using Psyco with django make any sense?
1,623,581
4
4
1,160
0
python,django,psyco
First, as gribbler and Ibrahim mentioned, your process won't die unless you are using pure CGI... which you shouldn't be using. Secondly, the bottleneck in most web apps are database queries, for which Psyco won't help. If you happen to have a some logic that is computationally intensive it can certainly make sense to use Psyco or Cython. In fact I read a report somewhere (sorry it's been a while so can't find a link now) by someone who was doing some complex calculations and had great results compiling their entire views.py with Cython.
0
0
0
0
2009-10-26T07:50:00.000
3
1.2
true
1,623,538
0
0
1
2
I know the benefits of Psyco for a Desktop app, but in a Web app where a process ( = a web page or an AJAX call) dies immediately after been fired, isn't it pointless ?
Is there an easy way to create derived attributes in Django Model/Python classes?
1,626,233
0
4
1,644
0
python,django,django-models,oop
You've got two options I can think of right now: Since you don't want the field in the database your best bet is to define a method on the model that returns self.id * SOME_CONSTANT, say you call it big_id(). You can access this method anytime as yourObj.big_id(), and it will be available in templates as yourObj.big_id (you might want to read about the "magic dot" in django templates). If you don't mind it being in the DB, you can override the save method on your object to calculate id * SOME_CONSTANT and store it in a big_id field. This would save you from having to calculate it every time, since I assume ID isn't going to change
0
0
0
0
2009-10-26T17:30:00.000
3
0
false
1,626,155
0
0
1
1
Every Django model has a default primary-key id created automatically. I want the model objects to have another attribute big_id which is calculated as: big_id = id * SOME_CONSTANT I want to access big_id as model_obj.big_id without the corresponding database table having a column called big_id. Is this possible?
How to manage local vs production settings in Django?
5,528,824
4
339
119,151
0
python,django,deployment
For most of my projects I use following pattern: Create settings_base.py where I store settings that are common for all environments Whenever I need to use new environment with specific requirements I create new settings file (eg. settings_local.py) which inherits contents of settings_base.py and overrides/adds proper settings variables (from settings_base import *) (To run manage.py with custom settings file you simply use --settings command option: manage.py <command> --settings=settings_you_wish_to_use.py)
0
0
0
0
2009-10-26T18:00:00.000
22
0.036348
false
1,626,326
0
0
1
4
What is the recommended way of handling settings for local development and the production server? Some of them (like constants, etc) can be changed/accessed in both, but some of them (like paths to static files) need to remain different, and hence should not be overwritten every time the new code is deployed. Currently, I am adding all constants to settings.py. But every time I change some constant locally, I have to copy it to the production server and edit the file for production specific changes... :( Edit: looks like there is no standard answer to this question, I've accepted the most popular method.
How to manage local vs production settings in Django?
1,626,371
14
339
119,151
0
python,django,deployment
I use a settings_local.py and a settings_production.py. After trying several options I've found that it's easy to waste time with complex solutions when simply having two settings files feels easy and fast. When you use mod_python/mod_wsgi for your Django project you need to point it to your settings file. If you point it to app/settings_local.py on your local server and app/settings_production.py on your production server then life becomes easy. Just edit the appropriate settings file and restart the server (Django development server will restart automatically).
0
0
0
0
2009-10-26T18:00:00.000
22
1
false
1,626,326
0
0
1
4
What is the recommended way of handling settings for local development and the production server? Some of them (like constants, etc) can be changed/accessed in both, but some of them (like paths to static files) need to remain different, and hence should not be overwritten every time the new code is deployed. Currently, I am adding all constants to settings.py. But every time I change some constant locally, I have to copy it to the production server and edit the file for production specific changes... :( Edit: looks like there is no standard answer to this question, I've accepted the most popular method.
How to manage local vs production settings in Django?
36,996,922
1
339
119,151
0
python,django,deployment
As an alternative to maintain different file if you wiil: If you are using git or any other VCS to push codes from local to server, what you can do is add the settings file to .gitignore. This will allow you to have different content in both places without any problem. SO on server you can configure an independent version of settings.py and any changes made on the local wont reflect on server and vice versa. In addition, it will remove the settings.py file from github also, the big fault, which i have seen many newbies doing.
0
0
0
0
2009-10-26T18:00:00.000
22
0.009091
false
1,626,326
0
0
1
4
What is the recommended way of handling settings for local development and the production server? Some of them (like constants, etc) can be changed/accessed in both, but some of them (like paths to static files) need to remain different, and hence should not be overwritten every time the new code is deployed. Currently, I am adding all constants to settings.py. But every time I change some constant locally, I have to copy it to the production server and edit the file for production specific changes... :( Edit: looks like there is no standard answer to this question, I've accepted the most popular method.
How to manage local vs production settings in Django?
9,517,763
6
339
119,151
0
python,django,deployment
The problem with most of these solutions is that you either have your local settings applied before the common ones, or after them. So it's impossible to override things like the env-specific settings define the addresses for the memcached pool, and in the main settings file this value is used to configure the cache backend the env-specific settings add or remove apps/middleware to the default one at the same time. One solution can be implemented using "ini"-style config files with the ConfigParser class. It supports multiple files, lazy string interpolation, default values and a lot of other goodies. Once a number of files have been loaded, more files can be loaded and their values will override the previous ones, if any. You load one or more config files, depending on the machine address, environment variables and even values in previously loaded config files. Then you just use the parsed values to populate the settings. One strategy I have successfully used has been: Load a default defaults.ini file Check the machine name, and load all files which matched the reversed FQDN, from the shortest match to the longest match (so, I loaded net.ini, then net.domain.ini, then net.domain.webserver01.ini, each one possibly overriding values of the previous). This account also for developers' machines, so each one could set up its preferred database driver, etc. for local development Check if there is a "cluster name" declared, and in that case load cluster.cluster_name.ini, which can define things like database and cache IPs As an example of something you can achieve with this, you can define a "subdomain" value per-env, which is then used in the default settings (as hostname: %(subdomain).whatever.net) to define all the necessary hostnames and cookie things django needs to work. This is as DRY I could get, most (existing) files had just 3 or 4 settings. On top of this I had to manage customer configuration, so an additional set of configuration files (with things like database names, users and passwords, assigned subdomain etc) existed, one or more per customer. One can scale this as low or as high as necessary, you just put in the config file the keys you want to configure per-environment, and once there's need for a new config, put the previous value in the default config, and override it where necessary. This system has proven reliable and works well with version control. It has been used for long time managing two separate clusters of applications (15 or more separate instances of the django site per machine), with more than 50 customers, where the clusters were changing size and members depending on the mood of the sysadmin...
0
0
0
0
2009-10-26T18:00:00.000
22
1
false
1,626,326
0
0
1
4
What is the recommended way of handling settings for local development and the production server? Some of them (like constants, etc) can be changed/accessed in both, but some of them (like paths to static files) need to remain different, and hence should not be overwritten every time the new code is deployed. Currently, I am adding all constants to settings.py. But every time I change some constant locally, I have to copy it to the production server and edit the file for production specific changes... :( Edit: looks like there is no standard answer to this question, I've accepted the most popular method.
Is it possible access other webpages from within another page
1,628,598
1
1
213
0
javascript,jquery,python
There are two general approaches: Modify your Python code so that it runs as a CGI (or WSGI or whatever) module and generate the page of interest by running some server side code. Use Javascript with jQuery to load the content of interest by running some client side code. The difference between these two approaches is where the third party server sees the requests coming from. In the first case, it's from your web server. In the second case, it's from the browser of the user accessing your page. Some browsers may not handle loading content from third party servers very gracefully (that is, they might pop up warning boxes or something).
0
0
1
0
2009-10-27T03:07:00.000
3
0.066568
false
1,628,564
0
0
1
1
Basically, what I'm trying to do is simply make a small script that accesses finds the most recent post in a forum and pulls some text or an image out of it. I have this working in python, using the htmllib module and some regex. But, the script still isn't very convenient as is, it would be much nicer if I could somehow put it into an HTML document. It appears that simply embedding Python scripts is not possible, so I'm looking to see if theres a similar feature like python's htmllib that can be used to access some other webpage and extract some information from it. (Essentially, if I could get this script going in the form of an html document, I could just open one html document, rather than navigate to several different pages to get the information I want to check) I'm pretty sure that javascript doesn't have the functionality I need, but I was wondering about other languages such as jQuery, or even something like AJAX?
Python Package For Multi-Threaded Spider w/ Proxy Support?
5,803,567
1
1
9,003
0
python,proxy,multithreading,web-crawler,pool
usually proxies filter websites categorically based on how the website was created. It is difficult to transmit data through proxies based on categories. Eg youtube is classified as audio/video streams therefore youtube is blocked in some places espically schools. If you want to bypass proxies and get the data off a website and put it in your own genuine website like a dot com website that can be registered it to you. When you are making and registering the website categorise your website as anything you want.
0
0
1
0
2009-10-27T04:23:00.000
2
0.099668
false
1,628,766
0
0
1
1
Instead of just using urllib does anyone know of the most efficient package for fast, multithreaded downloading of URLs that can operate through http proxies? I know of a few such as Twisted, Scrapy, libcurl etc. but I don't know enough about them to make a decision or even if they can use proxies.. Anyone know of the best one for my purposes? Thanks!
Are there any known issues with django and multithreading?
1,629,913
2
1
1,383
0
python,django,multithreading
Generally, your Django app already is multi-threaded. That's the way most of the standard Django servers operate -- they can tolerate multiple WSGI threads sending requests to them. Further, you'll almost always have Django running under Apache, which is also multi-threaded. If you use mod_wsgi, then Django may be part of the Apache process or a separate process. Anything that is running "side-by-side" (Whatever that means) will be outside Apache, outside Django, and in a separate process. So any multi-threading considerations don't apply between your Apache process (which contains Django) and your other process.
0
0
0
0
2009-10-27T10:08:00.000
3
0.132549
false
1,629,800
0
0
1
1
I need to develop an app that runs side by side with a django-app. This will be the first time i develop a multithreaded app that runs next to a django-app so are there any 'gotchas' and 'traps' i should be aware of?
Django Zip upload permission problem
1,631,366
0
0
677
0
python,django,zip
it works with ZipFile.extractall
0
0
0
0
2009-10-27T12:19:00.000
2
1.2
true
1,630,427
0
0
1
1
I have few uploads in this app, uploading csv files is working fine. I have a model that has zip upload in it. Zip file is uploaded, can be viewed, but having issues extracting it. class Message(models.Model): uploadFile = models.FileField(_('images file (.zip)'), upload_to='message/', storage=FileSystemStorage(), help_text=_('')) The error is IOError at /backend/media/new (13, 'Permission denied')
How do we override the choice field display of a reference property in appengine using Django?
1,636,697
1
1
289
0
python,django,google-app-engine,referenceproperty
I got it to work by overriding the init method of the modelform to pick up the correct fields as I had to do filtering of the choices as well.
0
0
0
0
2009-10-28T07:25:00.000
2
0.099668
false
1,635,638
0
0
1
1
The default choice field display of a reference property in appengine returns the choices as the string representation of the entire object. What is the best method to override this behaviour? I tried to override str() in the referenced class. But it does not work.
django generic templates
1,639,340
1
3
1,334
0
python,django,frameworks,templating
I don't see you getting away from writing templates, especially if you would want to format it, even slightly. However you can re-use basic templates, for e.g, create a generic object_list.html and object_detail.html that will basically contain the information to loop over the object list and present it, and show the object detail. You could use these "Generic" templates across the entire app if need be.
0
0
0
0
2009-10-28T17:40:00.000
2
0.099668
false
1,638,870
0
0
1
1
So, Generic views are pretty cool, but what I'm interested in is something that's a generic template. so for example, I can give it an object and it'll just tostring it for me. or if I give it a list, it'll just iterate over the objects and tostring them as a ul (or tr, or whatever else it deems necessary). for most uses you wouldn't need this. I just threw something together quickly for a friend (a bar stock app, if you must know), and I don't feel like writing templates.
Android: Java v. Python
1,641,125
11
10
4,643
0
java,python,android
Java is "more native" on the Android platform; Python is coming after and striving to get parity but not quite there yet AFAIK. Roughly the reverse situation wrt App Engine, where Python's been around for a year longer than Java and so is still more mature and complete (even though Java's catching up). So, in any situation where you'd be at all undecided between Java and Python if the deployment was due to happen on some general purpose platform such as Linux, I think the maturity and completeness arguments could sway you towards Python for deployment on App Engine, and towards Java for deployment on Android.
0
0
0
1
2009-10-28T23:30:00.000
3
1.2
true
1,640,806
0
0
1
2
Is there any reason to favor Python or Java over the other for developing on Android phones, other than the usual Python v. Java issues?
Android: Java v. Python
1,641,263
2
10
4,643
0
java,python,android
On the mobile platform performance and memory usage are much more critical than desktop or server. The JVM that runs on Android is highly optimized for the mobile platform. Based on the links I have seen about Python on Android none of them seem to have an optimized VM for mobile platform.
0
0
0
1
2009-10-28T23:30:00.000
3
0.132549
false
1,640,806
0
0
1
2
Is there any reason to favor Python or Java over the other for developing on Android phones, other than the usual Python v. Java issues?
Close all opened xml tags
1,652,871
0
5
1,809
0
python,xml
You could use BeautifulStoneSoup (XML part of BeautifulSoup). www.crummy.com/software/BeautifulSoup It's not ideal, but it would circumvent the problem if you cannot fix the file's output... It's basically a previously implemented version of what Denis said. You can just join whatever you need into the soup and it will do its best to fix it.
0
0
1
0
2009-10-29T16:36:00.000
4
0
false
1,644,994
0
0
1
2
I have a file, which change it content in a short time. But I'd like to read it before it is ready. The problem is, that it is an xml-file (log). So when you read it, it could be, that not all tags are closed. I would like to know if there is a possibility to close all opened tags correctly, that there are no problems to show it in the browser (with xslt stylsheet). This should be made by using included features of python.
Close all opened xml tags
1,645,047
0
5
1,809
0
python,xml
You can use any SAX parser by feeding data available so far to it. Use SAX handler that just reconstructs source XML, keep the stack of tags opened and close them in reverse order at the end.
0
0
1
0
2009-10-29T16:36:00.000
4
0
false
1,644,994
0
0
1
2
I have a file, which change it content in a short time. But I'd like to read it before it is ready. The problem is, that it is an xml-file (log). So when you read it, it could be, that not all tags are closed. I would like to know if there is a possibility to close all opened tags correctly, that there are no problems to show it in the browser (with xslt stylsheet). This should be made by using included features of python.
Concurrency control in Django model
4,679,345
13
23
16,575
0
python,django,django-models,concurrency
I don't think that 'keeping a version number or timestamp' works. When self.version == self.read_current_version() is True, there is still a chance that the version number got modified by other sessions just before you call super().save().
0
0
0
0
2009-10-29T17:19:00.000
3
1
false
1,645,269
0
0
1
1
How do I handle concurrency in a Django model? I don't want the changes to the record being overwritten by another user who reads the same record.
Django db reset without loading fixtures
1,645,519
2
1
1,667
1
python,database,django,fixtures
As far as I know, the fixtures (in initial_data file) are automatically loaded after manage.py syndcb and not after reset. So, if you do a manage.py reset yourapp it should not load the fixtures. Hmm?
0
0
0
0
2009-10-29T17:26:00.000
2
1.2
true
1,645,310
0
0
1
1
Is there an easy way to reset a django database (i.e. drop all data/tables, create new tables and create indexes) without loading fixture data afterwords? What I want to have is just an empty database because all data is loaded from another source (a kind of a post-processed backup). I know that this could be achieved by piping the output of the manage sql... commands to manage dbshell, but this relies on manage dbshelland is kind of hacky... Are there any other ways to do this? Edit: manage reset will do it, but is there a command like reset that doesn't need the application names as parameters?
mod_python django logging problem
1,648,183
2
1
556
0
python,django,logging
RotatingFileHandler is not designed to work in multiprocess system. Each process you have notice that file is too large and starts new log, so you get up to 5 new logs. It's not as easy to implement it properly: you have to obtain interprocess lock before creating new file and inform each process to reopen it. You'd better use external (provided with your OS) rotation with server restart or setup single-process logging server.
0
1
0
0
2009-10-30T04:10:00.000
1
1.2
true
1,647,974
0
0
1
1
I use logging settings as below in the settings.py file: logging.basicConfig(level=LOG_LEVEL, format=LOG_FORMAT); handler = logging.handlers.RotatingFileHandler( LOG_FILE_PATH, 'a', LOG_FILE_SIZE,LOG_FILE_NUM ); formatter = logging.Formatter ( LOG_FORMAT ); handler.setFormatter(formatter); logging.getLogger().addHandler(handler) and i use mod_python with apache2. the problem is: when the log rotate, i got many log files created at the same time. for example, i set 5 work-process in apache, and i got log.1, log.2 ... log.5 when it rotate. any suggestions?
How do I automatically rebuild the Sphinx index under django-sphinx?
2,657,021
0
2
2,816
0
python,django,search,sphinx,django-sphinx
The above sounds right to me, though I'll mention that you could call the indexer from your save function for the object. It'd probably get called a LOT, but it could work. Just call it as you would any external command.
0
0
0
0
2009-10-31T01:18:00.000
2
0
false
1,653,071
0
0
1
1
I just setup django-sphinx, and it is working beautifully. I am now able to search my model and get amazing results. The one problem is that I have to build the index by hand using the indexer command. That means every time I add new content, I have to manually hit the command line to rebuild the search index. That is just not acceptable. I could make a cron job that automatically runs the indexer command every so often, but that's far from optimal. New data won't be indexed until the cron runs again. In addition, the indexer will run unnecessarily most times as my site doesn't have data being added very often. How do I set it up so that the Sphinx index will automatically rebuild itself whenever data is added to or modified in a searchable django model?
Python deprecated functions
1,653,756
0
3
4,339
0
python,python-2.6
I think Python 2.5 apps should work fine in 2.6 without updates. 2.6 might complain about some deprecated functionality but those are only removed in 3.0 and still work in 2.6.
0
0
0
0
2009-10-31T07:55:00.000
5
0
false
1,653,734
1
0
1
3
I have a Django app written in Python 2.5 and I plan to upgrade it to be compatible with Python 2.6. It contains hundreds of .py files. Is there a simple way to find all deprecated functions in those files?
Python deprecated functions
1,653,810
5
3
4,339
0
python,python-2.6
Between point releases of Python (like between 2.5 and 2.6) anything that might break is a warning for at least one release. Most deprecation warnings are emitted by default but you have fine-grained control over the emitted warnings with the -W interpreter invocation option. This is a relatively small issue between point releases as they are explicitly intended to be backward compatible. A bigger change is between Python 2.x and 3.0 for which some special-purpose tools including the -3 interpreter invocation option which shows the Python 3.0 related deprecation warnings.
0
0
0
0
2009-10-31T07:55:00.000
5
0.197375
false
1,653,734
1
0
1
3
I have a Django app written in Python 2.5 and I plan to upgrade it to be compatible with Python 2.6. It contains hundreds of .py files. Is there a simple way to find all deprecated functions in those files?
Python deprecated functions
8,189,947
0
3
4,339
0
python,python-2.6
More and more I am persuaded that the right answer is "Just run your testsuite to find out." You have your testsuite covering your program reasonably, right? If not, this is a great opportunity to create one (you can persuade your point-headed boss that it is "migration" ;)).
0
0
0
0
2009-10-31T07:55:00.000
5
0
false
1,653,734
1
0
1
3
I have a Django app written in Python 2.5 and I plan to upgrade it to be compatible with Python 2.6. It contains hundreds of .py files. Is there a simple way to find all deprecated functions in those files?
erlang on google app engine?
1,654,786
11
2
1,713
0
python,google-app-engine,erlang
Erlang and Python are programming languages, and each language has one or more "runtimes" that allow you to run programs written in those languages. GAE supplies a Python runtime. GAE has no support for Erlang programs.
0
1
0
0
2009-10-31T15:48:00.000
1
1.2
true
1,654,759
0
0
1
1
I know python can be run on GAE what is different erlang and python in lay man term? can erlang run on google app engine ?
PyQt and MVC-pattern
1,692,893
9
35
29,014
0
python,qt,pyqt
Yes, PyQt uses Model/View concept (officially without the "Controller" part), but may be you have a somewhat distorted picture what does it mean in PyQt. There are two parts: Models, subclassed from appropriate PyQt base abstract model classes (QAbstractItemModel, QAbstractTableModel, QAbstractListModel, etc.). These models can talk to your data sources directly (files, databases), or proxy your own PyQt-agnostic models which were written before. Views, which are implemented in Qt library, and often do not require any modifications (examples: QTreeView, QTableView and others). Even some simpler controls, like QComboBox can act as a view for a PyQt model. All other parts of you application, which react to signals, etc. may be considered as "Controller". PyQt also provides a set of predefined "universal" models which can be subclassed or used directly if you need only simple functionality from the model, like QStringListModel, QStandardItemModel, etc. And there are also models which can talk to databases directly, like QSqlTableModel.
1
0
0
0
2009-11-02T10:27:00.000
3
1
false
1,660,474
0
0
1
1
I am trying to design an MVC-pattern with PyQt. I want to split all programs into 3 parts: classes abstracted from all Qt classes (model) classes providing data from the model to a Qt app (controller) the Qt app itself with defined method SignalsToSlots that connects signals with controller. Is this optimally? What scheme is recommended for use in PyQt development?
Can I add Runtime Properties to a Python App Engine App?
1,674,790
1
0
158
0
python,google-app-engine,properties,runtime
You can: edit records in the datastore through the dashboard ( if you really have to ) upload new scripts / files ( you can access files in READ-ONLY ) export a WEB Service API to configuration records in the datastore ( probably not what you had in mind ) access a page somewhere through an HTTP end-point
0
1
0
0
2009-11-04T15:58:00.000
2
1.2
true
1,674,764
0
0
1
1
Coming from a java background I'm used to having a bunch of properties files I can swap round at runtime dependent on what server I'm running on e.g. dev/production. Is there a method in python to do similar, specifically on Google's App Engine framework? At the minute I have them defined in .py files, obviously I'd like a better separation.
wxPython: How should I organize per-widget data in the controller?
1,738,316
2
4
519
0
python,model-view-controller,user-interface
The anomaly (from the MVC viewpoint) that makes this design difficult to make MVC-conformant is that you want to display information that, by your conceptualization, "does not live in a model". There is no such thing as "information that does not live in a model" in MVC: its conceptual root is "the models hold all the information, the views just do presentation tasks, the controllers mediate user interaction". It's quite possible that the information you're displaying doesn't "correspond to any business data", but (in an MVC worldview) this does not mean that info is "independent of the model", because there is no such thing -- it just means you need another model class (beyond whatever you're using to hold "business data"), to hold this "non-business" data!-) So when the user "instantiates a widget" (creates a directory-display view, presumably by some user action on some master/coordinating view, possibly on another existing widget if "cloning" is one of the ways to instantiate a widget), the controller's responsible for creating both a widget object and an instance of the "directory-display model class", and establish connection between them (normally by setting on the widget a reference to the relevant model instance), as well as telling the model to do its initial loading of information. When the user action on the widget implies an action on the model, the controller retrieves from the widget involved in the event the reference to the model instance, and sends that instance the appropriate request(s) (it's the model's business to let the view[s] interested in it know about changes to information -- typically by some observer pattern; it's definitely not the controller's business to feed the view with information -- that's really a very different approach from MVC!). Is the architectural investment required by MVC worth it, in your case, compared to a rougher approach where the information flows are less pristine and the model that should be there just doesn't exist? I'm a pragmatist and I definitely don't worship at the altar of MVC, but I think in this case the (relatively small) investment in sound, clear architecture may indeed repay itself in abundance. It's a question of envisioning the likely directions of change -- for example, what functionality that you don't need right now (but may well enter the picture soon afterwards) will be trivial to add if you go the proper MVC route, and would be a nightmare of ad-hoc kludges otherwise (or require a somewhat painful refactoring of the whole architecture)? All sort of likely things, from wanting to display the same directory information in different widgets to having a smarter "directory-information watching" model that can automatically refresh itself when needed (and supply the new info directly to interested views via the usual observer pattern, with no involvement by the controller), are natural and trivially easy with MVC (hey, that's the whole point of MVC, after all, so this is hardly surprising!-), kludgy and fragile with an ad-hoc corner-cutting architecture -- small investment, large potential returns, go for it! You may notice from the tone of the previous paragraph that I don't worship at the "extreme programming" altar either -- as a pragmatist, I will do a little "design up front" (especially in terms of putting in place a clean, flexible, extensible architecture, from the start, even if it's not indispensable right now) -- exactly because, in my experience, a little forethought and very modest investment, especially on the architectural front, pays back for itself many times over during a project's life (in such varied currencies as scalability, flexibility, extensibility, maintainability, security, and so forth, though not all of them will apply to every project -- e.g., in your case, security and scalability are not really a concern... but the other aspects will likely be!-). Just for generality, let me point out that this pragmatic attitude of mine does not justify excessive energy and time spent on picking an architecture (by definition of the word "excessive";-) -- being familiar with a few fundamental architectural patterns (and MVC is surely one of those) often reduces the initial investment in terms of time and effort -- once you recognize that such a classic architecture will serve you well, as in this case, it's really easy to see how to embody it (e.g., reject the idea of an "MVC without a M"!-), and it doesn't really take much more code compared to the kludgiest, ad-hoccest shortcuts!-)
1
0
0
0
2009-11-06T08:37:00.000
3
1.2
true
1,686,235
0
0
1
1
I have a widget that displays a filesystem hierarchy for convenient browsing (basically a tree control and some associated toolbar buttons, such as "refresh"). Each of these widgets has a set of base directories for it to display (recursively). Assume that the user may instantiate as many of these widgets as they find convenient. Note that these widgets don't correspond to any business data -- they're independent of the model. Where should the (per-widget) set of base directories live in good MVC design? When the refresh button is pushed, an event is trapped by the controller, and the event contains the corresponding filesystem-browser widget. The controller determines the base directories for that particular widget (somehow), walks that directory path, and passes the widget some data to render. Two places I can think to store the base directories: The easy solution: make the base directories an instance variable on the widget and have the controller manipulate it to retain state for that widget. There's a conceptual issue with this, though: since the widget never looks at that instance variable, you're just projecting one of the responsibilities of the controller onto the widget. The more (technically, maybe conceptually) complex solution: Keep a {widget: base_directory_set} mapping in the controller with weak key references. The second way allows for easy expansion of controller responsibilities later on, as putting things in the controller tends to do -- for example, if I decided I later wanted to determine the set of all the base directories for all those widgets. There may be some piece of MVC knowledge I'm missing that solves this kind of problem well.
Overhead of a Round-trip to MySql?
1,689,143
1
3
1,620
1
python,mysql,django,overhead
There is always overhead in database calls, in your case the overhead is not that bad because the application and database are on the same machine so there is no network latency but there is still a significant cost. When you make a request to the database it has to prepare to service that request by doing a number of things including: Allocating resources (memory buffers, temp tables etc) to the database server connection/thread that will handle the request, De-serializing the sql and parameters (this is necessary even on one machine as this is an inter-process request unless you are using an embeded database) Checking whether the query exists in the query cache if not optimise it and put it in the cache. Note also that if your queries are not parametrised (that is the values are not separated from the SQL) this may result in cache misses for statements that should be the same meaning that each request results in the query being analysed and optimized each time. Process the query. Prepare and return the results to the client. This is just an overview of the kinds of things the most database management systems do to process an SQL request. You incur this overhead 500 times even if the the query itself runs relatively quickly. Bottom line database interactions even to local database are not as cheap as you might expect.
0
0
0
0
2009-11-06T17:18:00.000
4
0.049958
false
1,689,031
0
0
1
4
So I've been building django applications for a while now, and drinking the cool-aid and all: only using the ORM and never writing custom SQL. The main page of the site (the primary interface where users will spend 80% - 90% of their time) was getting slow once you have a large amount of user specific content (ie photos, friends, other data, etc) So I popped in the sql logger (was pre-installed with pinax, I just enabled it in the settings) and imagine my surprise when it reported over 500 database queries!! With hand coded sql I hardly ever ran more than 50 on the most complex pages. In hindsight it's not all together surprising, but it seems that this can't be good. ...even if only a dozen or so of the queries take 1ms+ So I'm wondering, how much overhead is there on a round trip to mysql? django and mysql are running on the same server so there shouldn't be any networking related overhead.
Overhead of a Round-trip to MySql?
1,689,146
3
3
1,620
1
python,mysql,django,overhead
The overhead of each queries is only part of the picture. The actual round trip time between your Django and Mysql servers is probably very small since most of your queries are coming back in less than a one millisecond. The bigger problem is that the number of queries issued to your database can quickly overwhelm it. 500 queries for a page is way to much, even 50 seems like a lot to me. If ten users view complicated pages you're now up to 5000 queries. The round trip time to the database server is more of a factor when the caller is accessing the database from a Wide Area Network, where roundtrips can easily be between 20ms and 100ms. I would definitely look into using some kind of caching.
0
0
0
0
2009-11-06T17:18:00.000
4
0.148885
false
1,689,031
0
0
1
4
So I've been building django applications for a while now, and drinking the cool-aid and all: only using the ORM and never writing custom SQL. The main page of the site (the primary interface where users will spend 80% - 90% of their time) was getting slow once you have a large amount of user specific content (ie photos, friends, other data, etc) So I popped in the sql logger (was pre-installed with pinax, I just enabled it in the settings) and imagine my surprise when it reported over 500 database queries!! With hand coded sql I hardly ever ran more than 50 on the most complex pages. In hindsight it's not all together surprising, but it seems that this can't be good. ...even if only a dozen or so of the queries take 1ms+ So I'm wondering, how much overhead is there on a round trip to mysql? django and mysql are running on the same server so there shouldn't be any networking related overhead.
Overhead of a Round-trip to MySql?
1,689,452
4
3
1,620
1
python,mysql,django,overhead
Just because you are using an ORM doesn't mean that you shouldn't do performance tuning. I had - like you - a home page of one of my applications that had low performance. I saw that I was doing hundreds of queries to display that page. I went looking at my code and realized that with some careful use of select_related() my queries would bring more of the data I needed - I went from hundreds of queries to tens. You can also run a SQL profiler and see if there aren't indices that would help your most common queries - you know, standard database stuff. Caching is also your friend, I would think. If a lot of a page is not changing, do you need to query the database every single time? If all else fails, remember: the ORM is great, and yes - you should try to use it because it is the Django philosophy; but you are not married to it. If you really have a usecase where studying and tuning the ORM navigation didn't help, if you are sure that you could do it much better with a standard query: use raw sql for that case.
0
0
0
0
2009-11-06T17:18:00.000
4
0.197375
false
1,689,031
0
0
1
4
So I've been building django applications for a while now, and drinking the cool-aid and all: only using the ORM and never writing custom SQL. The main page of the site (the primary interface where users will spend 80% - 90% of their time) was getting slow once you have a large amount of user specific content (ie photos, friends, other data, etc) So I popped in the sql logger (was pre-installed with pinax, I just enabled it in the settings) and imagine my surprise when it reported over 500 database queries!! With hand coded sql I hardly ever ran more than 50 on the most complex pages. In hindsight it's not all together surprising, but it seems that this can't be good. ...even if only a dozen or so of the queries take 1ms+ So I'm wondering, how much overhead is there on a round trip to mysql? django and mysql are running on the same server so there shouldn't be any networking related overhead.
Overhead of a Round-trip to MySql?
1,689,330
2
3
1,620
1
python,mysql,django,overhead
There are some ways to reduce the query volume. Use .filter() and .all() to get a bunch of things; pick and choose in the view function (or template via {%if%}). Python can process a batch of rows faster than MySQL. "But I could send too much to the template". True, but you'll execute fewer SQL requests. Measure to see which is better. This is what you used to do when you wrote SQL. It's not wrong -- it doesn't break the ORM -- but it optimizes the underlying DB work and puts the processing into the view function and the template. Avoid query navigation in the template. When you do {{foo.bar.baz.quux}}, SQL is used to get the bar associated with foo, then the baz associated with the bar, then the quux associated with baz. You may be able to reduce this query business with some careful .filter() and Python processing to assemble a useful tuple in the view function. Again, this was something you used to do when you hand-crafted SQL. In this case, you gather larger batches of ORM-managed objects in the view function and do your filtering in Python instead of via a lot of individual ORM requests. This doesn't break the ORM. It changes the usage profile from lots of little queries to a few bigger queries.
0
0
0
0
2009-11-06T17:18:00.000
4
1.2
true
1,689,031
0
0
1
4
So I've been building django applications for a while now, and drinking the cool-aid and all: only using the ORM and never writing custom SQL. The main page of the site (the primary interface where users will spend 80% - 90% of their time) was getting slow once you have a large amount of user specific content (ie photos, friends, other data, etc) So I popped in the sql logger (was pre-installed with pinax, I just enabled it in the settings) and imagine my surprise when it reported over 500 database queries!! With hand coded sql I hardly ever ran more than 50 on the most complex pages. In hindsight it's not all together surprising, but it seems that this can't be good. ...even if only a dozen or so of the queries take 1ms+ So I'm wondering, how much overhead is there on a round trip to mysql? django and mysql are running on the same server so there shouldn't be any networking related overhead.
How do I upload data to Google App Engine periodically?
1,690,155
0
0
400
0
python,security,google-app-engine,automation
Can you break up the scraping process into independent chunks that can each finish in the timeframe of an appengine request? (which can run longer than one second btw). Then you can just spawn a bunch of tasks using the task API that when combined, accomplish the full scrape. Then use the cron API to spawn off those tasks every N minutes.
0
1
0
0
2009-11-06T18:56:00.000
5
0
false
1,689,570
0
0
1
4
I'm writing an aggregation application which scrapes data from a couple of web sources and displays that data with a novel interface. The sites from which I'm scraping update every couple of minutes, and I want to make sure the data on my aggregator is up-to-date. What's the best way to periodically submit fresh data to my App Engine application from an automated script? Constraints: The application is written in Python. The scraping process for each site takes longer than one second, thus I cannot process the data in an App Engine handler. The host on which the updater script would run is shared, so I'd rather not store my password on disk. I'd like to check the code for the application into to our codebase. While my associates aren't malicious, they're pranksters, and I'd like to prevent them from inserting fake data into my app. I'm aware that App Engine supports some remote_api thingey, but I'd have to put that entry point behind authentication (see constraint 3) or hide the URL (see constraint 4). Suggestions?
How do I upload data to Google App Engine periodically?
1,690,150
3
0
400
0
python,security,google-app-engine,automation
Write a Task Queue task or an App Engine cron job to handle this. I'm not sure where you heard that there's a limit of 1 second on any sort of App Engine operations - requests are limited to 30 seconds, and URL fetches have a maximum deadline of 10 seconds.
0
1
0
0
2009-11-06T18:56:00.000
5
1.2
true
1,689,570
0
0
1
4
I'm writing an aggregation application which scrapes data from a couple of web sources and displays that data with a novel interface. The sites from which I'm scraping update every couple of minutes, and I want to make sure the data on my aggregator is up-to-date. What's the best way to periodically submit fresh data to my App Engine application from an automated script? Constraints: The application is written in Python. The scraping process for each site takes longer than one second, thus I cannot process the data in an App Engine handler. The host on which the updater script would run is shared, so I'd rather not store my password on disk. I'd like to check the code for the application into to our codebase. While my associates aren't malicious, they're pranksters, and I'd like to prevent them from inserting fake data into my app. I'm aware that App Engine supports some remote_api thingey, but I'd have to put that entry point behind authentication (see constraint 3) or hide the URL (see constraint 4). Suggestions?
How do I upload data to Google App Engine periodically?
1,689,805
0
0
400
0
python,security,google-app-engine,automation
The only way to get data into AppEngine is to call up a Web app of yours (as a Web app) and feed it data through the usual HTTP-ish means, i.e. as parameters to a GET request (for short data) or to a POST (if long or binary). In other words, you'll have to craft your own little dataloader, which you will access as a Web app and which will in turn stash the data into the database behind AppEngine. You'll probably want at least password protection on that app so nobody loads bogus data into your app.
0
1
0
0
2009-11-06T18:56:00.000
5
0
false
1,689,570
0
0
1
4
I'm writing an aggregation application which scrapes data from a couple of web sources and displays that data with a novel interface. The sites from which I'm scraping update every couple of minutes, and I want to make sure the data on my aggregator is up-to-date. What's the best way to periodically submit fresh data to my App Engine application from an automated script? Constraints: The application is written in Python. The scraping process for each site takes longer than one second, thus I cannot process the data in an App Engine handler. The host on which the updater script would run is shared, so I'd rather not store my password on disk. I'd like to check the code for the application into to our codebase. While my associates aren't malicious, they're pranksters, and I'd like to prevent them from inserting fake data into my app. I'm aware that App Engine supports some remote_api thingey, but I'd have to put that entry point behind authentication (see constraint 3) or hide the URL (see constraint 4). Suggestions?
How do I upload data to Google App Engine periodically?
1,693,701
0
0
400
0
python,security,google-app-engine,automation
I asked around and some friends came up with two solutions: Upload a file with a shared secret token along with the application, but when committing to the codebase, change the token. Create a small datastore model with one row, a secret token. In both cases the token can be used to authenticate POST requests used to upload new data.
0
1
0
0
2009-11-06T18:56:00.000
5
0
false
1,689,570
0
0
1
4
I'm writing an aggregation application which scrapes data from a couple of web sources and displays that data with a novel interface. The sites from which I'm scraping update every couple of minutes, and I want to make sure the data on my aggregator is up-to-date. What's the best way to periodically submit fresh data to my App Engine application from an automated script? Constraints: The application is written in Python. The scraping process for each site takes longer than one second, thus I cannot process the data in an App Engine handler. The host on which the updater script would run is shared, so I'd rather not store my password on disk. I'd like to check the code for the application into to our codebase. While my associates aren't malicious, they're pranksters, and I'd like to prevent them from inserting fake data into my app. I'm aware that App Engine supports some remote_api thingey, but I'd have to put that entry point behind authentication (see constraint 3) or hide the URL (see constraint 4). Suggestions?
How to implement Symfony Partials or Components in Django?
1,691,549
1
1
715
0
python,django,symfony1
Assuming you are going to be using the components in different places on different pages I would suggest trying {% include "foo.html" %}. One of the (several) downsides of the Django templating language is that there is no concept of macros, so you need to be very consistent in the names of values in the context you pass to your main template so that the included template finds things it's looking for. Alternatively, in the view you can invoke the template engine for each component and save the result in a value passed in the context. Then in the main template simply use the value in the context. I'm not fond of either of these approaches. The more complex your template needs become the more you may want to look at Jinja2. (And, no, I don't buy the Django Party Line about 'template designers' -- never saw one in my life.)
0
0
0
0
2009-11-07T00:21:00.000
2
0.099668
false
1,691,400
0
0
1
1
I've been developing in the Symfony framework for quite a time, but now I have to work with Django and I'm having problems with doing something like a "component" or "partial" in Symfony. That said, here is my goal: I have a webpage with lots of small widgets, all these need their logic - located in a "views.py" I guess. But, how do I tell Django to call all this logic and render it all as one webpage?