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
Download image file from the HTML page source using python?
257,413
3
47
97,893
0
python,screen-scraping
Use htmllib to extract all img tags (override do_img), then use urllib2 to download all the images.
0
0
1
0
2008-11-02T21:31:00.000
7
0.085505
false
257,409
0
0
1
2
I am writing a scraper that downloads all the image files from a HTML page and saves them to a specific folder. all the images are the part of the HTML page.
Download image file from the HTML page source using python?
257,412
8
47
97,893
0
python,screen-scraping
You have to download the page and parse html document, find your image with regex and download it.. You can use urllib2 for downloading and Beautiful Soup for parsing html file.
0
0
1
0
2008-11-02T21:31:00.000
7
1
false
257,409
0
0
1
2
I am writing a scraper that downloads all the image files from a HTML page and saves them to a specific folder. all the images are the part of the HTML page.
Python vs Groovy vs Ruby? (based on criteria listed in question)
257,770
3
35
36,111
0
python,ruby,scripting,groovy
This sort of adding-up-scores-by-features is not a good way to choose a programming language. You'd be better off choosing whichever you know the best. If you don't know any of them, try them out for a little while. If you have a really specific project in mind, then maybe some programming languages would be better, but if you just have general preferences you will never come to a consensus. That said, Python is pretty flexible, it's the most popular on your list so the easiest to solve whatever sorts of problems you have by searching, so I'd recommend Python.
0
0
0
1
2008-11-03T01:31:00.000
10
0.059928
false
257,730
0
0
1
7
Considering the criteria listed below, which of Python, Groovy or Ruby would you use? Criteria (Importance out of 10, 10 being most important) Richness of API/libraries available (eg. maths, plotting, networking) (9) Ability to embed in desktop (java/c++) applications (8) Ease of deployment (8) Ability to interface with DLLs/Shared Libraries (7) Ability to generate GUIs (7) Community/User support (6) Portability (6) Database manipulation (3) Language/Semantics (2)
Python vs Groovy vs Ruby? (based on criteria listed in question)
257,746
33
35
36,111
0
python,ruby,scripting,groovy
I think it's going to be difficult to get an objective comparison. I personally prefer Python. To address one of your criteria, Python was designed from the start to be an embeddable language. It has a very rich C API, and the interpreter is modularized to make it easy to call from C. If Java is your host environment, you should look at Jython, an implementation of Python inside the Java environment (VM and libs).
0
0
0
1
2008-11-03T01:31:00.000
10
1.2
true
257,730
0
0
1
7
Considering the criteria listed below, which of Python, Groovy or Ruby would you use? Criteria (Importance out of 10, 10 being most important) Richness of API/libraries available (eg. maths, plotting, networking) (9) Ability to embed in desktop (java/c++) applications (8) Ease of deployment (8) Ability to interface with DLLs/Shared Libraries (7) Ability to generate GUIs (7) Community/User support (6) Portability (6) Database manipulation (3) Language/Semantics (2)
Python vs Groovy vs Ruby? (based on criteria listed in question)
1,401,616
28
35
36,111
0
python,ruby,scripting,groovy
Having worked with all 3 of them, this is what I can say: Python has very mature libraries libraries are documented documentation can be accessed from your debugger/shell at runtime through the docstrings you can develop code without an IDE Ruby has some great libraries ( even though some are badly documented ) Ruby's instrospection mechanisms are great. They make writing code pretty easy ( even if documentation is not available ) you can develop code without an IDE Groovy you can benefit from everything Java has to offer syntax is somewhat inspired from Ruby it's hard to write code without an IDE. You have no way to debug stuff from your console ( this is something you can easily do in Python/Ruby ) and the available Groovy plugins have a lot of catching up to do. I wrote some apps using Groovy and as they get bigger I regret not going with Ruby/Python ( debugging would have been WAY more easier ). If you'll only develop from an IDE, Groovy's a cool language.
0
0
0
1
2008-11-03T01:31:00.000
10
1
false
257,730
0
0
1
7
Considering the criteria listed below, which of Python, Groovy or Ruby would you use? Criteria (Importance out of 10, 10 being most important) Richness of API/libraries available (eg. maths, plotting, networking) (9) Ability to embed in desktop (java/c++) applications (8) Ease of deployment (8) Ability to interface with DLLs/Shared Libraries (7) Ability to generate GUIs (7) Community/User support (6) Portability (6) Database manipulation (3) Language/Semantics (2)
Python vs Groovy vs Ruby? (based on criteria listed in question)
326,962
8
35
36,111
0
python,ruby,scripting,groovy
try Groovy .. it has all features that you need there. You can use existing java lib without any modification on its classes. basically .. groovy is java++, it is more dynamic and fun to learn (just like ruby) I dont like ruby or python syntax so I will put them behind. Groovy is just like C/C++ syntax so I like him lol :)
0
0
0
1
2008-11-03T01:31:00.000
10
1
false
257,730
0
0
1
7
Considering the criteria listed below, which of Python, Groovy or Ruby would you use? Criteria (Importance out of 10, 10 being most important) Richness of API/libraries available (eg. maths, plotting, networking) (9) Ability to embed in desktop (java/c++) applications (8) Ease of deployment (8) Ability to interface with DLLs/Shared Libraries (7) Ability to generate GUIs (7) Community/User support (6) Portability (6) Database manipulation (3) Language/Semantics (2)
Python vs Groovy vs Ruby? (based on criteria listed in question)
257,831
7
35
36,111
0
python,ruby,scripting,groovy
Python has all nine criteria. It scores a 56. I'm sure Ruby has everything Python has. It seems to have fewer libraries. So it scores a 51. I don't know if Groovy has every feature. Since Python is 56 and Ruby is a 51, Python just barely edges out Ruby. However, I think this kind of decision can still boil down to some subjective issues outside these nine criteria.
0
0
0
1
2008-11-03T01:31:00.000
10
1
false
257,730
0
0
1
7
Considering the criteria listed below, which of Python, Groovy or Ruby would you use? Criteria (Importance out of 10, 10 being most important) Richness of API/libraries available (eg. maths, plotting, networking) (9) Ability to embed in desktop (java/c++) applications (8) Ease of deployment (8) Ability to interface with DLLs/Shared Libraries (7) Ability to generate GUIs (7) Community/User support (6) Portability (6) Database manipulation (3) Language/Semantics (2)
Python vs Groovy vs Ruby? (based on criteria listed in question)
257,776
24
35
36,111
0
python,ruby,scripting,groovy
Just to muddy the waters... Groovy give you access to Java. Java has an extremely rich set of APIs/Libraries, applications, etc. Groovy is embeddable, although easiest in Java. DLLs/Libraries (if you're talking about non-Groovy/Java) may be somewhat problematic, although there are ways and some APIs to help. I've done some Python programming, but being more familiar with Java, Groovy comes a lot easier to me.
0
0
0
1
2008-11-03T01:31:00.000
10
1
false
257,730
0
0
1
7
Considering the criteria listed below, which of Python, Groovy or Ruby would you use? Criteria (Importance out of 10, 10 being most important) Richness of API/libraries available (eg. maths, plotting, networking) (9) Ability to embed in desktop (java/c++) applications (8) Ease of deployment (8) Ability to interface with DLLs/Shared Libraries (7) Ability to generate GUIs (7) Community/User support (6) Portability (6) Database manipulation (3) Language/Semantics (2)
Python vs Groovy vs Ruby? (based on criteria listed in question)
257,738
0
35
36,111
0
python,ruby,scripting,groovy
I know it's not on your list, but at least look at perl. Richness of Api/Libraries to sink a ship. Runs on more systems than most people realise exists. Works well with Binary libraries. Has a huge community. Portability, See above. Database manipulation: more ways to do it. ( Pick your favorite module ) And one of the most expressive/terse languages around.
0
0
0
1
2008-11-03T01:31:00.000
10
0
false
257,730
0
0
1
7
Considering the criteria listed below, which of Python, Groovy or Ruby would you use? Criteria (Importance out of 10, 10 being most important) Richness of API/libraries available (eg. maths, plotting, networking) (9) Ability to embed in desktop (java/c++) applications (8) Ease of deployment (8) Ability to interface with DLLs/Shared Libraries (7) Ability to generate GUIs (7) Community/User support (6) Portability (6) Database manipulation (3) Language/Semantics (2)
How to fetch more than 1000?
1,000,121
0
51
32,035
0
python,google-app-engine,google-cloud-datastore
The proposed solution only works if entries are sorted by key... If you are sorting by another column first, you still have to use a limit(offset, count) clause, then the 1000 entries limitation still apply. It is the same if you use two requests : one for retrieving indexes (with conditions and sort) and another using where index in () with a subset of indexes from the first result, as the first request cannot return more than 1000 keys ? (The Google Queries on Keys section does not state clearly if we have to sort by key to remove the 1000 results limitation)
0
0
0
0
2008-11-05T01:56:00.000
16
0
false
264,154
0
0
1
1
How can I fetch more than 1000 record from data store and put all in one single list to pass to django?
Multiple database support in django
272,522
3
10
9,347
0
python,django,database-connection
If you read a few of the many (many) threads on this subject in django-dev, you will see that what looks straightforward, isn't. If you pick a single use case, then it looks easy, but as soon as you start to generalize in any way you start to run into trouble. To use the above-referenced thread as an example, when you say "multiple databases", which of the following are you talking about? All DB on the same machine under the same engine. All DB on same machine, different engines (E.g. MySQL + PostgreSQL) One Master DB with N read-only slaves on different machines. Sharding of tables across multiple DB servers. Will you need: Foreign keys across DBs JOINs across machines and/or engines etc. etc. One of the problems with a slick ORM like Django's is that it hides all of those messy details under a nice paint job. To continue to do that, but to then add in any of the above, is Not Easy (tm).
0
0
0
0
2008-11-06T09:39:00.000
10
0.059928
false
268,089
0
0
1
1
From some forum I came to know that Multiple database support is added in Django at lower level, but the higher level apis are not added yet. Can anyone please tell me how one can achieve multiple database connections in Django. Does anyone have any idea by when Django will fully/officially support Multiple database connections.
User Authentication in Django
272,470
4
2
1,232
0
python,django
A site I did last year was concerned that usernames/passwords might be posted to a forum. I dealt with this by adding a model and a check to the login view that looked at how many unique IPs the name had been used from in the last X hours. I gave the site admins two values in settings.py to adjust the number of hours and the number of unique IPs. If a name was being "overused" it was blocked for logins from new IPs until enough time had passed to fall below the threshold. Much to their surprise, they have had only one name trigger the blocking in the last year and that turned out to be the company president who was on a business trip and kept logging in from new locations. Ps. The code is straightforward. Email me at peter at techbuddy dot us if you would like it.
0
0
0
0
2008-11-07T13:21:00.000
2
0.379949
false
272,042
0
0
1
2
is there any way of making sure that, one user is logged in only once? I would like to avoid two different persons logging into the system with the same login/password. I guess I could do it myself by checking in the django_session table before logging in the user, but I rather prefer using the framework, if there is already such functionality. Cheers, Thanks for the responses!
User Authentication in Django
272,071
5
2
1,232
0
python,django
Logged in twice is ambiguous over HTTP. There's no "disconnecting" signal that's sent. You can frustrate people if you're not careful. If I shut down my browser and drop the cookies -- accidentally -- I might be prevented from logging in again. How would the server know it was me trying to re-login vs. me trying to login twice? You can try things like checking the IP address. And what if the accidental disconnect was my router crashing, releasing my DHCP lease? Now I'm trying to re-login, but I have a new address and no established cookie. I'm not trying to create a second session, I'm just trying to get back on after my current session got disconnected. the point is that there's no well-established rule for "single session" that can be installed in a framework. You have to make up a rule appropriate to your application and figure out how to enforce it.
0
0
0
0
2008-11-07T13:21:00.000
2
1.2
true
272,042
0
0
1
2
is there any way of making sure that, one user is logged in only once? I would like to avoid two different persons logging into the system with the same login/password. I guess I could do it myself by checking in the django_session table before logging in the user, but I rather prefer using the framework, if there is already such functionality. Cheers, Thanks for the responses!
Processing chunked encoded HTTP POST requests in python (or generic CGI under apache)
284,857
1
5
5,471
0
python,http,post,java-me,midlet
Maybe it is a configuration issue? Django can be fronted with Apache by mod_python, WSGI and FastCGI and it can accept file uploads.
0
0
0
1
2008-11-12T17:50:00.000
5
0.039979
false
284,741
0
0
1
2
I have a j2me client that would post some chunked encoded data to a webserver. I'd like to process the data in python. The script is being run as a CGI one, but apparently apache will refuse a chunked encoded post request to a CGI script. As far as I could see mod_python, WSGI and FastCGI are no go too. I'd like to know if there is a way to have a python script process this kind of input. I'm open to any suggestion (e.g. a confoguration setting in apache2 that would assemble the chunks, a standalone python server that would do the same, etc.) I did quite a bit of googling and didn't find anything usable, which is quite strange. I know that resorting to java on the server side would be a solution, but I just can't imagine that this can't be solved with apache + python.
Processing chunked encoded HTTP POST requests in python (or generic CGI under apache)
284,869
2
5
5,471
0
python,http,post,java-me,midlet
Apache 2.2 mod_cgi works fine for me, Apache transparently unchunks the request as it is passed to the CGI application. WSGI currently disallows chunked requests, and mod_wsgi does indeed block them with a 411 response. It's on the drawing board for WSGI 2.0. But congratulations on finding something that does chunk requests, I've never seen one before!
0
0
0
1
2008-11-12T17:50:00.000
5
0.07983
false
284,741
0
0
1
2
I have a j2me client that would post some chunked encoded data to a webserver. I'd like to process the data in python. The script is being run as a CGI one, but apparently apache will refuse a chunked encoded post request to a CGI script. As far as I could see mod_python, WSGI and FastCGI are no go too. I'd like to know if there is a way to have a python script process this kind of input. I'm open to any suggestion (e.g. a confoguration setting in apache2 that would assemble the chunks, a standalone python server that would do the same, etc.) I did quite a bit of googling and didn't find anything usable, which is quite strange. I know that resorting to java on the server side would be a solution, but I just can't imagine that this can't be solved with apache + python.
python (jython) archiving library
298,027
1
1
256
0
java,python,jython,archive
You can use java.util.zip, when I was using Jython the built in zip library in python didn't work
0
1
0
0
2008-11-18T06:32:00.000
2
0.099668
false
298,004
1
0
1
1
Is there a neat archiving library that automatically handles archiving a folder or directories for you out there? I am using Jython, so Java libs are also open for use. -UPDATE- Also Im looking for timestamp archiving. ie archive-dir/2008/11/16/zipfilebypreference.zip then the next day call it again and it creates another folder. Im sure there is something out there on the internet, who knows?
Django Template Variables and Javascript
304,627
8
276
309,660
0
javascript,python,django,google-app-engine,django-templates
For a dictionary, you're best of encoding to JSON first. You can use simplejson.dumps() or if you want to convert from a data model in App Engine, you could use encode() from the GQLEncoder library.
0
0
0
0
2008-11-18T13:52:00.000
16
1
false
298,772
0
0
1
1
When I render a page using the Django template renderer, I can pass in a dictionary variable containing various values to manipulate them in the page using {{ myVar }}. Is there a way to access the same variable in Javascript (perhaps using the DOM, I don't know how Django makes the variables accessible)? I want to be able to lookup details using an AJAX lookup based on the values contained in the variables passed in.
Calling Java (or python or perl) from a PHP script
300,035
4
3
1,939
0
java,php,python,dynamic-linking
"where I just can't figure out what model I need to produce the HTML form I want, which seems such a basic thing that I fear for my chances of doing anything more complex" Common problem. Root cause: Too much programming. Solution. Do less programming. Seriously. Define the Django model. Use the default admin pages to see if it's right. Fix the model. Regenerate the database. Look at the default admin pages. Repeat until the default admin pages work correctly and simply. Once it's right in the default admin pages, you have a model that works. It's testable. And the automatic stuff is hooked up correctly. Choices are defined correctly. Computations are in the model mmethods. Queries work. Now you can start working on other presentations of the data. Django generally starts (and ends) with the model. The forms, view and templates are derived from the model.
0
0
0
1
2008-11-18T19:51:00.000
2
1.2
true
299,913
0
0
1
1
I've been trying to build a simple prototype application in Django, and am reaching the point of giving up, sadly, as it's just too complicated (I know it would be worth it in the long-run, but I really just don't have enough time available -- I need something up and running in a few days). So, I'm now thinking of going with PHP instead, as it's the method for creating dynamic web content I'm most familiar with, and I know I can get something working quickly. My application, while simple, is probably going to be doing some reasonably complex AI stuff, and it may be that libraries don't exist for what I need in PHP. So I'm wondering how easy / possible it is for a PHP script to "call" a Java program or Python script or a program or script in another language. It's not entirely clear to me what exactly I mean by "call" in this context, but I guess I probably mean that ideally I'd like to define a function in, let's say Java, and then be able to call it from PHP. If that's not possible, then I guess my best bet (assuming I do go with PHP) will be to pass control directly to the external program explicitly through a POST or GET to a CGI program or similar. Feel free to convince me I should stick with Django, although I'm really at the point where I just can't figure out what model I need to produce the HTML form I want, which seems such a basic thing that I fear for my chances of doing anything more complex... Alternatively, anyone who can offer any advice on linking PHP and other languages, that'll be grateful received.
Which language is easiest and fastest to work with XML content?
301,538
2
21
18,193
0
java,.net,python,xml,ruby
either C# or VB.Net using LiNQ to XML. LiNQ to XML is very very powerful and easy to implement
0
0
1
1
2008-11-19T10:35:00.000
9
0.044415
false
301,493
0
0
1
1
We have developers with knowledge of these languages - Ruby , Python, .Net or Java. We are developing an application which will mainly handle XML documents. Most of the work is to convert predefined XML files into database tables, providing mapping between XML documents through database, creating reports from database etc. Which language will be the easiest and fastest to work with? (It is a web-app)
How to update turbogears application production database
301,708
1
1
889
1
python,database,postgresql,data-migration,turbogears
This always works and requires little thinking -- only patience. Make a backup. Actually make a backup. Everyone skips step 1 thinking that they have a backup, but they can never find it or work with it. Don't trust any backup that you can't recover from. Create a new database schema. Define your new structure from the ground up in the new schema. Ideally, you'll run a DDL script that builds the new schema. Don't have a script to build the schema? Create one and put it under version control. With SA, you can define your tables and it can build your schema for you. This is ideal, since you have your schema under version control in Python. Move data. a. For tables which did not change structure, move data from old schema to new schema using simple INSERT/SELECT statements. b. For tables which did change structure, develop INSERT/SELECT scripts to move the data from old to new. Often, this can be a single SQL statement per new table. In some cases, it has to be a Python loop with two open connections. c. For new tables, load the data. Stop using the old schema. Start using the new schema. Find every program that used the old schema and fix the configuration. Don't have a list of applications? Make one. Seriously -- it's important. Applications have hard-coded DB configurations? Fix that, too, while you're at it. Either create a common config file, or use some common environment variable or something to (a) assure consistency and (b) centralize the notion of "production". You can do this kind of procedure any time you do major surgery. It never touches the old database except to extract the data.
0
0
0
0
2008-11-19T11:00:00.000
4
1.2
true
301,566
0
0
1
1
I am having a postgres production database in production (which contains a lot of Data). now I need to modify the model of the tg-app to add couple of new tables to the database. How do i do this? I am using sqlAlchemy.
Best Django 'CMS' component for integration into existing site
3,892,818
25
14
12,696
0
python,django,content-management-system
I have worked with all three (and more) and they are all built for different use cases IMHO. I would agree that these are the top-teir choices. The grid comparison at djangopluggables.com certainly can make evaluating each of these easier. django-cms is the most full-featured and is something you could actually hand over to clients without being irresponsible. Even though it has features for integrating other apps, it doesn't have the extensibility/integration of FeinCMS or the simplicity of django-page-cms. That being said, I think the consensus is that this is the best Open Source CMS for Django. However, it's docs are a little lacking. update: I have been told that integrating apps into DjangoCMS 2.1 has been improved. FeinCMS - Is a great set of tools for combining and building CMS functionality into your own apps. It's not "out of the box" at all, which means that you can integrate it however you want. It doesn't want to take over your urls.py or control how you route pages. It's probably a prototype for the next-generation of truly pluggable apps in Django. - We are moving from django-page-cms to FeinCMS because our primary models is high volume eCommerce and I have custom content-types I want to integrate that aren't blogs or flash. Good documentation and support as well. Django-page-cms - Is great if you want to just have some "About Us" pages around your principle application. Its menu system is not truly hierarchical and building your page presentation is up to you. But it's very simple, unobtrusive, and very easy to slap into your app and get a navigation going that clients can manage, or even for yourself. It has no docs that I know of, but you won't really need any. Read the code and you will get it all in 30 minutes or less. update Mezzanine - Is a very well designed CMS and one that I have finally settled on for most of my client work, mostly because it has an integrated eCommerce portion. But beyond that it has very extensible page models, and a custom admin interface that a client might be willing to use. It also has the best "out of the box" experience i.e. You can have a full fledged site up with one command.
0
0
0
0
2008-11-19T19:04:00.000
7
1.2
true
302,983
0
0
1
1
So I have a relatively large (enough code that it would be easier to write this CMS component from scratch than to rewrite the app to fit into a CMS) webapp that I want to add basic Page/Menu/Media management too, I've seen several Django pluggables addressing this issue, but many seem targeted as full CMS platforms. Does anyone know of a plugin that can easily integrate with existing templates/views and still sports a powerful/comprehensive admin interface?
Data Modelling Advice for Blog Tagging system on Google App Engine
307,727
7
8
3,133
0
python,google-app-engine,data-modeling
Thanks to both of you for your suggestions. I've implemented (first iteration) as follows. Not sure if it's the best approach, but it's working. Class A = Articles. Has a StringListProperty which can be queried on it's list elements Class B = Tags. One entity per tag, also keeps a running count of the total number of articles using each tag. Data modifications to A are accompanied by maintenance work on B. Thinking that counts being pre-computed is a good approach in a read-heavy environment.
0
0
0
0
2008-11-20T01:56:00.000
4
1.2
true
304,117
0
0
1
2
Am wondering if anyone might provide some conceptual advice on an efficient way to build a data model to accomplish the simple system described below. Am somewhat new to thinking in a non-relational manner and want to try avoiding any obvious pitfalls. It's my understanding that a basic principal is that "storage is cheap, don't worry about data duplication" as you might in a normalized RDBMS. What I'd like to model is: A blog article which can be given 0-n tags. Many blog articles can share the same tag. When retrieving data would like to allow retrieval of all articles matching a tag. In many ways very similar to the approach taken here at stackoverflow. My normal mindset would be to create a many-to-may relationship between tags and blog articles. However, I'm thinking in the context of GAE that this would be expensive, although I have seen examples of it being done. Perhaps using a ListProperty containing each tag as part of the article entities, and a second data model to track tags as they're added and deleted? This way no need for any relationships and the ListProperty still allows queries where any list element matching will return results. Any suggestions on the most efficient way to approach this on GAE?
Data Modelling Advice for Blog Tagging system on Google App Engine
304,170
1
8
3,133
0
python,google-app-engine,data-modeling
Many-to-many sounds reasonable. Perhaps you should try it first to see if it is actually expensive. Good thing about G.A.E. is that it will tell you when you are using too many cycles. Profiling for free!
0
0
0
0
2008-11-20T01:56:00.000
4
0.049958
false
304,117
0
0
1
2
Am wondering if anyone might provide some conceptual advice on an efficient way to build a data model to accomplish the simple system described below. Am somewhat new to thinking in a non-relational manner and want to try avoiding any obvious pitfalls. It's my understanding that a basic principal is that "storage is cheap, don't worry about data duplication" as you might in a normalized RDBMS. What I'd like to model is: A blog article which can be given 0-n tags. Many blog articles can share the same tag. When retrieving data would like to allow retrieval of all articles matching a tag. In many ways very similar to the approach taken here at stackoverflow. My normal mindset would be to create a many-to-may relationship between tags and blog articles. However, I'm thinking in the context of GAE that this would be expensive, although I have seen examples of it being done. Perhaps using a ListProperty containing each tag as part of the article entities, and a second data model to track tags as they're added and deleted? This way no need for any relationships and the ListProperty still allows queries where any list element matching will return results. Any suggestions on the most efficient way to approach this on GAE?
Adding REST to Django
308,785
59
51
28,236
0
python,django,apache,rest
I'm thinking of falling back to simply writing view functions in Django that return JSON results. Explicit Portable to other frameworks Doesn't require patching Django
0
0
0
0
2008-11-21T12:24:00.000
11
1.2
true
308,605
0
0
1
6
I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy. Here are some examples of things I'm wringing my hands over. Right now, I'm using the Django-REST API with a pile of patches. I'm thinking of falling back to simply writing view functions in Django that return JSON results. I can also see filtering the REST requests in Apache and routing them to a separate, non-Django server instance. Please nominate one approach per answer so we can vote them up or down.
Adding REST to Django
308,885
4
51
28,236
0
python,django,apache,rest
Scrap the Django REST api and come up with your own open source project that others can contribute to. I would be willing to contribute. I have some code that is based on the forms api to do REST.
0
0
0
0
2008-11-21T12:24:00.000
11
0.072599
false
308,605
0
0
1
6
I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy. Here are some examples of things I'm wringing my hands over. Right now, I'm using the Django-REST API with a pile of patches. I'm thinking of falling back to simply writing view functions in Django that return JSON results. I can also see filtering the REST requests in Apache and routing them to a separate, non-Django server instance. Please nominate one approach per answer so we can vote them up or down.
Adding REST to Django
9,027,830
1
51
28,236
0
python,django,apache,rest
TastyPie looks quite interesting and promising. It goes well with Django.
0
0
0
0
2008-11-21T12:24:00.000
11
0.01818
false
308,605
0
0
1
6
I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy. Here are some examples of things I'm wringing my hands over. Right now, I'm using the Django-REST API with a pile of patches. I'm thinking of falling back to simply writing view functions in Django that return JSON results. I can also see filtering the REST requests in Apache and routing them to a separate, non-Django server instance. Please nominate one approach per answer so we can vote them up or down.
Adding REST to Django
736,425
1
51
28,236
0
python,django,apache,rest
you could try making a generic functions that process the data (like parand mentioned) which you can call from the views that generate the web pages, as well as those that generate the json/xml/whatever
0
0
0
0
2008-11-21T12:24:00.000
11
0.01818
false
308,605
0
0
1
6
I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy. Here are some examples of things I'm wringing my hands over. Right now, I'm using the Django-REST API with a pile of patches. I'm thinking of falling back to simply writing view functions in Django that return JSON results. I can also see filtering the REST requests in Apache and routing them to a separate, non-Django server instance. Please nominate one approach per answer so we can vote them up or down.
Adding REST to Django
312,910
2
51
28,236
0
python,django,apache,rest
I ended up going with my own REST API framework for Django (that I'd love to get rid of if I can find a workable alternative), with a few custom views thrown in for corner cases I didn't want to deal with. It's worked out ok. So a combination of 1 and 2; without some form of framework you'll end up writing the same boilerplate for the common cases. I've also done a few stand-alone APIs. I like having them as stand-alone services, but the very fact that they stand alone from the rest of the code leads to them getting neglected. No technical reason; simply out-of-sight, out-of-mind. What I'd really like to see is an approach that unifies Django forms and REST APIs, as they often share a lot of logic. Conceptually if your app exposes something in HTML it likely wants to expose it programmatically as well.
0
0
0
0
2008-11-21T12:24:00.000
11
0.036348
false
308,605
0
0
1
6
I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy. Here are some examples of things I'm wringing my hands over. Right now, I'm using the Django-REST API with a pile of patches. I'm thinking of falling back to simply writing view functions in Django that return JSON results. I can also see filtering the REST requests in Apache and routing them to a separate, non-Django server instance. Please nominate one approach per answer so we can vote them up or down.
Adding REST to Django
312,544
3
51
28,236
0
python,django,apache,rest
I'm thinking of falling back to simply writing view functions in Django that return JSON results. I would go with that .. Ali A summed it pretty well. The main point for me is beign explicit. I would avoid using a function that automatically converts an object into json, what if the object has a reference to a user and somehow the password (even if it's hashed) go into the json snippit?
0
0
0
0
2008-11-21T12:24:00.000
11
0.054491
false
308,605
0
0
1
6
I've got a Django application that works nicely. I'm adding REST services. I'm looking for some additional input on my REST strategy. Here are some examples of things I'm wringing my hands over. Right now, I'm using the Django-REST API with a pile of patches. I'm thinking of falling back to simply writing view functions in Django that return JSON results. I can also see filtering the REST requests in Apache and routing them to a separate, non-Django server instance. Please nominate one approach per answer so we can vote them up or down.
Does anyone know of a python based web ui for snmp monitoring?
541,516
0
1
1,942
0
python,django,pylons,snmp,turbogears
or you can start building your own solution (like me), you will be surprised how much can you do with few lines of code using for instance cherryp for web server, pysnmp, and python rrd module.
0
0
1
1
2008-11-22T02:26:00.000
2
0
false
310,759
0
0
1
1
Comparable to cacti or mrtg.
Are there problems developing Django on Jython?
315,110
1
14
3,101
0
python,django,jvm,jython
I have recently started working on an open source desktop project in my spare time. So this may not apply. I came to the same the question. I decided that I should write as much of the code as possible in python (and Django) and target all the platforms CPython, Jython, and IronPython. Then, I decided that I would write plugins that would interface with libraries on different implementations (for example, different GUI libraries). Why? I decided early on that longevity of my code may depend on targeting not only CPython but also virtual machines. For today's purposes CPython is the way to go because of speed, but who knows about tomorrow. If you code is flexible enough, you may not have to decide on targeting one. The downside to this approach is that you will have more code to create and maintain.
0
0
0
0
2008-11-24T14:17:00.000
4
0.049958
false
314,234
0
0
1
2
The background I'm building a fair-sized web application with a friend in my own time, and we've decided to go with the Django framework on Python. Django provides us with a lot of features we're going to need, so please don't suggest alternative frameworks. The only decision I'm having trouble with, is whether we use Python or Jython to develop our application. Now I'm pretty familiar with Java and could possibly benefit from the libraries within the JDK. I know minimal Python, but am using this project as an opportunity to learn a new language - so the majority of work will be written in Python. The attractiveness of Jython is of course the JVM. The number of python/django enabled web-hosts is extremely minimal - whereas I'm assuming I could drop a jython/django application on a huge variety of hosts. This isn't a massive design decision, but still one I think needs to be decided. I'd really prefer jython over python for the jvm accessibility alone. Questions Does Jython have many limitations compared to regular python? Will running django on jython cause problems? How quick is the Jython team to release updates alongside Python? Will Django work as advertised on Jython (with very minimal pre-configuration)? Decision Thanks for the helpful comments. What I think I'm going to do is develop in Jython for the JVM support - but to try to only use Python code/libraries. Portability isn't a major concern so if I need a library in the JDK (not readily available in python), I'll use it. As long as Django is fully supported, I'm happy.
Are there problems developing Django on Jython?
314,448
3
14
3,101
0
python,django,jvm,jython
I'd say that if you like Django, you'll also like Python. Don't make the (far too common) mistake of mixing past language's experience while you learn a new one. Only after mastering Python, you'll have the experience to judge if a hybrid language is better than either one. It's true that very few cheap hostings offer Django preinstalled; but it's quite probable that that will change, given that it's the most similar environment to Google's app engine. (and most GAE projects can be made to run on Django)
0
0
0
0
2008-11-24T14:17:00.000
4
0.148885
false
314,234
0
0
1
2
The background I'm building a fair-sized web application with a friend in my own time, and we've decided to go with the Django framework on Python. Django provides us with a lot of features we're going to need, so please don't suggest alternative frameworks. The only decision I'm having trouble with, is whether we use Python or Jython to develop our application. Now I'm pretty familiar with Java and could possibly benefit from the libraries within the JDK. I know minimal Python, but am using this project as an opportunity to learn a new language - so the majority of work will be written in Python. The attractiveness of Jython is of course the JVM. The number of python/django enabled web-hosts is extremely minimal - whereas I'm assuming I could drop a jython/django application on a huge variety of hosts. This isn't a massive design decision, but still one I think needs to be decided. I'd really prefer jython over python for the jvm accessibility alone. Questions Does Jython have many limitations compared to regular python? Will running django on jython cause problems? How quick is the Jython team to release updates alongside Python? Will Django work as advertised on Jython (with very minimal pre-configuration)? Decision Thanks for the helpful comments. What I think I'm going to do is develop in Jython for the JVM support - but to try to only use Python code/libraries. Portability isn't a major concern so if I need a library in the JDK (not readily available in python), I'll use it. As long as Django is fully supported, I'm happy.
How to debug Web2py applications?
2,781,947
0
19
9,395
0
python,debugging,web2py
As Carl stated, it is as easy as: Installing PyDev in Eclipse Right Click on your Web2Py project, selecting Debug As > Python Run Selecting web2py.py as the file to run No other plugins or downloads are needed.
0
0
0
0
2008-11-24T19:27:00.000
9
0
false
315,165
0
0
1
2
Is it possible? By debug I mean setting breakpoints, inspect values and advance step by step.
How to debug Web2py applications?
806,233
8
19
9,395
0
python,debugging,web2py
One can debug applications built on Web2py using the following set-up: Eclipse IDE Install Pydev into Eclipse Set Breakpoints on your code as needed Within Eclipse right-click the file web2py.py and select Debug As -> Python Run When a breakpoint is hit Eclipse will jump to the breakpoint where you can inspect variables and step thru the code
0
0
0
0
2008-11-24T19:27:00.000
9
1
false
315,165
0
0
1
2
Is it possible? By debug I mean setting breakpoints, inspect values and advance step by step.
Spambots are cluttering my log file [Django]
318,079
0
4
821
0
python,django,apache,spam-prevention
Yes, it should be a 404, not a 500. 500 indicates something is trying to deal with the URL and is failing in the process. You need to find and fix that. We have a similar problem. Since we are running Apache/mod_python, I chose to deal with it in .htaccess with mod_rewrite rules. I periodically look at the logs and add a few patterns to my "go to hell" list. These all rewrite to deliver a 1x1 pixel gif file. There is no tsunami of 404s to clutter up my log analysis and it puts minimal load on Django and Apache. You can't make these a**holes go away, so all you can do is minimize their impact on your system and get on with your life.
0
0
0
0
2008-11-24T20:31:00.000
8
0
false
315,363
0
0
1
3
I have a nice and lovely Django site up and running, but have noticed that my error.log file was getting huge, over 150 MB after a couple of months of being live. Turns out a bunch of spambots are looking for well known URL vulnerabilities (or something) and hitting a bunch of sub-directories like http://mysite.com/ie or http://mysite.com/~admin.php etc. Since Django uses URL rewriting, it is looking for templates to fit these requests, which raises a TemplateDoesNotExist exception, and then a 500 message (Django does this, not me). I have debug turned off, so they only get the generic 500 message, but it's filling up my logs very quickly. Is there a way to turn this behavior off? Or perhaps just block the IP's doing this?
Spambots are cluttering my log file [Django]
315,615
0
4
821
0
python,django,apache,spam-prevention
How about setting up a catch-all pattern as the last item in your urls file and directing it to a generic "no such page" or even your homepage? In other words, turn 500's into requests for your homepage.
0
0
0
0
2008-11-24T20:31:00.000
8
0
false
315,363
0
0
1
3
I have a nice and lovely Django site up and running, but have noticed that my error.log file was getting huge, over 150 MB after a couple of months of being live. Turns out a bunch of spambots are looking for well known URL vulnerabilities (or something) and hitting a bunch of sub-directories like http://mysite.com/ie or http://mysite.com/~admin.php etc. Since Django uses URL rewriting, it is looking for templates to fit these requests, which raises a TemplateDoesNotExist exception, and then a 500 message (Django does this, not me). I have debug turned off, so they only get the generic 500 message, but it's filling up my logs very quickly. Is there a way to turn this behavior off? Or perhaps just block the IP's doing this?
Spambots are cluttering my log file [Django]
315,394
-1
4
821
0
python,django,apache,spam-prevention
A programming solution would be to : open the log file read the lines in a buffer replace the lines that match the errors the bots caused seek to the beginning of the file write the new buffer truncate the file to current pointer position close Voila ! It's done !
0
0
0
0
2008-11-24T20:31:00.000
8
-0.024995
false
315,363
0
0
1
3
I have a nice and lovely Django site up and running, but have noticed that my error.log file was getting huge, over 150 MB after a couple of months of being live. Turns out a bunch of spambots are looking for well known URL vulnerabilities (or something) and hitting a bunch of sub-directories like http://mysite.com/ie or http://mysite.com/~admin.php etc. Since Django uses URL rewriting, it is looking for templates to fit these requests, which raises a TemplateDoesNotExist exception, and then a 500 message (Django does this, not me). I have debug turned off, so they only get the generic 500 message, but it's filling up my logs very quickly. Is there a way to turn this behavior off? Or perhaps just block the IP's doing this?
How to include output of PHP script in Python driven Plone site?
321,274
1
2
1,656
0
php,python,plone
Well, use AJAX to call the PHP script (yes, you will need apache) and display the output. Adding a custom JS to plone is trivial and this abstract the technology issue. Just be sure this is not a critical feature. Some users still deactivate JS and the web page should therefor degrade itself nicely.
0
0
0
0
2008-11-26T14:58:00.000
3
0.066568
false
320,979
0
0
1
1
I need to have the output of a PHP snippet in a Plone site. It was delivered to be a small library that has a display() function, in PHP, that outputs a line of text. But I need to put it in a Plone site. Do you have any recommendations? I was thinking a long the lines of having a display.php that just runs display() and from the Plone template to download that URL and output the content. Do you think it might work? What methods of hitting a URL, retrieve the content and outputting can I use from inside a Plone template? One important and critical constraint is that the output should be directly on the HTML and not an an iframe. This is a constraint coming from the outside, nothing technical.
@Rails users: have you tried web2py? Pros? Cons?
327,684
11
13
2,962
0
python,ruby-on-rails,web2py
c'mon guys... your only argument is "Technical differences are rather irrelevant." and "it don't matter what web framework you use"? I disagree. The size of the users base has more to do with marketing and how long a framework has been around. By that argument ASP and PHP are better than Rails. Has anybody here used both Rails and web2py? web2py runs on webfaction and any hosting provider that supports mod_proxy or mod_wsgi or mod_fcgi, and runs on Google App Engine (rails does not). There is also a dedicated web2py hosting provider (star-nix.com).
0
0
0
0
2008-11-29T03:11:00.000
3
1
false
327,101
0
0
1
3
web2py to is a Python framework but shares the "convention over configuration" design that Ruby on Rails has. On the plus side it packages a lot more functionality with its s standard distribution and we claim it is faster and easier to use. Has any Rails user tried it? What is your impression? No rants please. Just technical comments.
@Rails users: have you tried web2py? Pros? Cons?
1,250,930
1
13
2,962
0
python,ruby-on-rails,web2py
I found web2py much easier to learn... there are fewer scripts to run and abstractions. On the other hand, web2py's database layer isn't a real ORM... it's almost like writing raw SQL. Simple things end up taking many lines of code, just like SQL.
0
0
0
0
2008-11-29T03:11:00.000
3
0.066568
false
327,101
0
0
1
3
web2py to is a Python framework but shares the "convention over configuration" design that Ruby on Rails has. On the plus side it packages a lot more functionality with its s standard distribution and we claim it is faster and easier to use. Has any Rails user tried it? What is your impression? No rants please. Just technical comments.
@Rails users: have you tried web2py? Pros? Cons?
327,519
0
13
2,962
0
python,ruby-on-rails,web2py
I would say the biggest "con" of using webpy over Rails is that there are not a lot of Rails-specific hosting services around, and the huge community based around it (there are Rails plugins and tools for.. everything). The same cannot be said for web2py. It depends what you want to do with it - if it's something to write your personal site with, and you already have a server to host it on, use whatever you prefer. If it's something to distribute for others to run, Rails has more options for hosting, and a bigger community, so it may be a better choice. Technical differences are rather irrelevant. Every framework can basically do the same (generate web-pages). What is important is community, ease of use, useful feature-sets, ability to host it and so on - and those are all really subjective. I still use PHP quite often, not because "it's better", but because I can host it on a huge majority of web-hosts. I also use Rails because as it has a good, and very active community. The actually technicalities of the framework wasn't ever a consideration, really.. I could probably put together a list of why web2py is "better"/"worse" than Rails - Rails may be 0.04sec/request slower at generating templates containing loops, or web2py may have a good DB model generator, or some other technical reason - but those may not be relevant to you at all
0
0
0
0
2008-11-29T03:11:00.000
3
0
false
327,101
0
0
1
3
web2py to is a Python framework but shares the "convention over configuration" design that Ruby on Rails has. On the plus side it packages a lot more functionality with its s standard distribution and we claim it is faster and easier to use. Has any Rails user tried it? What is your impression? No rants please. Just technical comments.
Multiple Django Admin Sites on one Apache... When I log into one I get logged out of the other
327,296
0
3
1,679
0
python,django,admin
The session information is stored in the database, so if you're sharing the database with both running instances, logging off one location will log you off both. If your circumstance requires you to share the database, the easiest workaround is probably to create a second user account with admin privileges.
0
0
0
0
2008-11-29T04:01:00.000
5
0
false
327,142
0
0
1
4
I have two Django projects and applications running on the same Apache installation. Both projects and both applications have the same name, for example myproject.myapplication. They are each in separately named directories so it looks like .../dir1/myproject/myapplication and .../dir2/myproject/myapplication. Everything about the actual public facing applications works fine. When I log into either of the admin sites it seems ok, but if I switch and do any work on the opposite admin site I get logged out of the first one. In short I can't be logged into both admin sites at once. Any help would be appreciated.
Multiple Django Admin Sites on one Apache... When I log into one I get logged out of the other
1,007,356
1
3
1,679
0
python,django,admin
I ran into a similar issue with a live & staging site hosted on the same Apache server (on CentOS). I added unique SESSION_COOKIE_NAME values to each site's settings (in local_settings.py, create one if you don't have one and import it in your settings.py), set the SESSION_COOKIE_DOMAIN for the live site and set SESSION_COOKIE_DOMAIN = None for staging. I also ran "python manage.py cleanup" to (hopefully) clean any conflicted information out of the database.
0
0
0
0
2008-11-29T04:01:00.000
5
0.039979
false
327,142
0
0
1
4
I have two Django projects and applications running on the same Apache installation. Both projects and both applications have the same name, for example myproject.myapplication. They are each in separately named directories so it looks like .../dir1/myproject/myapplication and .../dir2/myproject/myapplication. Everything about the actual public facing applications works fine. When I log into either of the admin sites it seems ok, but if I switch and do any work on the opposite admin site I get logged out of the first one. In short I can't be logged into both admin sites at once. Any help would be appreciated.
Multiple Django Admin Sites on one Apache... When I log into one I get logged out of the other
327,398
0
3
1,679
0
python,django,admin
Let me guess, is this running on your localhost? and you have each site assigned to a different port? i.e. localhost:8000, localhost:8001 ..? I've had the same problem! (although I wasn't running Apache per se) When you login to the admin site, you get a cookie in your browser that's associated with the domain "localhost", the cookie stores a pointer of some sort to a session stored in the database on the server. When you visit the other site, the server tries to interpret the cookie, but fails. I'm guessing it deletes the cookie because it's "garbage". What you can do in this case, is change your domain use localhost:8000 for the first site, and 127.0.0.1:8001 for the second site. this way the second site doesn't attempt to read the cookie that was set by the first site I also think you can edit your HOSTS file to add more aliases to 127.0.0.1 if you need to. (but I haven't tried this)
0
0
0
0
2008-11-29T04:01:00.000
5
0
false
327,142
0
0
1
4
I have two Django projects and applications running on the same Apache installation. Both projects and both applications have the same name, for example myproject.myapplication. They are each in separately named directories so it looks like .../dir1/myproject/myapplication and .../dir2/myproject/myapplication. Everything about the actual public facing applications works fine. When I log into either of the admin sites it seems ok, but if I switch and do any work on the opposite admin site I get logged out of the first one. In short I can't be logged into both admin sites at once. Any help would be appreciated.
Multiple Django Admin Sites on one Apache... When I log into one I get logged out of the other
327,237
0
3
1,679
0
python,django,admin
Well, if they have the same project and application names, then the databases and tables will be the same. Your django_session table which holds the session information is the same for both sites. You have to use different project names that will go in different MySQL (or whatever) databases.
0
0
0
0
2008-11-29T04:01:00.000
5
0
false
327,142
0
0
1
4
I have two Django projects and applications running on the same Apache installation. Both projects and both applications have the same name, for example myproject.myapplication. They are each in separately named directories so it looks like .../dir1/myproject/myapplication and .../dir2/myproject/myapplication. Everything about the actual public facing applications works fine. When I log into either of the admin sites it seems ok, but if I switch and do any work on the opposite admin site I get logged out of the first one. In short I can't be logged into both admin sites at once. Any help would be appreciated.
Converting a PDF to a series of images with Python
657,704
4
50
44,444
0
python,pdf,imagemagick,jpeg,python-imaging-library
You can't avoid the Ghostscript dependency. Even Imagemagick relies on Ghostscript for its PDF reading functions. The reason for this is the complexity of the PDF format: a PDF doesn't just contain bitmap information, but mostly vector shapes, transparencies etc. Furthermore it is quite complex to figure out which of these objects appear on which page. So the correct rendering of a PDF Page is clearly out of scope for a pure Python library. The good news is that Ghostscript is pre-installed on many windows and Linux systems, because it is also needed by all those PDF Printers (except Adobe Acrobat).
0
0
0
0
2008-12-01T19:31:00.000
5
0.158649
false
331,918
1
0
1
1
I'm attempting to use Python to convert a multi-page PDF into a series of JPEGs. I can split the PDF up into individual pages easily enough with available tools, but I haven't been able to find anything that can covert PDFs to images. PIL does not work, as it can't read PDFs. The two options I've found are using either GhostScript or ImageMagick through the shell. This is not a viable option for me, since this program needs to be cross-platform, and I can't be sure either of those programs will be available on the machines it will be installed and used on. Are there any Python libraries out there that can do this?
Django FormWizard and Admin application
337,753
1
3
1,539
0
python,django,forms
There's a lot that you can do, but you'd need to be more specific about what you mean by "integrate a formwizard into the admin app" and "trigger several forms within the admin app." The admin app at its core is basically just a wrapper around a bunch of stock ModelForms, so if you just build a formwizard using ModelForms and slap the admin styling on it, you may be 80% of the way there.
0
0
0
0
2008-12-03T10:29:00.000
2
1.2
true
336,753
0
0
1
1
I have a series of forms that I need a user to complete in sequence, which is perfect for the formwizard app. However, I've some need of the admin application also and would like to set the whole thing up to trigger several forms within the admin app. Is it possible/easy to integrate a 'formwizard' into the admin application? If not, is extending the admin template a viable option and hooking the rest up manually? Opinions? Update: Some clarity in my 'problem'. I wanted to use the admin app as I was thinking I only needed basic modelforms - one perhaps split across many forms, which would have been the role of formwizard. What I have: Form 1: 10 yes/no questions (each yes corresponds to a new form that needs to be filled out) if yes is ticked, the corresponding forms are put into a formwizard and displayed for the user to complete. However the suggested option (modelforms + styling) would take care of the majority of my concerns I guess - and is the seemingly simpler solution.
Is rewriting a PHP app into Python a productive step?
340,338
14
6
1,366
0
php,python
You need to take some parts into mind here, What will you gain from re-writing Is it an economically wise decision Will the code be easier to handle for new programmers Performance-wise, will this be a good option? These four points is something that is important, will the work be more efficient after you re-write the code? Probably. But will it be worth the cost of re-development? One important step to follow, if you decide to re-write, make 3 documents, first Analyze the project, what needs to be done? How should everything work? Then put up a document with Requirements, what specificly do we need and how should this be done? Last but not least, the design document, where you put all your final class diagrams, the system operations and how the design and flow of the page should work. This will help a new developer, and old ones, to actually think about "do we really need to re-write?".
0
0
0
1
2008-12-04T11:48:00.000
11
1.2
true
340,318
0
0
1
8
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly. Is this worth the effort?
Is rewriting a PHP app into Python a productive step?
340,792
1
6
1,366
0
php,python
As others have said, re-writing will take a lot longer than you think and fixing all the bugs and making use everything worked like in the old version will take even longer. Chances are you are better off simply improving and refactoring the php code you have. There are only a few good reasons to port a project from one language to another: Performance. Some languages are simply faster than others, and there comes a point where there is nothing left to optimize and throwing hardware at the problem ceases to be effective. Maintainability. Sometimes it is hard to find good people who know some obscure language which your legacy code is written in. In those cases it might be a good idea to re-write it in a more popular language to ease maintenance down the road. Porting to a different platform. If you all of a sudden need to make your old VB program run on OS X and Linux as well as Windows then you’re probably looking at a re-write in a different language In your case it doesn't seem like any of the above points hold. Of course if it's an unimportant app and you want to do it for the learning experience then by all means go for it, but from a business or economic point of view I'd take a long hard look at what such a re-write will cost and what exactly you hope to gain.
0
0
0
1
2008-12-04T11:48:00.000
11
0.01818
false
340,318
0
0
1
8
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly. Is this worth the effort?
Is rewriting a PHP app into Python a productive step?
340,719
0
6
1,366
0
php,python
Other issues include how business critical are the applications and how hard will it be to find maintainers. If the pages are hobbies of yours then I don't see a reason why you shouldn't rewrite them since if you introduce bugs or the rewrite doesn't go according to schedule a business won't lose money. If the application is central to a business I wouldn’t rewrite it unless you are running into limitations with the current design that can not be overcome with out a complete rewrite at which point the language choice is secondary to the fact that you need to throw out several years of work because it’s not maintainable and no longer meets your needs.
0
0
0
1
2008-12-04T11:48:00.000
11
0
false
340,318
0
0
1
8
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly. Is this worth the effort?
Is rewriting a PHP app into Python a productive step?
340,685
1
6
1,366
0
php,python
If you are going to add more features to the code you already have working, then it might be a good idea to port it to python. After all, it will get you increased productivity. You just have to balance it, whether the rewriting task will not outweigh the potential gain... And also, when you do that, try to unittest as much as you can.
0
0
0
1
2008-12-04T11:48:00.000
11
0.01818
false
340,318
0
0
1
8
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly. Is this worth the effort?
Is rewriting a PHP app into Python a productive step?
340,342
2
6
1,366
0
php,python
Well, it depends... ;) If you're going to use the old code together with new Python code, it might be useful, not so much for speed but for easier integration. But usually: "If it ain't broke, don't fix it". Allso rewriting can result in better code, but only do it if you need to. As a hobby project of course it's worth it, cause the process is the goal.
0
0
0
1
2008-12-04T11:48:00.000
11
0.036348
false
340,318
0
0
1
8
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly. Is this worth the effort?
Is rewriting a PHP app into Python a productive step?
341,834
1
6
1,366
0
php,python
I did a conversion between a PHP site and a Turbogears(Python) site for my company. The initial reason for doing so was two fold, first so a redesign would be easier and second that features could be easily added. It did take a while to get the full conversion done, but what we end up with was a very flexible back end and an even more flexible and readable front end. We've added several features that would have been very hard in PHP and we are currently doing a complete overhaul of the front end, which is turning out to be very easy. In short it's something I would recommend, and my boss would probably say the same thing. Some people here are making good points though. Python isn't as fast as what PHP can give you, but what it lacks in performance it more then makes up for in versatility.
0
0
0
1
2008-12-04T11:48:00.000
11
0.01818
false
340,318
0
0
1
8
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly. Is this worth the effort?
Is rewriting a PHP app into Python a productive step?
340,604
2
6
1,366
0
php,python
As others have said, look at why you are doing it. For instance, at work I am rewriting our existing inventory/sales system to a Python/django backend. Why? Because the existing PHP code base is stale, and is going to scale poorly as we grow our business (plus it was built when our business model was different, then patched up to match our current needs which resulted in some spaghetti code) So basically, if you think you're going to benefit from it in ways that aren't just "sweet this is in python now!" then go for it.
0
0
0
1
2008-12-04T11:48:00.000
11
0.036348
false
340,318
0
0
1
8
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly. Is this worth the effort?
Is rewriting a PHP app into Python a productive step?
340,334
1
6
1,366
0
php,python
Is your aim purely to improve the applications, or is it that you want to learn/work with Python? If it's the first, I would say you should stick with PHP, since you already know that.
0
0
0
1
2008-12-04T11:48:00.000
11
0.01818
false
340,318
0
0
1
8
I have some old apps written in PHP that I'm thinking of converting to Python - both are websites that started as simple static html, then progressed to PHP and now include blogs with admin areas, rss etc. I'm thinking of rewriting them in Python to improve maintainability as well as to take advantage of my increase in experience to write things more robustly. Is this worth the effort?
How do I submit a form given only the HTML source?
343,794
2
0
941
0
python,django,testing,parsing,form-submit
It is simple... and hard at the same time. Disclaimer: I don't know much about Python and nothing at all about Django... So I give general, language agnostic advices... If one of the above advices doesn't work for you, you might want to do it manually: Load the page with an HTML parser, list the forms. If the method attribute is POST (case insensitive), get the action attribute to get the URL of the request (can be relative). In the form, get all input and select tags. The name (or id if no name) attributes are the keys of the request parameters. The value attributes (empty if absent) are the corresponding values. For select, the value is the one of the selected option or the displayed text is no value attribute. These names and values must be URL encoded in GET requests, but not in POST ones. HTH.
0
0
0
0
2008-12-05T12:02:00.000
4
0.099668
false
343,622
0
0
1
1
I would like to be able to submit a form in an HTML source (string). In other words I need at least the ability to generate POST parameters from a string containing HTML source of the form. This is needed in unit tests for a Django project. I would like a solution that possibly; Uses only standard Python library and Django. Allows parameter generation from a specific form if there is more than one form present. Allows me to change the values before submission. A solution that returns a (Django) form instance from a given form class is best. Because it would allow me to use validation. Ideally it would consume the source (which is a string), a form class, and optionally a form name and return the instance as it was before rendering. NOTE: I am aware this is not an easy task, and probably the gains would hardly justify the effort needed. But I am just curious about how this can be done, in a practical and reliable way. If possible.
How to use InterWiki links in moinmoin?
343,926
3
2
714
0
python,wiki,moinmoin
check out the interwiki page in moinmoin, (most wikis have them) we use trac for example and you can set up different link paths to point to your different web resources. So in our Trac you can go [[SSGWiki:Some Topic]] and it will point to another internal wiki.
0
0
1
0
2008-12-05T13:08:00.000
3
1.2
true
343,769
0
0
1
1
We use a number of diffrent web services in our company, wiki(moinmoin), bugtracker (internally), requestracker (customer connection), subversion. Is there a way to parse the wikipages so that if I write "... in Bug1234 you could ..." Bug1234 woud be renderd as a link to http://mybugtracker/bug1234
Having problem importing the PIL image library
344,805
1
0
2,719
0
python,django,image,python-imaging-library
The error above happens because your file is called Image.py and you're trying to import yourself. As Manual pointed out, you should import Image from the PIL module, but you'd also need to rename your file so it's not called Image.py.
0
0
0
0
2008-12-05T18:34:00.000
2
1.2
true
344,753
1
0
1
1
i am trying to do something with the PIL Image library in django, but i experience some problems. I do like this: import Image And then I do like this images = map(Image.open, glob.glob(os.path.join(dirpath, '*.thumb.jpg'))) But when i try to run this i get an error and it leeds me to think that its not imported correctly, anybody know? type object 'Image' has no attribute 'open'
How to test django caching?
348,079
8
17
7,621
0
python,django,caching,django-cache
Mock the view, hit the page, and see if the mock was called. if it was not, the cache was used instead.
0
0
0
0
2008-12-07T17:41:00.000
4
1
false
347,812
0
0
1
2
Is there a way to be sure that a page is coming from cache on a production server and on the development server as well? The solution shouldn't involve caching middleware because not every project uses them. Though the solution itself might be a middleware. Just checking if the data is stale is not a very safe testing method IMO.
How to test django caching?
348,192
2
17
7,621
0
python,django,caching,django-cache
The reason you use caches is to improve performance. Test the performance by running a load test against your server. If the server's performance matches your needs, then you are all set!
0
0
0
0
2008-12-07T17:41:00.000
4
0.099668
false
347,812
0
0
1
2
Is there a way to be sure that a page is coming from cache on a production server and on the development server as well? The solution shouldn't involve caching middleware because not every project uses them. Though the solution itself might be a middleware. Just checking if the data is stale is not a very safe testing method IMO.
Return file from python module
352,385
2
1
14,590
0
python,file,mime-types,download
You can either pass back a reference to the file itself i.e. the full path to the file. Then you can open the file or otherwise manipulate it. Or, the more normal case is to pass back the file handle, and, use the standard read/write operations on the file handle. It is not recommended to pass the actual data as files can be arbiterally large and the program could run out of memory. In your case, you probably want to return a tuple containing the open file handle, the file name and any other meta data you are interested in.
0
0
1
0
2008-12-09T10:34:00.000
3
0.132549
false
352,340
0
0
1
1
Edit: How to return/serve a file from a python controller (back end) over a web server, with the file_name? as suggested by @JV
How can I get the number of records that reference a particular foreign key in Django?
355,537
0
2
270
0
python,django,django-models
You can add field CommentCount to you Post model, and update it in pre_save, pre_delete signals. It's a hard for the db to calculate comments count at every view call and number of queries will be grow.
0
0
0
0
2008-12-10T00:43:00.000
2
0
false
354,755
0
0
1
1
I'm working on a blog application in Django. Naturally, I have models set up such that there are Posts and Comments, and a particular Post may have many Comments; thus, Post is a ForeignKey in the Comments model. Given a Post object, is there an easy way (ideally, through a method call) to find out how many Comments belong to the Post?
Keeping a variable around from post to get?
358,757
1
0
509
0
python,google-app-engine,post,get
HTTP is stateless, so you have no (built-in) way of knowing if the user that loads one page is the same user that loaded another. Further, even if you do know that, thanks to session cookies, for example, you have no way of telling if the browser window they're loading the subsequent page in is the same one they loaded the prior page in. The user could have multiple tabs accessing your site, and you don't want one page's state change to clobber another's. With that in mind, your best option is to include query parameters in the link to the page being fetched with GET, encoding the variables you want to send to the 'get' page (make sure they're not sensitive, since the user can modify them!). Then you can access them through self.request.GET in the get request.
0
0
0
0
2008-12-11T03:50:00.000
6
0.033321
false
358,398
0
0
1
5
I have a class called myClass which defines post() and get() methods. From index.html, I have a form with an action that calls myClass.post() which grabs some data from the data base, sets a couple variables and sends the user to new.html. now, new.html has a form which calls myClass.get(). I want the get() method to know the value of the variables I got in post(). That is is main point here. I figure the submit from new.html creates a separate instance of myClass created by the submit from index.html. Is there a way to access the "post instance" somehow? Is there a workaround for this? If I have to, is there an established way to send the value from post to "new.html" and send it back with the get-submit? more generally, I guess I don't understand the life of my instances when web-programming. In a normal interactive environment, I know when the instance is created and destroyed, but I don't get that when I'm only using the class through calls to its methods. Are those classes even instantiated unless their methods are called?
Keeping a variable around from post to get?
358,805
0
0
509
0
python,google-app-engine,post,get
Why not just use memcache to temporarily store the variable, and then redirect to the POST URL? That seems like the easiest solution.
0
0
0
0
2008-12-11T03:50:00.000
6
0
false
358,398
0
0
1
5
I have a class called myClass which defines post() and get() methods. From index.html, I have a form with an action that calls myClass.post() which grabs some data from the data base, sets a couple variables and sends the user to new.html. now, new.html has a form which calls myClass.get(). I want the get() method to know the value of the variables I got in post(). That is is main point here. I figure the submit from new.html creates a separate instance of myClass created by the submit from index.html. Is there a way to access the "post instance" somehow? Is there a workaround for this? If I have to, is there an established way to send the value from post to "new.html" and send it back with the get-submit? more generally, I guess I don't understand the life of my instances when web-programming. In a normal interactive environment, I know when the instance is created and destroyed, but I don't get that when I'm only using the class through calls to its methods. Are those classes even instantiated unless their methods are called?
Keeping a variable around from post to get?
359,034
3
0
509
0
python,google-app-engine,post,get
What you're talking about is establishing a "session". That is, a way to remember the user and the state of their transaction. There are several ways of tackling this, all of which rely on techniques for remembering that you're in a session in the first place. HTTP provides you no help. You have to find some place to save session state on the server, and some place to record session identification on the client. The two big techniques are Use a cookie to identify the session. Seamless and silent. Use a query string in the URL to identify the session. Obvious because you have a ?sessionid=SomeSessionGUID in your URL's. This exposes a lot and makes bookmarking annoying. After the session is cleaned up, you still have this session id floating around in people's bookmarks. In a limited way, you can also use hidden fields in a form. This only works if you have forms on every page. Not always true. Here's how it plays out in practice. GET response. Check for the cookie in the header. a. No cookie. First time user. Create a session. Save it somewhere (memory, file, database). Put the unique ID into a cookie. Respond knowing this is their first time. b. Cookie. Been here recently. Try to get the cookie. FInd the session object. Respond using information in the cookie. Drat. No session. Old cookie. Create a new one and act like this is their first visit. POST response. Check for the cookie in the header. a. No cookie. WTF? Stupid kids. Get off my lawn! Someone bookmarked a POST or is trying to mess with your head. Respond as if it was a first-time GET. b. Cookie. Excellent. Get the cookie. Find the session object. Find the thing you need in the session object. Respond. Drat. No session. Old cookie. Create a new one and respond as if was a first-time GET. You can do the same thing with a query string instead of a cookie. Or a hidden field on a form.
0
0
0
0
2008-12-11T03:50:00.000
6
0.099668
false
358,398
0
0
1
5
I have a class called myClass which defines post() and get() methods. From index.html, I have a form with an action that calls myClass.post() which grabs some data from the data base, sets a couple variables and sends the user to new.html. now, new.html has a form which calls myClass.get(). I want the get() method to know the value of the variables I got in post(). That is is main point here. I figure the submit from new.html creates a separate instance of myClass created by the submit from index.html. Is there a way to access the "post instance" somehow? Is there a workaround for this? If I have to, is there an established way to send the value from post to "new.html" and send it back with the get-submit? more generally, I guess I don't understand the life of my instances when web-programming. In a normal interactive environment, I know when the instance is created and destroyed, but I don't get that when I'm only using the class through calls to its methods. Are those classes even instantiated unless their methods are called?
Keeping a variable around from post to get?
358,425
0
0
509
0
python,google-app-engine,post,get
I don't know specifically about the google app engine, but normally, here's what happens: The server would have some kind of thread pool. Every time an http request is sent to the server, a thread is selected from the pool or created. In that thread an instance of some kind of controller object will be created. This object will decide what to do with the request (like instantiating other classes and preprocessing the http request parameters). Usually, this object is the core of web frameworks. The request parameters are also resent by the browser every time (the server cannot guess what the browser wants). Web servers usually have state stores for objects in a permanent or a session state. The session is represented by a unique user (usually by a cookie or a GUID in the url), which expires after a certain time. Now in your case, you would need to take the values you got from your first function, store that in the session store and in the second function, get those values back from the session store. Another solution would be to send the items back to the page as url parameters in your generated HTML from the first function and then you would get those back "as usual" from your second function.
0
0
0
0
2008-12-11T03:50:00.000
6
0
false
358,398
0
0
1
5
I have a class called myClass which defines post() and get() methods. From index.html, I have a form with an action that calls myClass.post() which grabs some data from the data base, sets a couple variables and sends the user to new.html. now, new.html has a form which calls myClass.get(). I want the get() method to know the value of the variables I got in post(). That is is main point here. I figure the submit from new.html creates a separate instance of myClass created by the submit from index.html. Is there a way to access the "post instance" somehow? Is there a workaround for this? If I have to, is there an established way to send the value from post to "new.html" and send it back with the get-submit? more generally, I guess I don't understand the life of my instances when web-programming. In a normal interactive environment, I know when the instance is created and destroyed, but I don't get that when I'm only using the class through calls to its methods. Are those classes even instantiated unless their methods are called?
Keeping a variable around from post to get?
360,292
0
0
509
0
python,google-app-engine,post,get
OK -- Thanks everyone. I'll try some of these ideas out, soon, and get back to you all. It seems I can work around some these things by doing a lot of writing and reading from the datastore*, but I thought there might be an easier way of keeping that instance of the class around (I'm trying to use my known techniques in a web framework that I don't completely get yet). *For instance, creating a unique record based on the data in the POST, and letting some variables "tag along". Is this a bad practice?
0
0
0
0
2008-12-11T03:50:00.000
6
0
false
358,398
0
0
1
5
I have a class called myClass which defines post() and get() methods. From index.html, I have a form with an action that calls myClass.post() which grabs some data from the data base, sets a couple variables and sends the user to new.html. now, new.html has a form which calls myClass.get(). I want the get() method to know the value of the variables I got in post(). That is is main point here. I figure the submit from new.html creates a separate instance of myClass created by the submit from index.html. Is there a way to access the "post instance" somehow? Is there a workaround for this? If I have to, is there an established way to send the value from post to "new.html" and send it back with the get-submit? more generally, I guess I don't understand the life of my instances when web-programming. In a normal interactive environment, I know when the instance is created and destroyed, but I don't get that when I'm only using the class through calls to its methods. Are those classes even instantiated unless their methods are called?
Access CVS through Apache service using SSPI
361,235
0
0
820
0
python,apache,cvs,sspi
Usage of SSPI make me think you are using CVSNT, thus a Windows system; what is the user you are running Apache into? Default user for services is SYSTEM, which does not share the same registry as your current user.
0
1
0
0
2008-12-11T21:05:00.000
1
1.2
true
360,911
0
0
1
1
I'm running an Apache server (v2.2.10) with mod_python, Python 2.5 and Django. I have a small web app that will show the current projects we have in CVS and allow users to make a build of the different projects (the build checks out the project, and copies certain files over with the source stripped out). On the Django dev server, everything works fine. I can see the list of projects in cvs, check out, etc. On the production server (the Apache one) I get the following error: [8009030d] The credentials supplied to the package were not recognized I'm trying to log in to the CVS server using SSPI. Entering the same command into a shell will execute properly. This is the code I'm using: def __execute(self, command = ''): command = 'cvs.exe -d :sspi:user:[email protected]:/Projects ls' p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr = subprocess.STDOUT, shell=True) return p.communicate() I've tried a number of different variations of things, and I can't seem to get it to work. Right now I believe that Apache is the culprit. Any help would be appreciated
MVC and django fundamentals
364,161
5
8
5,782
0
python,django,django-models,django-templates
first, forget all MVC mantra. it's important to have a good layered structure, but MVC (as defined originally) isn't one, it was a modular structure, where each GUI module is split in these tree submodules. nothing to use on the web here. in web development, it really pays to have a layered structure, where the most important layer is the storage/modelling one, which came to be called model layer. on top of that, you need a few other layers but they're really not anything like views and controllers in the GUI world. the Django layers are roughly: storage/modelling: models.py, obviously. try to put most of the 'working' concepts there. all the relationships, all the operations should be implemented here. dispatching: mostly in urls.py. here you turn your URL scheme into code paths. think of it like a big switch() statement. try hard to have readable URLs, which map into user intentions. it will help a lot to add new functionality, or new ways to do the same things (like an AJAX UI later). gathering: mostly the view functions, both yours and the prebuilt generic views. here you simply gather all the from the models to satisfy a user request. in surprisingly many cases, it just have to pick a single model instance, and everything else can be retrieved from relationships. for these URLs, a generic view is enough. presentation: the templates. if the view gives you the data you need, it's simple enough to turn it into a webpage. it's here where you'll thank that the model classes have good accessors to get any kind of relevant data from any given instance.
0
0
0
0
2008-12-12T20:22:00.000
3
0.321513
false
364,015
0
0
1
1
Pretty new to this scene and trying to find some documentation to adopt best practices. We're building a fairly large content site which will consist of various media catalogs and I'm trying to find some comparable data / architectural models so that we can get a better idea of the approach we should use using a framework we've never made use of before. Any insight / help would be greatly appreciated!
Which Eclipse distribution is good for web development using Python, PHP, or Perl?
6,481,753
0
4
2,130
0
php,python,perl,eclipse
I develop in PHP, python, C(python modules), SQL and JS/HTML/CSS all on eclipse. I do this by installing PDT, CDT, pydev and SQL tools onto the eclipse-platform, and then using different workspaces for mixed projects. Two workspaces to be specific, one for PHP web development and another for Python/C. I do run it on a rather powerful machine so I allow eclipse the luxury of added memory (2G). Works like a charm and it is very nice to be able to use the same IDE for everything :)
0
0
0
1
2008-12-12T23:26:00.000
7
0
false
364,486
0
0
1
3
I'd like to try out Eclipse, but I'm a bit baffled with all the different distributions of it. I mainly program in Python doing web development, but I also need to maintain PHP and Perl apps. It looks like EasyEclipse is a bit behind. Should I just grab the base Eclipse and start loading plug-ins?
Which Eclipse distribution is good for web development using Python, PHP, or Perl?
18,023,885
0
4
2,130
0
php,python,perl,eclipse
I use the javascript eclipse helios and added pydev plugin to it for django support it seems to do everything I need.
0
0
0
1
2008-12-12T23:26:00.000
7
0
false
364,486
0
0
1
3
I'd like to try out Eclipse, but I'm a bit baffled with all the different distributions of it. I mainly program in Python doing web development, but I also need to maintain PHP and Perl apps. It looks like EasyEclipse is a bit behind. Should I just grab the base Eclipse and start loading plug-ins?
Which Eclipse distribution is good for web development using Python, PHP, or Perl?
364,517
0
4
2,130
0
php,python,perl,eclipse
PyDev is pretty decent as I'm sure you know. It can fit on top of all the Eclipse distributions (provided they meet the minimum version requirements). If you're doing webdev stuff, you'll probably find the closest fit with Aptana. That said, I find Aptana hideously clunky when compared to a decent text editor. I build sites using django and for that I use Eclipse (pure) and PyDev to do the python and gedit (gnome's souped up notepad) for writing the HTML for templates/CSS/JS/etc. At the end of the day, whatever suits you best is what you'll go with.
0
0
0
1
2008-12-12T23:26:00.000
7
0
false
364,486
0
0
1
3
I'd like to try out Eclipse, but I'm a bit baffled with all the different distributions of it. I mainly program in Python doing web development, but I also need to maintain PHP and Perl apps. It looks like EasyEclipse is a bit behind. Should I just grab the base Eclipse and start loading plug-ins?
Can you change a field label in the Django Admin application?
365,431
5
64
67,765
0
python,python-3.x,django,django-forms,django-admin
Building on Javier's answer; if you need one label in forms (on the front-end) and another label on admin it is best to set internal (admin) one in the model and overwrite it on forms. Admin will of course use the label in the model field automatically.
0
0
0
0
2008-12-13T10:30:00.000
6
0.16514
false
365,082
0
0
1
1
As the title suggests. I want to be able to change the label of a single field in the admin application. I'm aware of the Form.field attribute, but how do I get my Model or ModelAdmin to pass along that information?
How to localize Content of a Django application
367,026
0
8
9,378
0
python,django,localization,internationalization
It depends on who will provide the translations. If you want to provide a web interface to translation, then you need to develop that yourself, and also represent the translations in the database. If the same translators who translated the site will also translate the data, you can provide them with the same model that they use for the site (presumably gettext), and you can then also use gettext for this content.
0
0
0
0
2008-12-14T18:48:00.000
10
0
false
366,838
0
0
1
2
Hey, i am currently working on a django app for my studies, and came to the point of l18n. Localizing the site itself was very easy, but now i have to allow users, to translate the dynamic content of the application. Users can save "products" in the database and give them names and descriptions, but since the whole site should be localized, i must provide a way of translating theses names and descriptions to the users. Is there a natural way in django to do this? Or do i have to realize it as part of the application (by representing the translations in the datamodel) Thanks, Janosch
How to localize Content of a Django application
3,870,634
0
8
9,378
0
python,django,localization,internationalization
I think you should operate in two steps: Get translations Show translated strings For the first step, you should tell Django that the user-inserted strings are to be translated. I think there is no native way to do so. Maybe you can extract the strings from your db putting them in locale-specific files, run 'makemessages' on them, obtaint django.po files and translate. Second, use ugettext to show those strings on your web application. Hope this can help the ones with your same problem.
0
0
0
0
2008-12-14T18:48:00.000
10
0
false
366,838
0
0
1
2
Hey, i am currently working on a django app for my studies, and came to the point of l18n. Localizing the site itself was very easy, but now i have to allow users, to translate the dynamic content of the application. Users can save "products" in the database and give them names and descriptions, but since the whole site should be localized, i must provide a way of translating theses names and descriptions to the users. Is there a natural way in django to do this? Or do i have to realize it as part of the application (by representing the translations in the datamodel) Thanks, Janosch
Deleting erroneous ReferenceProperty properties in AppEngine
367,334
1
0
1,235
0
python,google-app-engine,model,referenceproperty
I'm having similar difficulties for my project. As I code the beta version of my application, I do create a lot of dead link and its trully a pain to untangle things afterward. Ideally, this tool would have to also report of the offending reference so that you could pin-point problems in the code.
0
0
0
0
2008-12-14T21:45:00.000
3
0.066568
false
367,029
0
0
1
2
Most of the time, the errors you get from your model properties will happen when you're saving data. For instance, if you try saving a string as an IntegerProperty, that will result in an error. The one exception (no pun intended) is ReferenceProperty. If you have lots of references and you're not completely careful about leaving in bad references, it's common to be greeted with an error like "TemplateSyntaxError: Caught an exception while rendering: ReferenceProperty failed to be resolved". And this is if there's only one bad reference in the view. D'oh. I could write a try/except block to try to access all the reference properties and delete them if an exception is raised, but this functionality could surely be useful to many other developers if there was a more generic method than the one I'd be capable of writing. I imagine it would take a list of model types and try to access each reference property of each entity in each model, setting the property to None if an exception is raised. I'll see if I can do this myself, but it would definitely help to have some suggestions/snippets to get me started.
Deleting erroneous ReferenceProperty properties in AppEngine
374,241
0
0
1,235
0
python,google-app-engine,model,referenceproperty
You could extend and customize ReferenceProperty to not throw this exception, but then it'll need to return something - presumably None - in which case your template will simply throw an exception when it attempts to access properties on the returned object. A better approach is to fetch the referenceproperty and check it's valid before rendering the template. ReferenceProperties cache their references, so prefetching won't result in extra datastore calls.
0
0
0
0
2008-12-14T21:45:00.000
3
0
false
367,029
0
0
1
2
Most of the time, the errors you get from your model properties will happen when you're saving data. For instance, if you try saving a string as an IntegerProperty, that will result in an error. The one exception (no pun intended) is ReferenceProperty. If you have lots of references and you're not completely careful about leaving in bad references, it's common to be greeted with an error like "TemplateSyntaxError: Caught an exception while rendering: ReferenceProperty failed to be resolved". And this is if there's only one bad reference in the view. D'oh. I could write a try/except block to try to access all the reference properties and delete them if an exception is raised, but this functionality could surely be useful to many other developers if there was a more generic method than the one I'd be capable of writing. I imagine it would take a list of model types and try to access each reference property of each entity in each model, setting the property to None if an exception is raised. I'll see if I can do this myself, but it would definitely help to have some suggestions/snippets to get me started.
What is the best way to serialize a ModelForm object in Django?
372,371
0
2
2,670
0
python,xml,django,json,serialization
If your problem is just to serialze a ModelForm to json, just write your own simplejson serializer subclass.
0
0
0
0
2008-12-15T18:12:00.000
2
0
false
369,230
0
0
1
1
I am using Django and the Google Web Toolkit (GWT) for my current project. I would like to pass a ModelForm instance to GWT via an Http response so that I can "chop" it up and render it as I please. My goal is to keep the form in sync with changes to my models.py file, yet increase control I have over the look of the form. However, the django classes for serialization, serializers and simplejson, cannot serialize a ModelForm. Neither can cPickle. What are my alternatives?
Is there anyone who has managed to compile mod_wsgi for apache on Mac OS X Leopard?
392,945
2
4
953
0
python,django,apache
This doesn't directly answer your question, but have you thought about using something like MacPorts for this sort of thing? If you're compiling a lot of software like this, MacPorts can really make your life easier, since building software and dependencies is practically automatic.
0
1
0
0
2008-12-15T18:39:00.000
1
0.379949
false
369,305
0
0
1
1
I'm working on a Django project that requires debugging on a multithreaded server. I've found mod_wsgi 2.0+ to be the easiest to work with, because of easy workarounds for python module reloading. Problem is can't get it to compile on Leopard. Is there anyone who has managed to do it so far, either for the builtin Apache or MAMP. I'd be grateful if someone posts a link to a precompiled binary (for intel, python 2.5, apache 2.2 or 2.0). After 3 hours of trial and error I've managed to compile mod_wsgi 2.3 for the Apache that comes with Leopard. Here are the instructions in case anyone else needs this. ./configure Change 2 lines in the Makefile CFLAGS = -Wc,'-arch i386' LDFLAGS = -arch i386 -Wl,-F/Library/Frameworks -framework Python -u _PyMac_Error make && sudo make install Make a thin binary of the original httpd cd /usr/sbin sudo mv ./httpd ./httpd.fat sudo lipo ./httpd.fat -thin i386 -output ./httpd.i386 sudo ln -s ./httpd.i386 ./httpd This should work on intel macbook, macbook pro, imac and mac mini. As I understood the problem is modwsgi won't compile against MacPython 2.5.2 because of some weird architecture missmatch problem. But, if you compile it as a thin binary it won't play with the Apache fat binary. So this hack solves the problem. The rest is pretty standard configuration, like on any other platform.
Secure, sandboxable user exposed programming language / environment?
373,415
2
7
421
0
javascript,python,sandbox
I use Lua for this, but it's directed at a Lua capable community. So my answer would be who are your users? If your users are internal, like my case, and proficient with Python use Python. However if this is something for the world wide web, I'd probably choose javascript, because its the lingua franca, (every developer knows it, and its easy to pickup). As for an Engine... well V8 would be nice, but its not 100% thread safe, in that you can't run several engine within the same process in a lock free manner, as you can with SpiderMonkey. So You might want to use that. Also since javascript is sandboxed by default you won't have to worry about implementing much on your side.
0
0
0
1
2008-12-17T01:38:00.000
1
0.379949
false
373,406
0
0
1
1
Beyond offering an API for my website, I'd like to offer users the ability to write simple scripts that would run on my servers . The scripts would have access to objects owned by the user and be able to manipulate, modify, and otherwise process their data. I'd like to be able to limit resources taken by these scripts at a fine level (eg. max execution time should be 100ms). I'd also like to ensure a secure sandbox such that each user will have access to only a limited set of data and resources, and be prevented from accessing disk, other people's data, etc. Generally the scripts will be very simple (eg. create the sum or average of the values that match certain criteria), and they'll often be used in templates (eg. fill in the value of this cell or html element with the average or sum). Ideally I'd like to use a sandboxed subset of a well know, commonly available programming language so it's easy for users to pick up. The backend is written in Python, so a Python based language could have benefits, but I'm open to other languages and technologies. Javascript is also attractive due to its simple nature and common availability. The languages should support creation of DSLs and libraries. The target audience is a general user base for a web based application, not necessarily very technical. In other words, it's not targeted at a base with particular knowledge of any particular programming language. My expectation is a subset of users will create scripts that will be used by the larger majority. Any ideas or recommendations for the language and technology? Any examples of others trying this and the successes and failures they encountered?
How to integrate the StringTemplate engine into the CherryPy web server
467,736
4
2
1,241
0
python,cherrypy,stringtemplate
Based on the tutorials for both, it looks pretty straightforward: import stringtemplate import cherrypy class HelloWorld(object): def index(self): hello = stringtemplate.StringTemplate("Hello, $name$") hello["name"] = "World" return str(hello) index.exposed = True cherrypy.quickstart(HelloWorld()) You'll probably want to have the CherryPy functions find the StringTemplate's in some location on disk instead, but the general idea will be like this. Django is conceptually similar: url's are mapped to python functions, and the python functions generally build up a context dictionary, render a template with that context object, and return the result.
0
0
0
0
2008-12-18T21:23:00.000
2
0.379949
false
379,338
0
0
1
2
I love the StringTemplate engine, and I love the CherryPy web server, and I know that they can be integrated. Who has done it? How? EDIT: The TurboGears framework takes the CherryPy web server and bundles other related components such as a template engine, data access tools, JavaScript kit, etc. I am interested in MochiKit, demand CherryPy, but I don't want any other template engine than StringTemplate (architecture is critical--I don't want another broken/bad template engine). Therefore, it would be acceptable to answer this question by addressing how to integrate StringTemplate with TurboGears. It may also be acceptable to answer this question by addressing how to use CherryPy and StringTemplate in the Google App Engine. Thanks.
How to integrate the StringTemplate engine into the CherryPy web server
463,042
0
2
1,241
0
python,cherrypy,stringtemplate
Rob, There's reason behind people's selection of tools. StringTemplate is not terribly popular for Python, there are templating engines that are much better supported and with a much wider audience. If you don't like Kid, there's also Django's templating, Jinja, Cheetah and others. Perhaps you can find in one of them the features you like so much in StringTemplate and live happily ever after.
0
0
0
0
2008-12-18T21:23:00.000
2
0
false
379,338
0
0
1
2
I love the StringTemplate engine, and I love the CherryPy web server, and I know that they can be integrated. Who has done it? How? EDIT: The TurboGears framework takes the CherryPy web server and bundles other related components such as a template engine, data access tools, JavaScript kit, etc. I am interested in MochiKit, demand CherryPy, but I don't want any other template engine than StringTemplate (architecture is critical--I don't want another broken/bad template engine). Therefore, it would be acceptable to answer this question by addressing how to integrate StringTemplate with TurboGears. It may also be acceptable to answer this question by addressing how to use CherryPy and StringTemplate in the Google App Engine. Thanks.
104, 'Connection reset by peer' socket error, or When does closing a socket result in a RST rather than FIN?
52,826,181
2
39
140,801
0
python,sockets,wsgi,httplib2,werkzeug
I had the same issue however with doing an upload of a very large file using a python-requests client posting to a nginx+uwsgi backend. What ended up being the cause was the the backend had a cap on the max file size for uploads lower than what the client was trying to send. The error never showed up in our uwsgi logs since this limit was actually one imposed by nginx. Upping the limit in nginx removed the error.
0
0
1
0
2008-12-20T21:04:00.000
4
0.099668
false
383,738
0
0
1
3
We're developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read: (104, 'Connection reset by peer') When I listen in with wireshark, the "good" and "bad" responses look very similar: Because of the size of the OAuth header, the request is split into two packets. The service responds to both with ACK The service sends the response, one packet per header (HTTP/1.0 200 OK, then the Date header, etc.). The client responds to each with ACK. (Good request) the server sends a FIN, ACK. The client responds with a FIN, ACK. The server responds ACK. (Bad request) the server sends a RST, ACK, the client doesn't send a TCP response, the socket.error is raised on the client side. Both the web service and the client are running on a Gentoo Linux x86-64 box running glibc-2.6.1. We're using Python 2.5.2 inside the same virtual_env. The client is a Django 1.0.2 app that is calling httplib2 0.4.0 to make requests. We're signing requests with the OAuth signing algorithm, with the OAuth token always set to an empty string. The service is running Werkzeug 0.3.1, which is using Python's wsgiref.simple_server. I ran the WSGI app through wsgiref.validator with no issues. It seems like this should be easy to debug, but when I trace through a good request on the service side, it looks just like the bad request, in the socket._socketobject.close() function, turning delegate methods into dummy methods. When the send or sendto (can't remember which) method is switched off, the FIN or RST is sent, and the client starts processing. "Connection reset by peer" seems to place blame on the service, but I don't trust httplib2 either. Can the client be at fault? ** Further debugging - Looks like server on Linux ** I have a MacBook, so I tried running the service on one and the client website on the other. The Linux client calls the OS X server without the bug (FIN ACK). The OS X client calls the Linux service with the bug (RST ACK, and a (54, 'Connection reset by peer')). So, it looks like it's the service running on Linux. Is it x86_64? A bad glibc? wsgiref? Still looking... ** Further testing - wsgiref looks flaky ** We've gone to production with Apache and mod_wsgi, and the connection resets have gone away. See my answer below, but my advice is to log the connection reset and retry. This will let your server run OK in development mode, and solidly in production.
104, 'Connection reset by peer' socket error, or When does closing a socket result in a RST rather than FIN?
481,952
11
39
140,801
0
python,sockets,wsgi,httplib2,werkzeug
Don't use wsgiref for production. Use Apache and mod_wsgi, or something else. We continue to see these connection resets, sometimes frequently, with wsgiref (the backend used by the werkzeug test server, and possibly others like the Django test server). Our solution was to log the error, retry the call in a loop, and give up after ten failures. httplib2 tries twice, but we needed a few more. They seem to come in bunches as well - adding a 1 second sleep might clear the issue. We've never seen a connection reset when running through Apache and mod_wsgi. I don't know what they do differently, (maybe they just mask them), but they don't appear. When we asked the local dev community for help, someone confirmed that they see a lot of connection resets with wsgiref that go away on the production server. There's a bug there, but it is going to be hard to find it.
0
0
1
0
2008-12-20T21:04:00.000
4
1
false
383,738
0
0
1
3
We're developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read: (104, 'Connection reset by peer') When I listen in with wireshark, the "good" and "bad" responses look very similar: Because of the size of the OAuth header, the request is split into two packets. The service responds to both with ACK The service sends the response, one packet per header (HTTP/1.0 200 OK, then the Date header, etc.). The client responds to each with ACK. (Good request) the server sends a FIN, ACK. The client responds with a FIN, ACK. The server responds ACK. (Bad request) the server sends a RST, ACK, the client doesn't send a TCP response, the socket.error is raised on the client side. Both the web service and the client are running on a Gentoo Linux x86-64 box running glibc-2.6.1. We're using Python 2.5.2 inside the same virtual_env. The client is a Django 1.0.2 app that is calling httplib2 0.4.0 to make requests. We're signing requests with the OAuth signing algorithm, with the OAuth token always set to an empty string. The service is running Werkzeug 0.3.1, which is using Python's wsgiref.simple_server. I ran the WSGI app through wsgiref.validator with no issues. It seems like this should be easy to debug, but when I trace through a good request on the service side, it looks just like the bad request, in the socket._socketobject.close() function, turning delegate methods into dummy methods. When the send or sendto (can't remember which) method is switched off, the FIN or RST is sent, and the client starts processing. "Connection reset by peer" seems to place blame on the service, but I don't trust httplib2 either. Can the client be at fault? ** Further debugging - Looks like server on Linux ** I have a MacBook, so I tried running the service on one and the client website on the other. The Linux client calls the OS X server without the bug (FIN ACK). The OS X client calls the Linux service with the bug (RST ACK, and a (54, 'Connection reset by peer')). So, it looks like it's the service running on Linux. Is it x86_64? A bad glibc? wsgiref? Still looking... ** Further testing - wsgiref looks flaky ** We've gone to production with Apache and mod_wsgi, and the connection resets have gone away. See my answer below, but my advice is to log the connection reset and retry. This will let your server run OK in development mode, and solidly in production.
104, 'Connection reset by peer' socket error, or When does closing a socket result in a RST rather than FIN?
384,415
3
39
140,801
0
python,sockets,wsgi,httplib2,werkzeug
Normally, you'd get an RST if you do a close which doesn't linger (i.e. in which data can be discarded by the stack if it hasn't been sent and ACK'd) and a normal FIN if you allow the close to linger (i.e. the close waits for the data in transit to be ACK'd). Perhaps all you need to do is set your socket to linger so that you remove the race condition between a non lingering close done on the socket and the ACKs arriving?
0
0
1
0
2008-12-20T21:04:00.000
4
0.148885
false
383,738
0
0
1
3
We're developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read: (104, 'Connection reset by peer') When I listen in with wireshark, the "good" and "bad" responses look very similar: Because of the size of the OAuth header, the request is split into two packets. The service responds to both with ACK The service sends the response, one packet per header (HTTP/1.0 200 OK, then the Date header, etc.). The client responds to each with ACK. (Good request) the server sends a FIN, ACK. The client responds with a FIN, ACK. The server responds ACK. (Bad request) the server sends a RST, ACK, the client doesn't send a TCP response, the socket.error is raised on the client side. Both the web service and the client are running on a Gentoo Linux x86-64 box running glibc-2.6.1. We're using Python 2.5.2 inside the same virtual_env. The client is a Django 1.0.2 app that is calling httplib2 0.4.0 to make requests. We're signing requests with the OAuth signing algorithm, with the OAuth token always set to an empty string. The service is running Werkzeug 0.3.1, which is using Python's wsgiref.simple_server. I ran the WSGI app through wsgiref.validator with no issues. It seems like this should be easy to debug, but when I trace through a good request on the service side, it looks just like the bad request, in the socket._socketobject.close() function, turning delegate methods into dummy methods. When the send or sendto (can't remember which) method is switched off, the FIN or RST is sent, and the client starts processing. "Connection reset by peer" seems to place blame on the service, but I don't trust httplib2 either. Can the client be at fault? ** Further debugging - Looks like server on Linux ** I have a MacBook, so I tried running the service on one and the client website on the other. The Linux client calls the OS X server without the bug (FIN ACK). The OS X client calls the Linux service with the bug (RST ACK, and a (54, 'Connection reset by peer')). So, it looks like it's the service running on Linux. Is it x86_64? A bad glibc? wsgiref? Still looking... ** Further testing - wsgiref looks flaky ** We've gone to production with Apache and mod_wsgi, and the connection resets have gone away. See my answer below, but my advice is to log the connection reset and retry. This will let your server run OK in development mode, and solidly in production.
How do you manage your Django applications?
388,021
3
7
1,848
0
python,django,project,structure
A good question to ask yourself when deciding whether or not to write an app is "could I use this in another project?". If you think you could, then consider what it would take to make the application as independent as possible; How can you reduce the dependancies so that the app doesn't rely on anything specific to a particular project. Some of the ways you can do this are: Giving each app its own urls.py Allowing model types to be passed in as parameters rather than explicitly declaring what models are used in your views. Generic views use this principle. Make your templates easily overridden by having some sort of template_name parameter passed in your urls.py Make sure you can do reverse url lookups with your objects and views. This means naming your views in the urls.py and creating get_absolute_url methods on your models. In some cases like Tagging, GenericForeignKeys can be used to associate a model in your app to any other model, regardless of whether it has ForeignKeys "looking back" at it.
0
0
0
0
2008-12-21T10:48:00.000
5
0.119427
false
384,333
0
0
1
3
I just wanted to try to build a project with django. Therefore I have a (basic) question on how to manage such a project. Since I cannot find any guidelines or so on how to split a project into applications. Let's take a kind of SO as an example. Which applications would you use? I'd say there should be the applications "users" and "questions". But what if there was a topic system with static articles, too. Maybe they also could receive votes. How to build the apps structure then? One app for "questions", "votes" and "topics" or just one app "content"? I have no idea what to do. Maybe it's because I know not very much about Django yet, but I'm interested either...
How do you manage your Django applications?
384,377
0
7
1,848
0
python,django,project,structure
I'll tell you how I am approaching such question: I usually sit with a sheet of paper and draw the boxes (functionalities) and arrows (interdependencies between functionalities). I am sure there are methodologies or other things that could help you, but my approach usually works for me (YMMV, of course). Knowing what a site is supposed to be is basic, though. ;)
0
0
0
0
2008-12-21T10:48:00.000
5
0
false
384,333
0
0
1
3
I just wanted to try to build a project with django. Therefore I have a (basic) question on how to manage such a project. Since I cannot find any guidelines or so on how to split a project into applications. Let's take a kind of SO as an example. Which applications would you use? I'd say there should be the applications "users" and "questions". But what if there was a topic system with static articles, too. Maybe they also could receive votes. How to build the apps structure then? One app for "questions", "votes" and "topics" or just one app "content"? I have no idea what to do. Maybe it's because I know not very much about Django yet, but I'm interested either...
How do you manage your Django applications?
384,494
3
7
1,848
0
python,django,project,structure
Just like any set of dependencies... try to find the most useful stand-alone aspects of the project and make those stand-alone apps. Other Django Apps will have higher level functionality, and reuse the parts of the lowest level apps that you have set up. In my project, I have a calendar app with its own Event object in its models. I also have a carpool database set up, and for the departure time and the duration I use the calendar's Event object right in my RideShare tables. The carpooling database is calendar-aware, and gets all the nice .ics export and calendar views from the calendar app for 'free.' There are some tricks to getting the Apps reusable, like naming the templates directory: project/app2/templates/app2/index.html. This lets you refer to app2/index.html from any other app, and get the right template. I picked that one up looking at the built-in reusable apps in Django itself. Pinax is a bit of a monster size-wise but it also demonstrates a nice reusable App structure. If in doubt, forget about reusable apps for now. Put all your messages and polls in one app and get through one rev. You'll discover during the process what steps feel unnecessary, and could be broken out as something stand-alone in the future.
0
0
0
0
2008-12-21T10:48:00.000
5
0.119427
false
384,333
0
0
1
3
I just wanted to try to build a project with django. Therefore I have a (basic) question on how to manage such a project. Since I cannot find any guidelines or so on how to split a project into applications. Let's take a kind of SO as an example. Which applications would you use? I'd say there should be the applications "users" and "questions". But what if there was a topic system with static articles, too. Maybe they also could receive votes. How to build the apps structure then? One app for "questions", "votes" and "topics" or just one app "content"? I have no idea what to do. Maybe it's because I know not very much about Django yet, but I'm interested either...
How do you debug Mako templates?
390,603
1
41
10,962
0
python,debugging,templates,jinja2,mako
I break them down into pieces, and then reassemble the pieces when I've found the problem. Not good, but it's really hard to tell what went wrong in a big, complex template.
0
0
0
1
2008-12-23T23:43:00.000
6
0.033321
false
390,409
0
0
1
1
So far I've found it impossible to produce usable tracebacks when Mako templates aren't coded correctly. Is there any way to debug templates besides iterating for every line of code?
Is there a Ruby/Python HTML reflow/layout library?
392,243
3
3
488
0
python,html,ruby,layout
Scriptor, I think what you likely are looking for might be something in JavaScript more then Ruby or Python. I mean - the positions and sizes are essentially going to be determined by the rendering engine (the browser). You might consider using something like jQuery to loop through all of your desired objects - outputting the name of the object (like the DIV's ID) and the height and width of that item. So, for what it's worth I'd look at jQuery if I was in your position and the height() and width() methods. You never know - there may already be a jQuery plugin.
0
0
0
0
2008-12-24T21:05:00.000
2
0.291313
false
392,217
0
0
1
2
I'm looking for a library in Ruby or Python that would take some HTML and CSS as the input and return data that contains the positions and sizes of the elements. If it helps, I don't need the info for all the elements but just the major divs of the page.
Is there a Ruby/Python HTML reflow/layout library?
392,412
-1
3
488
0
python,html,ruby,layout
Both Ruby and Python have a Regex library. Why not search for things like /width=\"(\d+)px\"/ and /height:(\d+)px/. Use $1 to find the value in the group. I'm not a regex expert and I'm doing this from memory, so refer to any of the tutorials on the net for the correct syntax and variable usage, but that's where to start. Good luck, bsperlinus
0
0
0
0
2008-12-24T21:05:00.000
2
-0.099668
false
392,217
0
0
1
2
I'm looking for a library in Ruby or Python that would take some HTML and CSS as the input and return data that contains the positions and sizes of the elements. If it helps, I don't need the info for all the elements but just the major divs of the page.
How to process two forms in one view?
392,849
0
5
7,720
0
python,django,django-forms,django-templates
If the two forms are completely different, it will certainly not hurt to have them be handled by two different views. Otherwise, you may use the 'hidden input element' trick zacherates has touched upon. Or, you could always give each submit element a unique name, and differentiate in the view which form was submitted based on that.
0
0
0
0
2008-12-25T12:40:00.000
3
0
false
392,784
0
0
1
1
I have two completely different forms in one template. How to process them in one view? How can I distinguish which of the forms was submitted? How can I use prefix to acomplish that? Or maybe it's better to write separate views? regards chriss
What values to use for FastCGI maxrequests, maxspare, minspare, maxchildren?
393,636
13
6
5,068
0
python,django,fastcgi
Let's start with the definition maxrequests: How many requests does a child server before being killed and a new one forked maxspare : Maximum number of spare processes to keep running minspare : Minimum number of spare processes to prefork maxchildren: Hard limit number of processes in prefork mode This means that you'll have at most maxchildren processes running at any given time in your webserver, each running for maxrequests requests. At server start you'll get minspare processes, which will keep growing until maxspare (or maxchildren) if more requests are coming. So, minspare lets you say how many concurrent requests are you expecting at a minimum (important to avoid the process creation if you start with one, it's good to start at, say 10), and maxspare lets you say how many concurrent requests will your server attend to at most (without compromising it's expected response time and so on. Needs a stress test to validate). And maxrequests is talking about the lifetime of each child, in case they cannot run forever due to any kind of constraint.
0
0
0
0
2008-12-26T08:49:00.000
2
1.2
true
393,629
0
0
1
2
I'm running a Django app using FastCGI and lighttpd. Can somebody explain me what I should consider when deciding what value to use for maxrequests, maxspare, minspare, maxchildren? These options are not too well documented, but seem quite important. Don't just tell me what they do; I want to understand what implications they have and how I should decide on what values to use. Thanks.
What values to use for FastCGI maxrequests, maxspare, minspare, maxchildren?
393,649
-1
6
5,068
0
python,django,fastcgi
Don't forget to coordinate your fcgi settings with your apache worker settings. I usually keep more apache workers around than fcgi workers... they are lighter weight and will wait for an available fcgi worker to free up to process the request if the concurrency reaches higher than my maxspare.
0
0
0
0
2008-12-26T08:49:00.000
2
-0.099668
false
393,629
0
0
1
2
I'm running a Django app using FastCGI and lighttpd. Can somebody explain me what I should consider when deciding what value to use for maxrequests, maxspare, minspare, maxchildren? These options are not too well documented, but seem quite important. Don't just tell me what they do; I want to understand what implications they have and how I should decide on what values to use. Thanks.
Python POST data using mod_wsgi
1,038,071
14
15
12,755
0
python,mod-wsgi
Be aware that technically speaking calling read() or read(-1) on wsgi.input is a violation of the WSGI specification even though Apache/mod_wsgi allows it. This is because the WSGI specification requires that a valid length argument be supplied. The WSGI specification also says you shouldn't read more data than is specified by the CONTENT_LENGTH. So, the code above may work in Apache/mod_wsgi but it isn't portable WSGI code and will fail on some other WSGI implementations. To be correct, determine request content length and supply that value to read().
0
0
0
0
2008-12-26T23:35:00.000
2
1
false
394,465
0
0
1
1
This must be a very simple question, but I don't seem to be able to figure out. I'm using apache + mod_wsgi to host my python application, and I'd like to get the post content submitted in one of the forms -however, neither the environment values, nor sys.stdin contains any of this data. Mind giving me a quick hand? Edit: Tried already: environ["CONTENT_TYPE"] = 'application/x-www-form-urlencoded' (no data) environ["wsgi.input"] seems a plausible way, however, both environ["wsgi.input"].read(), and environ["wsgi.input"].read(-1) returns an empty string (yes, content has been posted, and environ["request_method"] = "post"
PHP vs. application server?
397,669
1
5
1,413
0
php,python
Python web-apps tend to require more initial setup and development than the equivalent PHP site (particularly so for small sites). There also tend to be more reusable pieces for PHP (ie Wordpress as a blog). Configuring a server to run Python web-apps can be a difficult process, and not always well documented. PHP tends to be very easy to get running with Apache. Also, as PHP is very widely used and is heavily used by beginners, there tends to be very good documentation for it. However, Python is much more fun, and much more maintainable. It scales well (in development complexity terms, rather than traffic). Personally, I would also say that using Python tends to train you to solve problems in a better way. I am definitely a better developer for having learned the Pythonic way of doing things.
0
0
0
1
2008-12-28T07:56:00.000
5
0.039979
false
395,960
0
0
1
3
For those of you who have had the opportunity of writing web applications in PHP and then as an application server (eg. Python-based solutions like CherryPy or Pylons), in what context are application servers a better alternative to PHP? I tend to favor PHP simply because it's available on just about any web server (especially shared host), but I'm looking for other good reasons to make an informed choice. Thank you.
PHP vs. application server?
396,717
0
5
1,413
0
php,python
Using application servers like Pylons, Django, etc. require much more work to setup and deploy then PHP applications which are generally supported out of the box. I run a few Django apps and had to learn a bit of configuring apache with mod_python in order to get things to work. I put forth the effort because coding in python is much more enjoyable to me than PHP and after you get the Apache config right once you never really have to mess with it again. On another note, if you decide to go with a framework like Django, Rails, Pylons, .... they tend to solve a lot of small repetitive tasks that you would otherwise do on your own. But frameworks are their own huge topic of discussion.
0
0
0
1
2008-12-28T07:56:00.000
5
0
false
395,960
0
0
1
3
For those of you who have had the opportunity of writing web applications in PHP and then as an application server (eg. Python-based solutions like CherryPy or Pylons), in what context are application servers a better alternative to PHP? I tend to favor PHP simply because it's available on just about any web server (especially shared host), but I'm looking for other good reasons to make an informed choice. Thank you.
PHP vs. application server?
397,730
5
5
1,413
0
php,python
I have a feeling that some of the responses didn't address the initial question directly, so I decided to post my own. I understand that the question was about the difference between the mod_php deployment model and the application server deployment model. In simple words, PHP executes a given script on every request, and the application has no knowledge of what has happened before (unless it is emulated somehow). Moreover even the source code is being parsed on every request (unless you use a bytecode cache like APC). This process can be slow, especially if you have a framework with complex initialization. In contrast to this, the application server has to be started once, and then it waits for a request to be processed. The application server should clean up resources after every requests (allocated memory, open descriptors, etc.), it can also pool certain resources (like database connections) that can be reused between requests for extra performance. This later model (application server) is more efficient in most cases, but on the other hand more difficult to setup and maintain. It is also more demanding, as you have to pay more attention to the resources you utilize, in order to avoid resource leaks.
0
0
0
1
2008-12-28T07:56:00.000
5
0.197375
false
395,960
0
0
1
3
For those of you who have had the opportunity of writing web applications in PHP and then as an application server (eg. Python-based solutions like CherryPy or Pylons), in what context are application servers a better alternative to PHP? I tend to favor PHP simply because it's available on just about any web server (especially shared host), but I'm looking for other good reasons to make an informed choice. Thank you.
How to limit rate of requests to web services in Python?
401,826
1
18
17,294
0
python,web-services,rate-limiting
SO I am assuming something simple like import time time.sleep(2) will not work for waiting 2 seconds between requests
0
0
1
0
2008-12-30T19:30:00.000
6
0.033321
false
401,215
1
0
1
3
I'm working on a Python library that interfaces with a web service API. Like many web services I've encountered, this one requests limiting the rate of requests. I would like to provide an optional parameter, limit, to the class instantiation that, if provided, will hold outgoing requests until the number of seconds specified passes. I understand that the general scenario is the following: an instance of the class makes a request via a method. When it does, the method emits some signal that sets a lock variable somewhere, and begins a countdown timer for the number of seconds in limit. (In all likelihood, the lock is the countdown timer itself.) If another request is made within this time frame, it must be queued until the countdown timer reaches zero and the lock is disengaged; at this point, the oldest request on the queue is sent, and the countdown timer is reset and the lock is re-engaged. Is this a case for threading? Is there another approach I'm not seeing? Should the countdown timer and lock be instance variables, or should they belong to the class, such that all instances of the class hold requests? Also, is this generally a bad idea to provide rate-limiting functionality within a library? I reason since, by default, the countdown is zero seconds, the library still allows developers to use the library and provide their own rate-limiting schemes. Given any developers using the service will need to rate-limit requests anyway, however, I figure that it would be a convenience for the library to provide a means of rate-limiting. Regardless of placing a rate-limiting scheme in the library or not, I'll want to write an application using the library, so suggested techniques will come in handy.
How to limit rate of requests to web services in Python?
401,332
1
18
17,294
0
python,web-services,rate-limiting
Your rate limiting scheme should be heavily influenced by the calling conventions of the underlying code (syncronous or async), as well as what scope (thread, process, machine, cluster?) this rate-limiting will operate at. I would suggest keeping all the variables within the instance, so you can easily implement multiple periods/rates of control. Lastly, it sounds like you want to be a middleware component. Don't try to be an application and introduce threads on your own. Just block/sleep if you are synchronous and use the async dispatching framework if you are being called by one of them.
0
0
1
0
2008-12-30T19:30:00.000
6
0.033321
false
401,215
1
0
1
3
I'm working on a Python library that interfaces with a web service API. Like many web services I've encountered, this one requests limiting the rate of requests. I would like to provide an optional parameter, limit, to the class instantiation that, if provided, will hold outgoing requests until the number of seconds specified passes. I understand that the general scenario is the following: an instance of the class makes a request via a method. When it does, the method emits some signal that sets a lock variable somewhere, and begins a countdown timer for the number of seconds in limit. (In all likelihood, the lock is the countdown timer itself.) If another request is made within this time frame, it must be queued until the countdown timer reaches zero and the lock is disengaged; at this point, the oldest request on the queue is sent, and the countdown timer is reset and the lock is re-engaged. Is this a case for threading? Is there another approach I'm not seeing? Should the countdown timer and lock be instance variables, or should they belong to the class, such that all instances of the class hold requests? Also, is this generally a bad idea to provide rate-limiting functionality within a library? I reason since, by default, the countdown is zero seconds, the library still allows developers to use the library and provide their own rate-limiting schemes. Given any developers using the service will need to rate-limit requests anyway, however, I figure that it would be a convenience for the library to provide a means of rate-limiting. Regardless of placing a rate-limiting scheme in the library or not, I'll want to write an application using the library, so suggested techniques will come in handy.