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
pydev not recognizing python installation with django
4,049,594
0
15
11,629
0
python,django,eclipse,pydev
I think I've got the same problem, Eclipse 3.5.2 on Fedora. In my PyDev Python interpreter settings I've got the site-packages/django folder (site-packages/django/bin too, just in case), but when I try to create a django project I get an error dialogue saying "It seems that the selected interpreter does not have Django available". Looks like I'm going to have to use Eric4, which is a pity because I can't get that working at all on my Windows rig! Unless I manage to understand the cryptic advice above, "Django must not be among the system libraries for this to function..."
0
0
0
0
2010-10-15T06:11:00.000
10
0
false
3,939,877
1
0
1
10
I have python installed with django. I know the installation is there because I installed it following the directions and in the command line I can do "import python" and there is no crash. When I try creating a django project in pydev, I get an error: "Django not found." What could the problem be?
pydev not recognizing python installation with django
4,241,222
21
15
11,629
0
python,django,eclipse,pydev
I had the same problem and this is what I did just after installing eclipse: Preferences > Interpreter Python Pressed Auto-config Selected /Library/Python/x.x/site-packages, which was not selected (some django folders were in there, persumably the installation) Clicked apply / OK Creating a Django project afterwards should be ok. Good Luck!
0
0
0
0
2010-10-15T06:11:00.000
10
1
false
3,939,877
1
0
1
10
I have python installed with django. I know the installation is there because I installed it following the directions and in the command line I can do "import python" and there is no crash. When I try creating a django project in pydev, I get an error: "Django not found." What could the problem be?
pydev not recognizing python installation with django
4,563,129
1
15
11,629
0
python,django,eclipse,pydev
Use auto config in the preferences option and then click apply and then ok.
0
0
0
0
2010-10-15T06:11:00.000
10
0.019997
false
3,939,877
1
0
1
10
I have python installed with django. I know the installation is there because I installed it following the directions and in the command line I can do "import python" and there is no crash. When I try creating a django project in pydev, I get an error: "Django not found." What could the problem be?
pydev not recognizing python installation with django
4,961,144
1
15
11,629
0
python,django,eclipse,pydev
If everything is done as said above, and still showing "Django not found" while your are trying to create django project, let try to double click 'django-admin' python file that in scripts folder of python. And try to create django project
0
0
0
0
2010-10-15T06:11:00.000
10
0.019997
false
3,939,877
1
0
1
10
I have python installed with django. I know the installation is there because I installed it following the directions and in the command line I can do "import python" and there is no crash. When I try creating a django project in pydev, I get an error: "Django not found." What could the problem be?
pydev not recognizing python installation with django
5,612,184
2
15
11,629
0
python,django,eclipse,pydev
I was having this same exact problem today, and I just wanted to add some notes to help people out. You can follow the instructions of antonkeren above, but there's one thing to note that was not mentioned. After adding the django directory to the path you must QUIT ECLIPSE OR APTANA STUDIO. After you restart it and try to create a django project it will work.
0
0
0
0
2010-10-15T06:11:00.000
10
0.039979
false
3,939,877
1
0
1
10
I have python installed with django. I know the installation is there because I installed it following the directions and in the command line I can do "import python" and there is no crash. When I try creating a django project in pydev, I get an error: "Django not found." What could the problem be?
pydev not recognizing python installation with django
4,438,527
1
15
11,629
0
python,django,eclipse,pydev
I had the same problem and had solved it by adding the python home directory to the PATH variable and reconfigure the python interpreter on pydev.
0
0
0
0
2010-10-15T06:11:00.000
10
0.019997
false
3,939,877
1
0
1
10
I have python installed with django. I know the installation is there because I installed it following the directions and in the command line I can do "import python" and there is no crash. When I try creating a django project in pydev, I get an error: "Django not found." What could the problem be?
Is it technically possible to take a screenshot of a website programmatically?
3,940,121
0
6
2,523
0
python,google-app-engine,screenshot
It's certainly technically possible. You would probably have to render the HTML directly onto an image file (or more likely, onto an in-memory bitmap that's written to an image file once completed). I don't know any libraries to do this for you (apart from a modified WebKit, perhaps)... but there's certainly websites that do this. Of course, this is a bit more involved than just opening the page in a browser on a machine and taking a screenshot programatically, but the result would likely be better if you don't care about the result from a specific browser.
0
0
1
0
2010-10-15T06:53:00.000
5
0
false
3,940,098
0
0
1
1
Do you think is technically possible to take a screeshot of a website programmatically? I would like to craft a scheduled Python task that crawls a list of websites taking an homepage screenshot of them. Do you think is technically feasible or do you know third party website that offer a service like that (Input: url --> Output: screenshot) ? Any suggestion?
Server Upgrade Script
3,943,924
0
0
88
0
python,django,sysadmin
I think you're pretty much covering everything. Identify what's important to you and you're business practices: that's what counts.
0
0
0
0
2010-10-15T15:16:00.000
2
0
false
3,943,598
0
0
1
1
Does anyone have or know of a good template / plan for doing automated server upgrades? In this case I am upgrading a python/django server, but am going to have to apply this update to many machines, and want to be sure that the operation is fully testable and recoverable should anything go wrong. Am picturing something along the lines of: remotely fetch new code verify code download (e.g. hash of files) take down server, display "you are upgrading dialog" backup database(s) backup code directory apply new code updates verify code update (e.g. hash of files) apply database update (if necessary) run tests if success startup server verify server update else restore old database restore old code report error startup server verify server restore I'm sure that this isn't exhaustive, and there are many other error conditions to consider, but am wondering if something like this already exists as a formalized process/best practices checklist to follow? Ideally this whole thing should of course be done by a single script call.
Python unittests almost never check types
3,944,260
5
3
187
0
java,python,unit-testing
Python unit tests do check types. All the time. In fact, that's the only thing they are doing. Python is duck-typed. Duck typing means that the type of an object is defined by its behavior. Unit tests test behavior. Ergo, they test types.
0
0
0
1
2010-10-15T15:43:00.000
3
0.321513
false
3,943,808
0
0
1
1
I was going through a few tests written in Java using JUnit and I could'nt help noticing the emphasis which is laid on checking the "type" of objects. This is something I have never seen in Python test-suites. Java being statically-typed and Python being dynamically-typed, should'nt the reverse be the case?
Find a specific tag with BeautifulSoup
45,193,575
9
29
62,029
0
python,beautifulsoup
with bs4 things have changed a little. so the code should look like this soup = BeautifulSoup(htmlstring,'lxml') soup.find_all('div', {'style':"width=300px;"})
0
0
1
0
2010-10-15T20:11:00.000
2
1
false
3,945,750
0
0
1
1
I can traverse generic tags easily with BS, but I don't know how to find specific tags. For example, how can I find all occurances of <div style="width=300px;">? Is this possible with BS?
Google App Engine development server is slow to start up when using WingIDE
3,957,947
2
1
713
0
python,google-app-engine,performance,wing-ide
Probably because you've got a debugger hooked up - debuggers slow code down a lot by instrumenting everything, and deserializing your datastore is a lot of work. Using the --use_sqlite flag will enable an experimental sqlite-based local datastore, which should require less startup time. Note that it'll require you to wipe your datastore when you switch to it, however.
0
1
0
0
2010-10-16T02:36:00.000
2
1.2
true
3,947,443
0
0
1
1
I'm developing on Google App Engine. I am using WingIDE (a python IDE) to debug on the development server. I have several thousand entities in my datastore and I can see that when the development server starts up, it has to go through DatastoreFileStub.Read() and do something which each entity. The problem is, when I run the development server through WingIDE it runs horrendously slow. I put some profiling logging code into the google app engine to take a peak. When I run the development server on the command line, I get the following message: Finished reading 10374 Entites in 10.17 seconds, 1019 per second When I run the development server through WingIDE however, I get this: Finished reading 10374 Entites in 52.44 seconds, 197 per second Anyone have an idea why WingIDE would be 5 times slower?
How to turn an encoded link such as "http%3A%2F%2Fexample.com%2Fwhatever" into "http://example.com/whatever" in python?
5,693,726
0
0
797
0
python,html
urllib.unquote() on its own may still cause problems by throwing the exception: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position n: ordinal not in range(128) In that case try: print urllib.unquote("Ober%C3%B6sterreich.txt").decode("utf8")
0
0
1
0
2010-10-16T16:33:00.000
2
0
false
3,949,739
0
0
1
1
I always found links in html source stored in such format, the question is how do I change such links back to what it's normally like? Thanks a lot!
Preparing a web site for international usage
3,970,432
0
1
98
0
python,django,internationalization,project-planning
One big change in your project: you need to build in time to localize your strings. Depending on your schedules, you may have to rearrange work so that all the string-changing work is at the front so that you have time to get the translations done before launching. Or, alternately, you have to build in a buffer at the end to account for it.
0
0
0
1
2010-10-16T21:21:00.000
2
0
false
3,950,851
0
0
1
1
I am preparing to develop a web application that will (hopefully) be used by an audience with many different native languages. What should I do to prepare my software project to have the user interface be almost entirely internationalized? Are there any software stacks that make this easier?
How to change email account details in appcfg.py google appengine SDK
4,927,348
0
9
6,689
0
python,google-app-engine
Answer of Adam Bernier also can apply when you use the appcfg.py download_app for downloading app from appengine servers.
0
1
0
0
2010-10-16T22:29:00.000
5
0
false
3,951,089
0
0
1
1
I have hosted GAE apps with two different email ids! When i first time used appcfg.py to update my app then it prompted me for email id and password but later it doesnot. How to i change the saved email id and password? I tried to use --email= flag with appcfg.py, but it dint worked.
When would we need a javascript client template engine?
3,954,282
0
2
308
0
javascript,python,client-side,template-engine
I'll address your first question. You can store data in JavaScript objects (instead of SQL databases, for example). Those JavaScript objects can be stored in .js files, or inline as part of the HTML document. You can take a look at the source code of my w3viewer.com. All data is stored inside a JavaScript array. In the example of my web-site, I dynamically create HTML lists with data taken from that JavaScript object (I generate the HTML code string). One could use templating to get this job done.
0
0
0
0
2010-10-17T16:24:00.000
3
0
false
3,954,099
0
0
1
3
Recently, I found out that jQuery has an official template engine which was contributed by the Microsoft team. Also I had heard about jTemplate from my friends, but I'm still confused: When & where might I need to use these plugins? How should I choose between the many client side template engines?
When would we need a javascript client template engine?
3,954,332
0
2
308
0
javascript,python,client-side,template-engine
A template-engine prevents unnecessary HTML-code in the actual code. This makes it much easier to read.
0
0
0
0
2010-10-17T16:24:00.000
3
0
false
3,954,099
0
0
1
3
Recently, I found out that jQuery has an official template engine which was contributed by the Microsoft team. Also I had heard about jTemplate from my friends, but I'm still confused: When & where might I need to use these plugins? How should I choose between the many client side template engines?
When would we need a javascript client template engine?
3,954,142
1
2
308
0
javascript,python,client-side,template-engine
The reason for a jQuery template engine is this: developers write Javascript code to create new chunks of HTML to inject into the page. This usually is done by concatenating many strings with variables for values, and it becomes difficult to maintain. With a jQuery template engine, the process of creating HTML at the client can benefit from all the same advantages that server-side developers now have with their templating engines.
0
0
0
0
2010-10-17T16:24:00.000
3
1.2
true
3,954,099
0
0
1
3
Recently, I found out that jQuery has an official template engine which was contributed by the Microsoft team. Also I had heard about jTemplate from my friends, but I'm still confused: When & where might I need to use these plugins? How should I choose between the many client side template engines?
Reading files in GAE using python
3,957,752
2
2
613
0
python,django,google-app-engine
os.path.normpath() on "content_includes" is a no-op - normpath just removes double slashes and other denormalizations. What you probably want is to build a path relative to the script, in which case you should do something like os.path.join(os.path.dirname(__file__), 'content_includes', pageName + '.inc').
0
1
0
0
2010-10-17T21:22:00.000
2
1.2
true
3,955,361
0
0
1
2
I created a simple python project that serves up a couple of pages. I'm using the 'webapp' framework and django. What I'm trying to do is use one template file, and load 'content files' that contain the actual page text. When I try to read the content files using os.open, I get the following error: pageContent = os.open(pageUrl, 'r').read() OSError: [Errno 1] Operation not permitted: 'content_includes/home.inc' error If I let the django templating system to read the same file for me, everything works fine! So the question is What am I doing wrong that django isn't??? The same 'pageUrl' is used. The code below will give me the error, while if I comment out the first pageContent assignment, everything works fine. Code: pageName = "home"; pageUrl = os.path.join(os.path.normpath('content_includes'), pageName + '.inc') pageContent = os.open(pageUrl, 'r').read() pageContent=template.render(pageUrl, template_values, debug=True); template_values = { 'page': pageContent, 'test': "testing my app" } Error: Traceback (most recent call last): File "/opt/apis/google_appengine/google/appengine/ext/webapp/__init__.py", line 511, in __call__ handler.get(*groups) File "/home/odessit/Development/Python/Alpha/main.py", line 19, in get pageContent = os.open(pageUrl, 'r').read() File "/opt/apis/google_appengine/google/appengine/tools/dev_appserver.py", line 805, in FakeOpen raise OSError(errno.EPERM, "Operation not permitted", filename) OSError: [Errno 1] Operation not permitted: 'content_includes/home.inc' app.yaml: handlers: - url: /javascript static_dir: javascript - url: /images static_dir: images - url: /portfolio static_dir: portfolio - url: /.* script: main.py
Reading files in GAE using python
3,994,580
0
2
613
0
python,django,google-app-engine
If you dig in the dev_appserver.py source code and related files you see that the server does some incarnate checking to ensure that you open only files from below your applications root (in fact the rules seem even more complex). For file access troubled I instrumented that "path permission checking" code from the development server to find that I was using absolute paths. We propbably should do a patch to appengine to provide better error reporting on that: IIRC the Appserver does not display the offending path but a mangled version of this which makes debugging difficult.
0
1
0
0
2010-10-17T21:22:00.000
2
0
false
3,955,361
0
0
1
2
I created a simple python project that serves up a couple of pages. I'm using the 'webapp' framework and django. What I'm trying to do is use one template file, and load 'content files' that contain the actual page text. When I try to read the content files using os.open, I get the following error: pageContent = os.open(pageUrl, 'r').read() OSError: [Errno 1] Operation not permitted: 'content_includes/home.inc' error If I let the django templating system to read the same file for me, everything works fine! So the question is What am I doing wrong that django isn't??? The same 'pageUrl' is used. The code below will give me the error, while if I comment out the first pageContent assignment, everything works fine. Code: pageName = "home"; pageUrl = os.path.join(os.path.normpath('content_includes'), pageName + '.inc') pageContent = os.open(pageUrl, 'r').read() pageContent=template.render(pageUrl, template_values, debug=True); template_values = { 'page': pageContent, 'test': "testing my app" } Error: Traceback (most recent call last): File "/opt/apis/google_appengine/google/appengine/ext/webapp/__init__.py", line 511, in __call__ handler.get(*groups) File "/home/odessit/Development/Python/Alpha/main.py", line 19, in get pageContent = os.open(pageUrl, 'r').read() File "/opt/apis/google_appengine/google/appengine/tools/dev_appserver.py", line 805, in FakeOpen raise OSError(errno.EPERM, "Operation not permitted", filename) OSError: [Errno 1] Operation not permitted: 'content_includes/home.inc' app.yaml: handlers: - url: /javascript static_dir: javascript - url: /images static_dir: images - url: /portfolio static_dir: portfolio - url: /.* script: main.py
What does a audio frame contain?
9,184,327
6
23
39,854
0
python,wav
The first thing you should do is a fourier transformation to transform the data into its frequencies. It is rather complex however. I wouldn't use voice recognition libraries here as it sounds like you don't record voices only. You would then try different time shifts (in case the sounds are not exactly aligned) and use the one that gives you the best similarity - where you have to define a similarity function. Oh and you should normalize both signals (same maximum loudness).
0
0
0
1
2010-10-18T06:38:00.000
4
1
false
3,957,025
1
0
1
4
I'm doing some research on how to compare sound files(wave). Basically, I want to compare stored soundfiles (wav) with sound from a microphone. So in the end I would like to pre-store some voice commands of my own and then when I'm running my app I would like to compare the pre-stored files with input from the microphone. My thought was to put in some margin when comparing because saying something two times in a row in the exactly same way would be difficult I guess. So after some googling I see that Python has this module named wave and the Wave_read object. That object has a function named readframes(n): Reads and returns at most n frames of audio, as a string of bytes. What do these bytes contain? I'm thinking of looping thru the wave files one frame at the time comparing them frame by frame.
What does a audio frame contain?
20,810,191
7
23
39,854
0
python,wav
I believe the accepted description to be slightly incorrect. A frame appears to be somewhat like stride in graphics formats. For interleaved stereo @ 16 bits/sample, the frame size is 2*sizeof(short)=4 bytes. For non-interleaved stereo @ 16 bits/sample, the samples of the left channel are all one after another, so the frame size is just sizeof(short).
0
0
0
1
2010-10-18T06:38:00.000
4
1
false
3,957,025
1
0
1
4
I'm doing some research on how to compare sound files(wave). Basically, I want to compare stored soundfiles (wav) with sound from a microphone. So in the end I would like to pre-store some voice commands of my own and then when I'm running my app I would like to compare the pre-stored files with input from the microphone. My thought was to put in some margin when comparing because saying something two times in a row in the exactly same way would be difficult I guess. So after some googling I see that Python has this module named wave and the Wave_read object. That object has a function named readframes(n): Reads and returns at most n frames of audio, as a string of bytes. What do these bytes contain? I'm thinking of looping thru the wave files one frame at the time comparing them frame by frame.
What does a audio frame contain?
3,957,097
8
23
39,854
0
python,wav
A simple byte-by-byte comparison has almost no chance of a successful match, even with some tolerance thrown in. Voice-pattern recognition is a very complex and subtle problem that is still the subject of much research.
0
0
0
1
2010-10-18T06:38:00.000
4
1
false
3,957,025
1
0
1
4
I'm doing some research on how to compare sound files(wave). Basically, I want to compare stored soundfiles (wav) with sound from a microphone. So in the end I would like to pre-store some voice commands of my own and then when I'm running my app I would like to compare the pre-stored files with input from the microphone. My thought was to put in some margin when comparing because saying something two times in a row in the exactly same way would be difficult I guess. So after some googling I see that Python has this module named wave and the Wave_read object. That object has a function named readframes(n): Reads and returns at most n frames of audio, as a string of bytes. What do these bytes contain? I'm thinking of looping thru the wave files one frame at the time comparing them frame by frame.
What does a audio frame contain?
3,957,230
47
23
39,854
0
python,wav
An audio frame, or sample, contains amplitude (loudness) information at that particular point in time. To produce sound, tens of thousands of frames are played in sequence to produce frequencies. In the case of CD quality audio or uncompressed wave audio, there are around 44,100 frames/samples per second. Each of those frames contains 16-bits of resolution, allowing for fairly precise representations of the sound levels. Also, because CD audio is stereo, there is actually twice as much information, 16-bits for the left channel, 16-bits for the right. When you use the sound module in python to get a frame, it will be returned as a series of hexadecimal characters: One character for an 8-bit mono signal. Two characters for 8-bit stereo. Two characters for 16-bit mono. Four characters for 16-bit stereo. In order to convert and compare these values you'll have to first use the python wave module's functions to check the bit depth and number of channels. Otherwise, you'll be comparing mismatched quality settings.
0
0
0
1
2010-10-18T06:38:00.000
4
1.2
true
3,957,025
1
0
1
4
I'm doing some research on how to compare sound files(wave). Basically, I want to compare stored soundfiles (wav) with sound from a microphone. So in the end I would like to pre-store some voice commands of my own and then when I'm running my app I would like to compare the pre-stored files with input from the microphone. My thought was to put in some margin when comparing because saying something two times in a row in the exactly same way would be difficult I guess. So after some googling I see that Python has this module named wave and the Wave_read object. That object has a function named readframes(n): Reads and returns at most n frames of audio, as a string of bytes. What do these bytes contain? I'm thinking of looping thru the wave files one frame at the time comparing them frame by frame.
Uploading images from a django application to a Google AppEngine application
3,959,150
1
1
269
0
python,google-app-engine
Afaik you can not store files in App Engine programmatically. You can just store them, when uploading your app. You can however store information in its data store. So you would need to deploy an app, that authenticates your user and then writs the image to the gae's data store
0
1
0
0
2010-10-18T10:24:00.000
2
0.099668
false
3,958,224
0
0
1
1
I am not running Django on AppEngine. I just want to use AppEngine as a content delivery network, basically a place I can host and serve images for free. It's for a personal side project. The situation is this: I have the URL of an image hosted on another server/provider. Instead of hotlinking to that image its better to save it on AppEngine and serve it from there - this applies mostly for thumbnails. My questions are these: How do I authenticate from my Django app (let's say A) to my AppEngine app (B), so that only I can upload images How do I make a request from A to B saying "Fetch the image on this URL, create a thumbnail and save it." How do I tell B that "For this url return that image" How can I handle errors or timeouts? And how can this be done asynchronously?
Handle GPS Coordinate in Django
3,962,335
0
1
1,957
0
python,django,gps
Save them as double/float with adequate precision in the input data
0
0
0
0
2010-10-18T18:46:00.000
2
1.2
true
3,962,304
0
0
1
1
What is the best way to manage GPS coordinates (latitude and longitude) in django models ? I know that there is a module called GeoDjango but reading the tutorial seems dedicated to GIS and not simply to manage the latitude and longitude. I do not care to have convenient interface for the admin because int the application I'm creatin the admin is virtually absent. But instead the application will often comunicate with mobile device such as iPhone that,for example, treat coordinates as double (double typedef CLLocationDegrees). I would simply like an easy way to manage these data in the model?
Can I gzip JavaScript and CSS files in Django?
3,968,783
4
4
4,916
0
python,django,compression,gzip,static-files
You should think about placing your django application behind an HTTP reverse proxy. You can configure apache to act as a reverse proxy to your django application, although a number of people seem to prefer using nginx or lighttpd for this scenario. An HTTP reverse proxy basically is a proxy set up directly in front of your web application. Browsers make requests from the reverse proxy, and the reverse proxy forwards the requests to the web application. The reverse proxy can also do a number of interesting things like handle ssl, handle gzip-compressing all responses, and handle serving static files.
0
0
0
0
2010-10-19T13:09:00.000
4
0.197375
false
3,968,650
0
0
1
2
I tried profiling my web application and one of the bottlenecks reported was the lack of gzip compression. I proceeded to install the gzip middleware in Django and got a bit of a boost but a new report shows that it is only gzipping the HTML files i.e. any content processed by Django. Is there a way I could kludge/hack/force/make the middleware gzip my CSS and my JS as well? Could someone please answer my questions below. I've gotten a little lost with this. I might have gotten it wrong but people do gzip the CSS and the JS, don't they? Does Django not compress JS and CSS for some browser compatibility issues? Is compressing and minifying the same thing? Thanks.
Can I gzip JavaScript and CSS files in Django?
3,975,710
2
4
4,916
0
python,django,compression,gzip,static-files
Thanks everyone. It seems that the GzipMiddleware in Django DOES compress CSS and JS. I was using Google's Page Speed plugin for Firebug to profile my page and it seems that it was generating reports based on old copies (non-gzipped versions) of the CSSs and JSs in my local cache. These copies were there from the time before I enabled the Gzip middleware. I flushed the cache and it seems that the reports showed different results altogether.
0
0
0
0
2010-10-19T13:09:00.000
4
1.2
true
3,968,650
0
0
1
2
I tried profiling my web application and one of the bottlenecks reported was the lack of gzip compression. I proceeded to install the gzip middleware in Django and got a bit of a boost but a new report shows that it is only gzipping the HTML files i.e. any content processed by Django. Is there a way I could kludge/hack/force/make the middleware gzip my CSS and my JS as well? Could someone please answer my questions below. I've gotten a little lost with this. I might have gotten it wrong but people do gzip the CSS and the JS, don't they? Does Django not compress JS and CSS for some browser compatibility issues? Is compressing and minifying the same thing? Thanks.
SHA-256 password generator
3,974,224
0
1
1,380
0
javascript,python,sha256
SHA-256 generates very long strings. You're better off using random.choice() with a string a fixed number of times.
0
0
0
1
2010-10-20T02:01:00.000
2
0
false
3,974,211
0
0
1
1
i saw a javascript implementation of sha-256. i waana ask if it is safe (pros/cons wathever) to use sha-256 (using javascript implementation or maybe python standard modules) alogrithm as a password generator: i remember one password, put it in followed(etc) by the website address and use the generated text as the password for that website. repeat process every time i need password same for other websites
How to handle multiple forms in google app engine?
3,976,759
7
2
1,373
0
python,google-app-engine,web-applications
The framework you use is irrelevant to how you handle forms. You have a couple of options: you can distinguish the forms by changing the URL they submit to - in which case, you can use the same handler or a different handler for each form - or you can distinguish them based on the contents of the form. The easiest way to do the latter is to give your submit buttons distinct names or values, and check for them in the POST data.
0
1
0
0
2010-10-20T09:23:00.000
2
1.2
true
3,976,368
0
0
1
1
Say if I have multiple forms with multiple submit button in a single page, can I somehow make all of these buttons work using webapp as backend handler? If not, what are the alternatives?
App Engine Version, Memcache
3,976,845
12
6
371
0
python,google-app-engine
The os.environ variable contains a key called CURRENT_VERSION_ID that you can use. It's value is composed of the version from app.yaml concatenated together with a period and what I suspect is the api_version. If I set version to 42 it gives me the value of 42.1. You should have no problems extracting the version number alone, but it might not be such a bad idea to keep the api_version aswell. EDIT: @Nick Johnson has pointed out that the number to the right of the period is the minor version, a number which is incremented each time you deploy your code. On the development server this number is always 1.
0
1
0
0
2010-10-20T10:17:00.000
1
1.2
true
3,976,772
0
0
1
1
I am developing an App Engine App that uses memcache. Since there is only a single memcache shared among all versions of your app I am potentially sending bad data from a new version to the production version memcache. To prevent this, I think I may append the app version to the memcache key string to allow various versions of the app to keep their data separate. I could do this manually, but I'd like to pull in the version from the app.yaml How can I access the app version from within the python code?
Encryption: simulate SSL in javascript and python
3,978,603
1
5
2,770
0
javascript,python,ssl
You can't stop the men in the middle from trapping your packets/messages, especially if they don't really care if you find out. What you can do is encrypt your messages so that trapping them does not enable them to read what you're sending and receiving. In theory that's fine, but in practice you can't do modern crypto by hand even with the keys: you need to transfer some software too, and that's where it gets much more awkward. You want to have the client's side of the crypto software locally, or at least enough to be able to check whether a digital signature of the crypto software is correct. Digital signatures are very difficult to forge. Deliver signed code, check its signature, and if the signature validates against a public key that you trust (alas, you'll have to transfer that out of band) then you know that the code (plus any CA certificates – trust roots – sent along with it) can be trusted to work as desired. The packets can then go over plain HTTP; they'll either get to where they're meant to or be intercepted, but either way nobody but the intended recipient will be able to read them. The only advantage of SSL is that it builds virtually all of this stuff for you and makes it easy. I have no idea how practical it is to do this all in Javascript. Obviously it can do it – it's a Turing-complete language, it has access to all the requisite syscalls – but it could be stupidly expensive. It might be easier to think in terms of using GPG… (Hiding the fact from the government that you are communicating at all is a different problem entirely.)
0
0
1
0
2010-10-20T11:29:00.000
4
0.049958
false
3,977,274
0
0
1
3
Because of china Great Firewall has blocked google appengine's https port. So I want to simulate a Secure Socket Layer by javascript and python to protect my users information will not be capture by those ISP and GFW. My plan: Shake hands: Browser request server, server generate a encrypt key k1, and decrypt key k2, send k1 to browser. Browser generate a encrypt key k3, and decrypt key k4, send k3 to server. Browse: During the session, browser encrypt data with k1 and send to server, server decrypt with k2. server encrypt data with k3 and response to browser, browser decrypt with k4. Please figure out my mistake. If it's right, my question is how to generate a key pair in javascript and python, are there some libraries? how to encrypt and decrypt data in javascript and python , are there some libraries?
Encryption: simulate SSL in javascript and python
3,977,301
0
5
2,770
0
javascript,python,ssl
There's a big problem, if security really is a big concern: Your algorithm is going to be transfered unsecured. Can you trust the client at all? Can the client trust the server at all?
0
0
1
0
2010-10-20T11:29:00.000
4
0
false
3,977,274
0
0
1
3
Because of china Great Firewall has blocked google appengine's https port. So I want to simulate a Secure Socket Layer by javascript and python to protect my users information will not be capture by those ISP and GFW. My plan: Shake hands: Browser request server, server generate a encrypt key k1, and decrypt key k2, send k1 to browser. Browser generate a encrypt key k3, and decrypt key k4, send k3 to server. Browse: During the session, browser encrypt data with k1 and send to server, server decrypt with k2. server encrypt data with k3 and response to browser, browser decrypt with k4. Please figure out my mistake. If it's right, my question is how to generate a key pair in javascript and python, are there some libraries? how to encrypt and decrypt data in javascript and python , are there some libraries?
Encryption: simulate SSL in javascript and python
3,977,325
2
5
2,770
0
javascript,python,ssl
You have a fundamental problem in that a JavaScript implementation of SSL would have no built-in root certificates to establish trust, which makes it impossible to prevent a man-in-the-middle attack. Any certificates you deliver from your site, including a root certificate, could be intercepted and replaced by a spy. Note that this is a fundamental limitation, not a peculiarity of the way SSL works. All cryptographic security relies on establishing a shared secret. The root certificates deployed with mainstream browsers provide the entry points to a trust network established by certifying authorities (CAs) that enable you to establish the shared secret with a known third party. These certificates are not, AFAIK, directly accessible to JavaScript code. They are only used to establish secure (e.g., https) connections.
0
0
1
0
2010-10-20T11:29:00.000
4
0.099668
false
3,977,274
0
0
1
3
Because of china Great Firewall has blocked google appengine's https port. So I want to simulate a Secure Socket Layer by javascript and python to protect my users information will not be capture by those ISP and GFW. My plan: Shake hands: Browser request server, server generate a encrypt key k1, and decrypt key k2, send k1 to browser. Browser generate a encrypt key k3, and decrypt key k4, send k3 to server. Browse: During the session, browser encrypt data with k1 and send to server, server decrypt with k2. server encrypt data with k3 and response to browser, browser decrypt with k4. Please figure out my mistake. If it's right, my question is how to generate a key pair in javascript and python, are there some libraries? how to encrypt and decrypt data in javascript and python , are there some libraries?
A good way to encrypt database fields?
3,979,447
2
17
13,590
1
python,sql,sql-server,django,encryption
If you are storing things like passwords, you can do this: store users' passwords as their SHA256 hashes get the user's password hash it List item check it against the stored password You can create a SHA-256 hash in Python by using the hashlib module. Hope this helps
0
0
0
0
2010-10-20T15:12:00.000
4
0.099668
false
3,979,385
0
0
1
2
I've been asked to encrypt various db fields within the db. Problem is that these fields need be decrypted after being read. I'm using Django and SQL Server 2005. Any good ideas?
A good way to encrypt database fields?
3,979,446
6
17
13,590
1
python,sql,sql-server,django,encryption
Yeah. Tell whoever told you to get real. Makes no / little sense. If it is about the stored values - enterprise edition 2008 can store encrypted DB files. Otherwise, if you really need to (with all disadvantages) just encrypt them and store them as byte fields.
0
0
0
0
2010-10-20T15:12:00.000
4
1.2
true
3,979,385
0
0
1
2
I've been asked to encrypt various db fields within the db. Problem is that these fields need be decrypted after being read. I'm using Django and SQL Server 2005. Any good ideas?
Show pdf only to authenticated users
4,025,388
0
1
216
0
python,html,pdf,permissions,pylons
Maybe filename with md5 key will be enough? 48cd84ab06b0a18f3b6e024703cfd246-myfilename.pdf You can use filename and datetime.now to generate md5 key.
0
0
0
0
2010-10-20T18:01:00.000
4
0
false
3,980,878
0
0
1
3
I'm building a web site from the old one and i need to show a lot of .pdf files. I need users to get authenficated before the can't see any of my .pdf but i don't know how (and i can't put my pdf in my database). I'm using Pylons with Python. Thank for you help. If you have any question, ask me! :)
Show pdf only to authenticated users
3,980,973
2
1
216
0
python,html,pdf,permissions,pylons
Paul's suggestion of X-Sendfile is excellent - this is truly a great way to deal with actually getting the document back to the user. (+1 for Paul :) As for the front end, do something like this: Store your pdfs somewhere not accessible by the web (say /secure) Offer a URL that looks like /unsecure/filename.pdf Have your HTTP server (if it's Apache, see Mod Rewrite) convert that link into /normal/php/path/authenticator.php?file=filename.pdf authenticator.php confirms that the file exists, that the user is legit (i.e. via a cookie), and then uses X-Sendfile to return the PDF.
0
0
0
0
2010-10-20T18:01:00.000
4
0.099668
false
3,980,878
0
0
1
3
I'm building a web site from the old one and i need to show a lot of .pdf files. I need users to get authenficated before the can't see any of my .pdf but i don't know how (and i can't put my pdf in my database). I'm using Pylons with Python. Thank for you help. If you have any question, ask me! :)
Show pdf only to authenticated users
3,980,896
2
1
216
0
python,html,pdf,permissions,pylons
You want to use the X-Sendfile header to send those files. Precise details will depend on which Http server you're using.
0
0
0
0
2010-10-20T18:01:00.000
4
0.099668
false
3,980,878
0
0
1
3
I'm building a web site from the old one and i need to show a lot of .pdf files. I need users to get authenficated before the can't see any of my .pdf but i don't know how (and i can't put my pdf in my database). I'm using Pylons with Python. Thank for you help. If you have any question, ask me! :)
Serving static files with apache and mod_wsgi without changing apache's configuration?
3,981,300
1
1
2,445
0
python,django,apache,.htaccess,mod-wsgi
Serve the static files from a different virtual host.
0
0
0
0
2010-10-20T18:52:00.000
2
0.099668
false
3,981,267
0
0
1
1
I have a Django application, and I'm using a shared server hosting, so I cannot change apache's config files. The only thing that I can change is the .htaccess file in my application. I also have a standard django.wsgi python file, as an entry point. In dev environment, I'm using Django to serve the static files, but it is discouraged in the official documentation, saying that you should do it using the web server instead. Is there a way to serve static files through apache without having access to Apache's configuration, changing only the .htaccess or django.wsgi files??
Check facebook object type
3,983,424
0
1
177
0
python,facebook
You could hit up the graph api with the id and see what you get back. https://graph.facebook.com/{OBJECTID}
0
0
0
0
2010-10-20T23:38:00.000
1
0
false
3,983,168
0
0
1
1
In my app, I have a form where user should submit a facebook page URL. How to check that it's correct? Presently, I'm just checking that it begins with 'http://www.facebook.com' How can I check that it is a page (where you can become a fan) and not a profile, event or whatever? I'm using the python api and appengine. Thanks!
How to implement "autoincrement" on Google AppEngine
3,986,265
25
31
11,536
0
python,database,google-app-engine
If you absolutely have to have sequentially increasing numbers with no gaps, you'll need to use a single entity, which you update in a transaction to 'consume' each new number. You'll be limited, in practice, to about 1-5 numbers generated per second - which sounds like it'll be fine for your requirements.
0
1
0
0
2010-10-21T09:02:00.000
9
1.2
true
3,985,812
0
0
1
4
I have to label something in a "strong monotone increasing" fashion. Be it Invoice Numbers, shipping label numbers or the like. A number MUST NOT BE used twice Every number SHOULD BE used when exactly all smaller numbers have been used (no holes). Fancy way of saying: I need to count 1,2,3,4 ... The number Space I have available are typically 100.000 numbers and I need perhaps 1000 a day. I know this is a hard Problem in distributed systems and often we are much better of with GUIDs. But in this case for legal reasons I need "traditional numbering". Can this be implemented on Google AppEngine (preferably in Python)?
How to implement "autoincrement" on Google AppEngine
29,419,735
0
31
11,536
0
python,database,google-app-engine
I'm thinking in using the following solution: use CloudSQL (MySQL) to insert the records and assign the sequential ID (maybe with a Task Queue), later (using a Cron Task) move the records from CloudSQL back to the Datastore. The entities also can have a UUID, so we can map the entities from the Datastore in CloudSQL, and also have the sequential ID (for legal reasons).
0
1
0
0
2010-10-21T09:02:00.000
9
0
false
3,985,812
0
0
1
4
I have to label something in a "strong monotone increasing" fashion. Be it Invoice Numbers, shipping label numbers or the like. A number MUST NOT BE used twice Every number SHOULD BE used when exactly all smaller numbers have been used (no holes). Fancy way of saying: I need to count 1,2,3,4 ... The number Space I have available are typically 100.000 numbers and I need perhaps 1000 a day. I know this is a hard Problem in distributed systems and often we are much better of with GUIDs. But in this case for legal reasons I need "traditional numbering". Can this be implemented on Google AppEngine (preferably in Python)?
How to implement "autoincrement" on Google AppEngine
15,731,054
0
31
11,536
0
python,database,google-app-engine
Remember: Sharding increases the probability that you will get a unique, auto-increment value, but does not guarantee it. Please take Nick's advice if you MUST have a unique auto-incrment.
0
1
0
0
2010-10-21T09:02:00.000
9
0
false
3,985,812
0
0
1
4
I have to label something in a "strong monotone increasing" fashion. Be it Invoice Numbers, shipping label numbers or the like. A number MUST NOT BE used twice Every number SHOULD BE used when exactly all smaller numbers have been used (no holes). Fancy way of saying: I need to count 1,2,3,4 ... The number Space I have available are typically 100.000 numbers and I need perhaps 1000 a day. I know this is a hard Problem in distributed systems and often we are much better of with GUIDs. But in this case for legal reasons I need "traditional numbering". Can this be implemented on Google AppEngine (preferably in Python)?
How to implement "autoincrement" on Google AppEngine
4,056,817
7
31
11,536
0
python,database,google-app-engine
If you drop the requirement that IDs must be strictly sequential, you can use a hierarchical allocation scheme. The basic idea/limitation is that transactions must not affect multiple storage groups. For example, assuming you have the notion of "users", you can allocate a storage group for each user (creating some global object per user). Each user has a list of reserved IDs. When allocating an ID for a user, pick a reserved one (in a transaction). If no IDs are left, make a new transaction allocating 100 IDs (say) from the global pool, then make a new transaction to add them to the user and simultaneously withdraw one. Assuming each user interacts with the application only sequentially, there will be no concurrency on the user objects.
0
1
0
0
2010-10-21T09:02:00.000
9
1
false
3,985,812
0
0
1
4
I have to label something in a "strong monotone increasing" fashion. Be it Invoice Numbers, shipping label numbers or the like. A number MUST NOT BE used twice Every number SHOULD BE used when exactly all smaller numbers have been used (no holes). Fancy way of saying: I need to count 1,2,3,4 ... The number Space I have available are typically 100.000 numbers and I need perhaps 1000 a day. I know this is a hard Problem in distributed systems and often we are much better of with GUIDs. But in this case for legal reasons I need "traditional numbering". Can this be implemented on Google AppEngine (preferably in Python)?
Python GeoModel alternative
3,993,903
2
6
1,355
0
python,google-app-engine,google-cloud-datastore,gis,geohashing
I can't point you to an existing library that has better performance, but as I recall, GeoModel is open source and the code isn't difficult to understand. We found that we could make some speed improvements by adjusting the code to fit our scenario. For example, if you don't need nearest-n, you just need X results from within a particular bounding box or radius, you can probably improve GeoModel's speed, as GeoModel has to currently get every record in the appropriate geohash and then sorts for closest in memory. (Details of that implementation left as an exercise for the reader.) You might also consider tuning how many levels of geohash you're using. If you have a lot of dense data and are querying over small areas, you might considerably increase performance by keeping 16 levels instead of 8 or 12. (I'm not looking at the GeoModel source right now but recalling when I last used it several months ago, so take this with a grain of salt and dive into the source code yourself.)
0
1
0
0
2010-10-22T04:22:00.000
3
0.132549
false
3,993,862
0
0
1
1
I'm looking for an alternative library for the app engine datastore that will do nearest-n or boxed geo-queries, currently i'm using GeoModel 0.2 and it runs quite slow ( > 1.5s in some cases). Does anyone have any suggestions? Thanks!
using django-jython
4,676,968
0
0
121
0
python,django,jython
I was able to get django 1.2 working just fine in jython 2.5. You will have to use the SVN build of django-jython. I would recommend that you use Java 6 I was able to get it running in Java 5 but I had to rebuild the ruby file system jar and remove the Java 6 database drivers from the packaged war. So you wont end up with war file that can be deployed on any environment unless you are using Java 6.
0
0
0
0
2010-10-22T08:28:00.000
1
0
false
3,995,088
0
0
1
1
I have read from the django-jython wiki that 1.1.1 is not compatible with django 1.2, and that jython does not works with the default django backend. Does this means I'm unable to use django 1.2 with jython at the moment?
HTML code processing
3,998,246
1
3
933
0
python,html-parsing
Depending on your needs, you could just use the regular expression /<(.|\n)*?>/ and replace all matches with empty strings. This works perfectly for manual cases, but if you're building this as an application feature then you'll need a more robust and secure option.
0
0
0
0
2010-10-22T15:07:00.000
5
0.039979
false
3,998,165
0
0
1
1
I want to process some HTML code and remove the tags as in the example: "<p><b>This</b> is a very interesting paragraph.</p>" results in "This is a very interesting paragraph." I'm using Python as technology; do you know any framework I may use to remove the HTML tags? Thanks!
Best way to keep an activity log in memcached
4,006,612
0
0
351
1
python,memcached,feed
If the list of keys is bounded in size then it should be ok. memcache by default has a 1MB item size limit. Sounds like memcache is the only storage for the data, is it a good idea?
0
0
0
0
2010-10-22T17:43:00.000
1
0
false
3,999,496
0
0
1
1
I'd like to build a "feed" for recent activity related to a specific section of my site. I haven't used memcache before, but I'm thinking of something like this: When a new piece of information is submitted to the site, assign a unique key to it and also add it to memcache. Add this key to the end of an existing list in memcache, so it can later be referenced. When retrieving, first retrieve the list of keys from memcache For each key retrieved, retrieve the individual piece of information String the pieces together and return them as the "feed" E.g., user comments: user writes, "Nice idea" Assign a unique key to "Nice idea," let's say key "1234" Insert a key/data pair into memcache, 1234 -> "Nice Idea" Append "1234" to an existing list of keys: key_list -> {2341,41234,124,341,1234} Now when retrieving, first query the key list: {2341,41234,124,341,1234} For each key in the key list, retrieve the data: 2341 -> "Yes" 41234 -> "Good point" 124 -> "That's funny" 341 -> "I don't agree" 1234 -> "Nice Idea" Is this a good approach? Thanks!
Logging into Facebook without a Browser
4,000,963
5
4
4,595
0
python,facebook
What you are trying to do is not possible. You are going to have to use a browser to get an access token one way or another. You cannot collect username and passwords (a big violation of Facebook's TOS). If you need a script that runs without user interaction you will still need to use a browser to authenticate, but once you have the user's token you can use it without their direct interaction. You must request the "offline_access" permission to gain an access token that does not expire. You can save this token and then use it for however long you need.
0
0
1
0
2010-10-22T20:55:00.000
3
1.2
true
4,000,896
0
0
1
1
I'm working on a script currently that needs to pull information down from a specific user's wall. The only problem is that it requires authentication, and the script needs to be able to run without any human interference. Unfortunately all I can find thus far tells me that I need to register an application, and then do the whole FB Connect dance to pull off what I want. Problem is that requires browser interaction, which I'm trying to avoid. I figured I could probably just use httplib2, and login this route. I got that to work, only to find that with that method I still don't get an "access_token" in any retrievable method. If I could get that token without launching a browser, I'd be completely set. Surely people are crawling feeds and such without using FB Connect right? Is it just not possible, thus why I'm hitting so many road blocks? Open to any suggestions you all might have.
Can I reliably figure out the correct mime type to serve untrusted content?
4,002,237
1
0
203
0
python,web-applications,mime,mime-types
Beware of text files: there's no way of knowing what encoding they're in, and there's no reliable way of guessing, especially since most ones created in Windows are in 8-bit MBCS encodings which are indistinguishable without language heuristics. You need to know the encoding--not just the MIME type--to set the complete Content-Type for a file to be viewable in a browser. If you want to allow uploading and displaying text, it's much safer to use an HTML text form than a raw file upload. Also, note that a file can be multiple file types; for example, self-extracting ZIPs are both valid Windows executables and ZIP files, and can be treated as either.
0
0
0
1
2010-10-23T01:33:00.000
2
0.099668
false
4,002,015
0
0
1
1
Say I let users upload files to my server, and I let users download them. I'd like to set the mime type to something other than just application/octet-stream, so that if the browser can just open them, it does (say, for images, pdf files, plain text files, etc.) Of course, since the files are uploaded by users, I can't trust the file extension, etc. Is there a good library for figuring out what mime type goes with an arbitrary blob? Preferably usable from Python :-) Thanks!
Getting the Tasks in a Google App Engine TaskQueue
4,059,302
1
6
2,402
0
python,google-app-engine,task,dashboard,task-queue
A workaround, since they don't seem to support this yet, would be to model a Task datastore object. Create one on task queue add, update it when running, and delete it when your task fires. This can also be a nice way to get around the payload limits of the task queue api.
0
1
0
0
2010-10-23T04:42:00.000
3
0.066568
false
4,002,514
0
0
1
1
I know you can view the currently queued and running tasks in the Dashboard or development server console. However, is there any way to get that list programmatically? The docs only describe how to add tasks to the queue, but not how to list and/or cancel them. In python please.
Django development version vs stable release
4,010,690
0
2
1,216
0
python,django,google-app-engine
Another thing to consider is how you install. I'd be sure to install django from SVN, because it makes updating it MUCH easier. I have been using the dev version for a while on my site, and haven't encountered a single bug yet, aside from one that affected the admin site in a minor way (which a svn up fixed). I don't have a feel for whether people are using 1.2 or dev, but in my experience, dev is perfectly suitable. Any major errors that you may have in the code will get fixed very quickly, and svn up will get you to the latest code on the off chance that you get a revision with a major bug.
0
1
0
0
2010-10-24T20:40:00.000
3
0
false
4,010,349
0
0
1
1
I am about to start ramping up on Django and develop a web app that I want to deploy on Google App Engine. I learn that Google has Django 0.96 already installed on the APP engine, but the latest "official" version of Django I see is at 1.2.3 and its a bit of an effort to install it there. I am curious which version of Django is most widely used. So, can you please guide me on which Django version I should ramp on and deploy based on the following criterion Stability and suitability for production release Availability for applications (or plugins) and which version is most supported by the community Thanks a lot!
How do I forcefully clean a field and redisplay it in Django?
4,013,095
0
3
220
0
python,django
If, after you've cleaned your form with is_valid(), you render that cleaned form with your view, rather than redirect to a new page, you'll see the cleaned data in your page. (If you wanted the user to see this cleaned data and then properly submit it, you could use a hidden field to track whether the form data has already been cleaned, but this isn't without complications...)
0
0
0
0
2010-10-24T21:17:00.000
1
0
false
4,010,507
0
0
1
1
How can I clean the data in a form and have the cleaned data redisplayed instead of the submitted data? There are several fields in my form, and every time the user submits it, it should be redisplayed with the values the user entered. However, some of the fields I would like to clean and update for the user. More specifically, I have a field FriendlyIntegerField(forms.CharField) in which I override to_python to not only call int(str(value)), but also set any negative number to 0 etc. I do not want to redisplay the form with the invalid data and have the user fix it himself (which is how Django wants me to do it). I don't have a problem cleaning the data and use it for the rest of my view-function, but how can I update the actual form with this data? By the way, the form does not reflect a structure in my data model, and so inherits from Form, not ModelForm. Edit: My Field (in a stripped down version) looks like this: class FriendlyIntegerField(forms.CharField): def to_python(self, value): try: return str(int(str(value).replace(' ',''))) except: raise forms.ValidationError('some error msg') My Form (in a stripped down version) looks like this: class SearchForm(forms.Form): price_from = FriendlyIntegerField() price_to = FriendlyIntegerField() And my view: def search(request, key): if request.method == 'POST': form = SearchForm(request.REQUEST) if not form.is_valid(): print "Form not valid" else: form = SearchForm() return render_to_response('path_to_template', {'form' : form}
django multiple select in admin change-list
4,030,636
0
0
559
0
python,django,django-models,django-admin
say you have a product model class Product(models.Model): name=models.CharField(max_length=20) cost=models.DecimalField(max_length=10) you can subclass the admin's Modeladmin to show a list display for the products or you can do a custom modelform for the product which you can call in the product's admin from django.contrib import admin from django import forms class PropertyInline(admin.TabularInine): model=Property extra=1 class PropertyForm(admin.ModelAdmin): inlines=(PropertyInline,)
0
0
0
0
2010-10-25T10:38:00.000
1
0
false
4,013,733
0
0
1
1
Our product model can have multiple campaigns. Our customers change these campaigns frequently and generally on multiple products. So what we need right now seems that we need to show a multiple select widget on a change-list of Product model where our customers can easily change the campaigns. Any idea on this? Maybe another way to achieve this kind of UI interaction? Thanks,
Loading New Content with Ajax
4,027,614
1
2
261
0
javascript,python,ajax,django
The reason to update all of the comments is to take in account other comments that other people may have also submitted in the meantime. to keep the site truly dynamic, you can do either that, or even, when the page is loaded, load up a variable with the newest submitted comment ID, and set a timer that goes back to check if there are more comments since then. if there are, return them as a JSON object and append them onto the current page a DIV at a time. That would be my preferred way to handle it, because you can then target actions based on each DIV's id or rel, which directly relates back to the comment's ID in the database...
0
0
0
0
2010-10-26T20:02:00.000
3
0.066568
false
4,027,508
0
0
1
3
This is a situation I've run into several times, not sure what the best approach is. Let's say I have some kind of dynamic content that users can add to via Ajax. For example, take Stack Overflow's comments - people can add comments directly on to the page using Ajax. The question is, how do I implement the addition itself of the new content. For example, it looks like the ajax call which Stack Overflow uses to add a comment, simply returns html which replaces all of the comments (not just the new one). This way saves redundant logic in the Javascript code which has to "know" what the html looks like. Is this the best approach? If so, how best to implement it in Django so that there is no redundancy (i.e., so that the view doesn't have to know what the html looks like?) Thanks! EDIT: In my specific case, there is no danger of other comments being added in the meantime - this is purely a question of the best implementation.
Loading New Content with Ajax
4,027,641
1
2
261
0
javascript,python,ajax,django
I am not proficient neither with Django nor Python but I suppose the basic logic is similar for all server-side languages. When weighing the pros and cons of either approach things depend on what you want to optimize. If bandwidth is important then obviously using pure JSON in communication reduces latency when compared to transmitting ready-made HTML. However, duplicating the server-side view functionality to Javascript is a tedious and error-prone process. It simply takes a lot of time. I personally feel that in most cases (for small and medium traffic sites) it's perfectly fine to put the HTML fragment together on server side and simply replace the contents of a container (e.g. contents of a div) inside an AJAX callback function. Of course, replacing the whole page would be silly, hence your Django application needs to support outputting specific regions of the document.
0
0
0
0
2010-10-26T20:02:00.000
3
0.066568
false
4,027,508
0
0
1
3
This is a situation I've run into several times, not sure what the best approach is. Let's say I have some kind of dynamic content that users can add to via Ajax. For example, take Stack Overflow's comments - people can add comments directly on to the page using Ajax. The question is, how do I implement the addition itself of the new content. For example, it looks like the ajax call which Stack Overflow uses to add a comment, simply returns html which replaces all of the comments (not just the new one). This way saves redundant logic in the Javascript code which has to "know" what the html looks like. Is this the best approach? If so, how best to implement it in Django so that there is no redundancy (i.e., so that the view doesn't have to know what the html looks like?) Thanks! EDIT: In my specific case, there is no danger of other comments being added in the meantime - this is purely a question of the best implementation.
Loading New Content with Ajax
4,029,103
4
2
261
0
javascript,python,ajax,django
If the content is simple, I would get JSON and build the HTML in jQuery. If it's complex, I would create a template and call render() on it on the server and return the HTML (which jQuery could either append to other content or replace existing content).
0
0
0
0
2010-10-26T20:02:00.000
3
1.2
true
4,027,508
0
0
1
3
This is a situation I've run into several times, not sure what the best approach is. Let's say I have some kind of dynamic content that users can add to via Ajax. For example, take Stack Overflow's comments - people can add comments directly on to the page using Ajax. The question is, how do I implement the addition itself of the new content. For example, it looks like the ajax call which Stack Overflow uses to add a comment, simply returns html which replaces all of the comments (not just the new one). This way saves redundant logic in the Javascript code which has to "know" what the html looks like. Is this the best approach? If so, how best to implement it in Django so that there is no redundancy (i.e., so that the view doesn't have to know what the html looks like?) Thanks! EDIT: In my specific case, there is no danger of other comments being added in the meantime - this is purely a question of the best implementation.
Django Poll for new records
4,029,976
0
0
92
0
python,django,polling
Hmm. You could do it two ways that I can think of off the bat - there are surely more. You can add a field called "already_retrieved" and set it to True for those fields that have already been retrieved, and then only grab Whatever.objects.filter(already_retrieved=False). Also, if they are in order by a pk, you could just keep track of how far you are in the list of pk's.
0
0
0
0
2010-10-27T03:42:00.000
2
0
false
4,029,807
0
0
1
1
In ajax I am polling a django url to retrieve the latest records. I do not want to display any records I have retrieved previously and I only want to retrieve 1 record for each poll request. What would be the best way to do this?
Any framework for PHP, as effective as Django for Python?
4,030,033
3
0
3,514
0
php,python,django,frameworks
I'd try Symfony. What you're referring to sounds like "scaffolding"
0
0
0
0
2010-10-27T04:44:00.000
5
0.119427
false
4,030,026
0
0
1
2
I am using python with django. There I can simply make form from models and also it had builtin Admin. I am eager to know corresponding framework for PHP with all this facilities. I have encountered lot some similar questions like this, but they had not compared the frameworks with django. Experts Please Suggest.
Any framework for PHP, as effective as Django for Python?
4,030,038
2
0
3,514
0
php,python,django,frameworks
I've had good success with Zend in the past. It has a lot of functionality in its libraries and it is all completely decoupled, so you can use whichever parts best fit your task, leaving out other things all together.
0
0
0
0
2010-10-27T04:44:00.000
5
0.07983
false
4,030,026
0
0
1
2
I am using python with django. There I can simply make form from models and also it had builtin Admin. I am eager to know corresponding framework for PHP with all this facilities. I have encountered lot some similar questions like this, but they had not compared the frameworks with django. Experts Please Suggest.
One python multiprocess errors
4,385,534
1
0
1,864
0
python,multiprocess
Main proc is waiting for all child procs to be terminated before exits itself so there's a blocking call (i.e. wait4) registered as at_exit handles. The signal you sent interrupts that blocking call thus the stack trace. The thing I'm not clear about is that if the signal sent to child would be redirected to the parent process, which then interrupted that wait4 call. This is something related to the Unix process group behaviors.
0
1
0
0
2010-10-27T05:40:00.000
1
0.197375
false
4,030,277
1
0
1
1
I have one multprocess demo here, and I met some problems with it. Researched for a night, I cannot resolve the reason. Any one can help me? I want to have one parent process acts as producer, when there are tasks come, the parent can fork some children to consume these tasks. The parent monitors the child, if any one exits with exception, it can be restarted by parent. #!/usr/bin/env python # -*- coding: utf-8 -*- from multiprocessing import Process, Queue from Queue import Empty import sys, signal, os, random, time import traceback child_process = [] child_process_num = 4 queue = Queue(0) def work(queue): signal.signal(signal.SIGINT, signal.SIG_DFL) signal.signal(signal.SIGTERM, signal.SIG_DFL) signal.signal(signal.SIGCHLD, signal.SIG_DFL) time.sleep(10) #demo sleep def kill_child_processes(signum, frame): #terminate all children pass def restart_child_process(signum, frame): global child_process for i in xrange(len(child_process)): child = child_process[i] try: if child.is_alive(): continue except OSError, e: pass child.join() #join this process to make sure there is no zombie process new_child = Process(target=work, args=(queue,)) new_child.start() child_process[i] = new_child #restart one new process child = None return if __name__ == '__main__': reload(sys) sys.setdefaultencoding("utf-8") for i in xrange(child_process_num): child = Process(target=work, args=(queue,)) child.start() child_process.append(child) signal.signal(signal.SIGINT, kill_child_processes) signal.signal(signal.SIGTERM, kill_child_processes) #hook the SIGTERM signal.signal(signal.SIGCHLD, restart_child_process) signal.signal(signal.SIGPIPE, signal.SIG_DFL) When this program runs, there will be errors as below: Error in atexit._run_exitfuncs: Error in sys.exitfunc: Traceback (most recent call last): File "/usr/local/python/lib/python2.6/atexit.py", line 30, in _run_exitfuncs traceback.print_exc() File "/usr/local/python/lib/python2.6/traceback.py", line 227, in print_exc print_exception(etype, value, tb, limit, file) File "/usr/local/python/lib/python2.6/traceback.py", line 124, in print_exception _print(file, 'Traceback (most recent call last):') File "/usr/local/python/lib/python2.6/traceback.py", line 12, in _print def _print(file, str='', terminator='\n'): File "test.py", line 42, in restart_child_process new_child.start() File "/usr/local/python/lib/python2.6/multiprocessing/process.py", line 99, in start _cleanup() File "/usr/local/python/lib/python2.6/multiprocessing/process.py", line 53, in _cleanup if p._popen.poll() is not None: File "/usr/local/python/lib/python2.6/multiprocessing/forking.py", line 106, in poll pid, sts = os.waitpid(self.pid, flag) OSError: [Errno 10] No child processes If I send signal to one child:kill –SIGINT {child_pid} I will get: [root@mail1 mail]# kill -SIGINT 32545 [root@mail1 mail]# Error in atexit._run_exitfuncs: Traceback (most recent call last): File "/usr/local/python/lib/python2.6/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/local/python/lib/python2.6/multiprocessing/util.py", line 269, in _exit_function p.join() File "/usr/local/python/lib/python2.6/multiprocessing/process.py", line 119, in join res = self._popen.wait(timeout) File "/usr/local/python/lib/python2.6/multiprocessing/forking.py", line 117, in wait return self.poll(0) File "/usr/local/python/lib/python2.6/multiprocessing/forking.py", line 106, in poll pid, sts = os.waitpid(self.pid, flag) OSError: [Errno 4] Interrupted system call Error in sys.exitfunc: Traceback (most recent call last): File "/usr/local/python/lib/python2.6/atexit.py", line 24, in _run_exitfuncs func(*targs, **kargs) File "/usr/local/python/lib/python2.6/multiprocessing/util.py", line 269, in _exit_function p.join() File "/usr/local/python/lib/python2.6/multiprocessing/process.py", line 119, in join res = self._popen.wait(timeout) File "/usr/local/python/lib/python2.6/multiprocessing/forking.py", line 117, in wait return self.poll(0) File "/usr/local/python/lib/python2.6/multiprocessing/forking.py", line 106, in poll pid, sts = os.waitpid(self.pid, flag) OSError: [Errno 4] Interrupted system call
3rd party applications inside iFrames?
4,036,760
1
1
321
0
javascript,python,html,ruby
If you meant "embed" rather than "extend" and you just want people to drop a little box on a page and that's it, then an iframe should be fine. However, if you want two-way communication or mashupability — rather than "opaque blob of HTML and hope for the best" communication — then a JavaScript or REST API might be a better call. More specifics would make for an easier answer. If the functionality you need is on the level of an embedded ad or stackoverlflow flair then an iframe would work, if the functionality is more along the lines of a Google Map then an API of some sort would work better.
0
0
0
0
2010-10-27T12:45:00.000
2
1.2
true
4,033,325
0
0
1
2
I am about to build a web application and I want to allow other developers extend it with their own applications. Should I do this with iFrames like Facebook? Is this a good practice? Are there other alternatives that let other developers extend my application (that is for the user it looks like it's from my application). To be specific: I want developers to be able to code applications that is embedded on my web application. Eg. if I have a file on my application they could provide a way for the users to interact with that file. Maybe a "preview" application that let the users preview the file. Another application might draw a mindmap tree view of all the user's files. What is the best way of doing this? iFrame + Restful API on backend for data exchange? Let them insert javascript on backend + frontend + html + css on my web application? Other alternatives?
3rd party applications inside iFrames?
4,033,372
0
1
321
0
javascript,python,html,ruby
It depends on what you mean by "extend". When you use iFrames with 3rd parties, presumably vended from different domains than the host page, then you are constrained by cross-domain issues and cannot interact with the contents of those iFrames. If that's not an issue for you, then you can go ahead and try that strategy, but I can't see how merely adding iFrames without interopability is "extending" your web application.
0
0
0
0
2010-10-27T12:45:00.000
2
0
false
4,033,325
0
0
1
2
I am about to build a web application and I want to allow other developers extend it with their own applications. Should I do this with iFrames like Facebook? Is this a good practice? Are there other alternatives that let other developers extend my application (that is for the user it looks like it's from my application). To be specific: I want developers to be able to code applications that is embedded on my web application. Eg. if I have a file on my application they could provide a way for the users to interact with that file. Maybe a "preview" application that let the users preview the file. Another application might draw a mindmap tree view of all the user's files. What is the best way of doing this? iFrame + Restful API on backend for data exchange? Let them insert javascript on backend + frontend + html + css on my web application? Other alternatives?
PHP front-end for installing Django
4,039,483
1
0
208
0
php,python,django
You should probably bundle Django with your project - or the parts of it that are needed. Users of your product will need to have python and the necessary libs installed. That is not something that you can do via PHP. Well, you could, but that would be like Webmin. When making a product for sale or for users to install, this is always something to think about before starting. In fact, at times, this very restriction is the most important deciding factor when choosing a technology and designing the system. Why is XYZ popular in the first place?
0
0
0
0
2010-10-27T13:02:00.000
1
1.2
true
4,033,492
0
0
1
1
A simple question: Is this possible? Is it worth the time looking into it?
What do i build my alpha platform on, PHP, Ruby, Python, .NET, etc?
4,034,000
1
1
156
0
php,.net,python,ruby-on-rails
Write in assembler if you're comfortable with that. :) Some questions you should ask yourself: Are there hosting restrictions? No point in coding ASP.net when you have a PHP-only host/server. Are there technical restrictions? E.g. if you want to use SQL Server as a back-end, going with ASP.net may make your life easier. What other requirements do you have? Does it have to run on the JVM? Do you want to compile stuff all the time or do you want an interpreted language? etc. etc. What experience do you have? If you're already familiar with Python, why switch to Ruby? My best tip is: use what's best for the job at hand according to the above questions. For me, I'd use Ruby on Rails for the project you described. Rails offers all the tools I need for a large project like that. Please let us know when and what you've decided :)
0
0
0
1
2010-10-27T13:26:00.000
2
0.099668
false
4,033,735
0
0
1
2
I am developing a social networking website in the facebook/foursquare-ish space. I have gotten such varied feedback on what platform I should develop in. Of course it will be heavily influenced by who I hire, but i was hoping for a little additional feedback from the larger community. Thanks.
What do i build my alpha platform on, PHP, Ruby, Python, .NET, etc?
4,033,788
7
1
156
0
php,.net,python,ruby-on-rails
It doesn't matter. StackOverflow was written in ASP .NET MVC and it's awesome. Twitter was written in Rails and it's super popular. Facebook was written in PHP and half a billion people use it. It's not the technology, it's the community. That's the hard part. Just pick one and go. Your best bet might actually be to find the technology that the most smart people are using while still working for the least amount of money.
0
0
0
1
2010-10-27T13:26:00.000
2
1
false
4,033,735
0
0
1
2
I am developing a social networking website in the facebook/foursquare-ish space. I have gotten such varied feedback on what platform I should develop in. Of course it will be heavily influenced by who I hire, but i was hoping for a little additional feedback from the larger community. Thanks.
How can I use HTML + Javascript to build a python GUI?
17,223,197
0
22
24,264
0
python,webkit
If you are thinking about real desktop applications that are multi-threaded and/or use multiple system component - forget about JavaScript. That requires a very good SDK (like PyQt4), and not a basic wrapper like Appcelerator Titanium. Note that developing such applications takes a lot of time. Second option is to drop the desktop binding and make a web application with an advanced frontend UI made with one of JavaScript frameworks & friends (Ember, Angular... up to things like dhtmlx and alike widgets). Those can't use system components (like access some hardware), but they can provide nice services.
0
0
0
0
2010-10-27T14:09:00.000
10
0
false
4,034,169
0
0
1
2
I have been experimenting with Appcelerator Titanum yesterday and I think it's cool when it comes to Javascript. Python features on Appcelerator Titanum are so limited (can't use some modules for example). My question is How can I use html & javascript as a GUI tool for a real python application ? I am running windows 7 and i was thinking of using webkit for that purpose but couldn't know how to work with it in python. I am planning to make a standalone executable using py2exe as I don't know if the users always have python and the appropriate modules installed.
How can I use HTML + Javascript to build a python GUI?
4,064,133
0
22
24,264
0
python,webkit
I assume you are mobilizing a web-application for cross platform access. If so have you considered abstracting the cross platform access at the web-app presentation layer ? Appcelerator / Webkit does not provide true native look-and-feel on mobile devices but this is where a new technology can help.
0
0
0
0
2010-10-27T14:09:00.000
10
0
false
4,034,169
0
0
1
2
I have been experimenting with Appcelerator Titanum yesterday and I think it's cool when it comes to Javascript. Python features on Appcelerator Titanum are so limited (can't use some modules for example). My question is How can I use html & javascript as a GUI tool for a real python application ? I am running windows 7 and i was thinking of using webkit for that purpose but couldn't know how to work with it in python. I am planning to make a standalone executable using py2exe as I don't know if the users always have python and the appropriate modules installed.
A good way to make Django geolocation aware? - Django/Geolocation
4,037,302
0
2
1,229
0
python,django,geolocation
Geocoding datasets from yahoo and google can be a good starting poing, Also take a look at geopy library in django.
0
0
0
0
2010-10-27T16:00:00.000
2
0
false
4,035,195
0
0
1
1
I would like to be able to associate various models (Venues, places, landmarks) with a City/Country. But I am not sure what some good ways of implementing this would be. I'm following a simple route, I have implemented a Country and City model. Whenever a new city or country is mentioned it is automatically created. Unfortunately I have various problems: The database can easily be polluted Django has no real knowledge of what those City/Countries really are Any tips or ideas? Thanks! :)
Advice on designing django model with "exclusive" foreign key relationships
4,045,209
0
0
141
0
python,django-models
What I have done is to inherit from a base class on all my models that will be related to tasks. Task models points to that base class on the ForeignKey with unique=True, and it seems like all subclasses inherit the relationship. Thanks.
0
0
0
0
2010-10-27T16:12:00.000
2
0
false
4,035,298
0
0
1
1
I want to design a Task model that can be associated to Project Models, another X model, and other Task models. The obvious choice is a foreign key, but I want any particular instance of that Task model to only be associated to only one of those model types, that is, if a Task model has a relationship with a Project model, it cannot have a relationship with another Task model, and so on. Any advice in what would be the best way to represent this? Thanks.
Django, Python: How do I know if users have closed their browser without click logout?
4,039,366
4
0
982
0
python,django
HTTP is a stateless protocol: you can't know at the server if the user has simply closed their browser without informing you.
0
0
0
0
2010-10-28T02:30:00.000
3
0.26052
false
4,039,278
0
0
1
2
Django, Python: How do I know if users have closed their browser without click logout? Really seriously question, because I need to analyse the user activities.
Django, Python: How do I know if users have closed their browser without click logout?
4,039,425
0
0
982
0
python,django
It's not pretty, but you could fire off ajax requests with the user's session info (or some cookie, or any way of identifying the user) every x seconds with javascript and if you haven't received anything from that user in 2*x seconds, then they're likely to have left the page/site.
0
0
0
0
2010-10-28T02:30:00.000
3
0
false
4,039,278
0
0
1
2
Django, Python: How do I know if users have closed their browser without click logout? Really seriously question, because I need to analyse the user activities.
Django: tracking all the database changes with values
4,040,743
1
2
1,840
0
python,django,django-models
fullhistory seems to do most of what you want - what part of the requirement does it not fulfil? It might be easier to enhance fullhistory. Another option is to do it at the database level, if your database supports logging at that level.
0
0
0
0
2010-10-28T07:21:00.000
2
0.099668
false
4,040,656
0
0
1
1
I have to implement an application in django which will track all the changes in the database with the previous values,current value,action,date,time, user(who performed the changes) etc. Is there any application/module available in python or django which can perform these actions with may be after some changes. I have seen "fullhistory" app in Django but it does not fits into the requirement. Please suggest. Thanks in advance
How to add reference to a dynamic assembly for compiling another dynamic assembly?
4,040,871
0
2
2,123
0
c#,asp.net-mvc,clr,ironpython,razor
Not test, try use assembly.FullName instead of assembly.Location.
0
0
0
0
2010-10-28T07:51:00.000
2
0
false
4,040,825
1
0
1
1
In my AppDomain there are few dynamic assembly, when I try codeDom.CompileAssemblyFromSource to Compile another new assembly, I can't figure out a way to add those dynamic assemble to ReferencedAssemblies. foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { compilerParameters.ReferencedAssemblies.Add(assembly.Location); } Failed, as dynamic assembly doesn't have Location. Thanks in advance. PS: I'm actually trying to use ASP.Net MVC 3's new Razor template engine in IronPython.
Django : ORM objects come with nothing in _meta.local_fields
4,042,630
0
0
280
0
python,django
It seems that proxy objects don't have local_fields set, which would be logical. I've just found something in the existing code (exploiting the django python serializer) that works around the lack of local_fields... I think my question is void :-/
0
0
0
0
2010-10-28T09:35:00.000
1
1.2
true
4,041,543
0
0
1
1
[python 2.6 - django 1.1.1] Hello. I'm writing a custom serializer for my django application. All the objects that I use are proxy objects derived from django model classes and implement special members that I must serialize (hence the custom serializer). So I've begun to implement a new abstract serializer that inherits django.core.serialiazer.base.Serializer and redifines the serialize(...) method. I've also begun a python concrete serializer (child-class of my own base Serializer), needed for custom construction of the dict. Problem is, when my queryset comes into the serialize() method, each individual obj in it has an empty list ([]) for obj._meta.local_fields. As a consequence, my serialized python dicts are almost empty (apart from primary key & model), because I rely on this list. I can't seem to find where this field is inited. I don't understand, also, why _meta.local_fields is inconsistent when I use my serializer and not when I use django's serializer (i pass the same querysets of proxy objects). Thanks. EDIT: i thought maybe some __init__ code somewhere in the django packages had an effect, but I can't find anything in that direction, either.
Django: If I added new tables to database, how can I query them?
4,042,305
0
0
78
1
python,django,django-models,django-admin
Django doen't follow convention over configuration philosophy. you have to explicitly create the backing model for the table and in the meta tell it about the table name...
0
0
0
0
2010-10-28T11:11:00.000
2
0
false
4,042,286
0
0
1
2
Django: If I added new tables to database, how can I query them? Do I need to create the relevant models first? Or django creates it by itself? More specifically, I installed another django app, it created several database tables in database, and now I want to get some specific data from them? What are the correct approaches? Thank you very much!
Django: If I added new tables to database, how can I query them?
4,042,337
1
0
78
1
python,django,django-models,django-admin
I suppose another django app has all model files needed to access those tables, you should just try importing those packages and use this app's models.
0
0
0
0
2010-10-28T11:11:00.000
2
1.2
true
4,042,286
0
0
1
2
Django: If I added new tables to database, how can I query them? Do I need to create the relevant models first? Or django creates it by itself? More specifically, I installed another django app, it created several database tables in database, and now I want to get some specific data from them? What are the correct approaches? Thank you very much!
Defining Constants in Django
4,042,429
3
23
31,657
0
python,django,constants
Consider putting it into settings.py of your application. Of course, in order to use it in template you will need to make it available to template as any other usual variable.
0
0
0
0
2010-10-28T11:27:00.000
7
0.085505
false
4,042,407
1
0
1
1
I want to have some constants in a Django Projects. For example, let's say a constant called MIN_TIME_TEST. I would like to be able to access this constant in two places: from within my Python code, and from within any Templates. What's the best way to go about doing this? EDIT: To clarify, I know about Template Context Processors and about just putting things in settings.py or some other file and just importing. My question is, how do I combine the two approaches without violating the "Don't Repeat Yourself" rule? Based on the answers so far, here's my approach: I'd like to create a file called global_constants.py, which will have a list of constants (things like MIN_TIME_TEST = 5). I can import this file into any module to get the constants. But now, I want to create the context processor which returns all of these constants. How can I go about doing this automatically, without having to list them again in a dictionary, like in John Mee's answer?
What is the best way to serve small static images?
4,046,258
1
3
547
0
java,javascript,python,image
Data urls will definitely reduce the number of requests to the server, since the browser doesn't have to ask for the pixels in a separate request. But they are not supported in all browsers. You'll have to make the tradeoff.
0
0
1
0
2010-10-28T18:54:00.000
4
0.049958
false
4,046,242
0
0
1
1
Right now I'm base 64 encoding them and using data uris. The idea was that this will somehow lower the number of requests the browser needs to make. Does this bucket hold any water? What is the best way of serving images in general? DB, from FS, S3? I am most interested in python and java based answers, but all are welcome!
Date sensitive regression testing using python
4,121,205
0
0
317
0
python,date,automated-tests,regression-testing
Answering my own question: Our current plan is to test on virtual machines and change the date/time on the VMs. This is a more complete solution as it gets the database and worker threads all at once. I'll post an update with some real world experience when we come to actual do it.
0
0
0
1
2010-10-28T20:46:00.000
2
0
false
4,047,049
0
0
1
1
Hey, I am helping to set up a regression testing suite for our python web application. Many of our tests are scheduling style tests where the current date is important. For example: create a recurring event that runs every week for a month starting on Feb 1. In order to test this, what I really want to do is override the current date so I can move back and forward in time to check the state of the app. For example, I may add an test-only page that lets me set the 'current' date which gets passed to the python back end and is used for date calculations. In the past when I have done this, I engineered it into the application architecture from day 1. Unfortunately, I am coming in late to this project and there is no application support for this. So here's my question, is there any way I can override the current date on a web service call? For example, can I intercept calls for the current date (monkey patching possibly?). I would rather not have to do a whole IOC thing as it would mean changing hundreds of methods. - dave
Does FastCGI or Apache2 limit upload sizes?
4,047,955
2
3
1,279
1
python,mysql,file-upload,apache2,fastcgi
If the web server/gateway layer were truncating incoming form submissions I'd expect an error from FieldStorage, since the truncation would not just interrupt the file upload but also the whole multipart/form-data structure. Even if cgi.py tolerated this, it would be very unlikely to have truncated the multipart at just the right place to leave exactly 2**16-1 bytes of file upload. So I would suspect MySQL. LONGBLOB should be fine up to 2**32-1, but 65535 would be the maximum length of a normal BLOB. Are you sure the types are what you think? Check with SHOW CREATE TABLE x. Which database layer are you using to get the data in?
0
0
0
0
2010-10-28T23:16:00.000
1
1.2
true
4,047,899
0
0
1
1
I'm having a problem with file uploading. I'm using FastCGI on Apache2 (unix) to run a WSGI-compliant application. File uploads, in the form of images, are begin saved in a MySQL database. However, larger images are being truncated at 65535 bytes. As far as I can tell, nothing should be limiting the size of the files and I'm not sure which one of the pieces in my solution would be causing the problem. Is it FastCGI; can it limit file upload sizes? Is it Python? The cgi.FieldStorage object gives me a file handle to the uploaded file which I then read: file.read(). Does this limit file sizes in any way? Is it MySQL? The type of the column for saving the image data is a longblob. I figured this could store a couple of GB worth of data. So a few MB shouldn't be a problem, right? Is it the flups WSGIServer? I can't find any information regarding this. My file system can definitely handle huge files, so that's not a problem. Any ideas? UPDATE: It is MySQL. I got python to output the number of bytes uploaded and it's greater than 65535. So I looked into max_allowed_packet for mysqld and set it to 128M. Overkill, but wanting to be sure for the moment. My only problem now is getting python's MySQLdb to allow the transfer of more than 65535 bytes. Does anyone know how to do this? Might post as a separate question.
What's the best way to start learning django?
4,048,987
8
54
77,794
0
python,django
Build something. Anything. Keep it relatively simple and short, but start building it and make sure you finish building it. The project you have in mind right there might be perfect. Reading documentation and books is extremely helpful, of course, but like any programming the only way to really learn Django is to practice with it. Building something tangible is pretty much the only way to get that practice.
0
0
0
0
2010-10-29T04:26:00.000
8
1
false
4,048,973
0
0
1
2
I really want to build a web application; something simple, maybe a database of Pokémon cards for instance? I've heard excellent things about Django. Where would be the best place to start?
What's the best way to start learning django?
4,050,115
7
54
77,794
0
python,django
If you don't know Python, start your learning with that. People tend to get very frustrated when they try to learn a framework without knowing at least something about its programming language.
0
0
0
0
2010-10-29T04:26:00.000
8
1
false
4,048,973
0
0
1
2
I really want to build a web application; something simple, maybe a database of Pokémon cards for instance? I've heard excellent things about Django. Where would be the best place to start?
Django Apps extendability - How to make your django apps easily extendable?
4,051,518
1
0
238
0
python,django
use signals and dispatchers in your app create files.. -litseners.py -signals.py and then implement signals for your models and forms (views not so much) use the django plugins pattern ducktyping for your classes
0
0
0
0
2010-10-29T10:32:00.000
2
0.099668
false
4,051,010
0
0
1
1
What are your best practises for making your django application easily extendable for other developers? What are your approaches for enabling other to overwrite your views forms templates models classes In a way that enables a healthy environment for extensions to work well together?
fit mysql db in memory
4,061,902
1
1
1,165
1
python,mysql,sqlalchemy,performance
I would create a read only slave to your mysql database and force its database engines to memory. You'd have to handle failures by re-initializing the read only database, but that can be scripted rather easily. This way you still have your persistence in the regular mysql database and your read speed in the read only memory tables.
0
0
0
0
2010-10-31T04:18:00.000
3
1.2
true
4,061,828
0
0
1
2
I am using Redis database where we store the navigational information. These data must be persistent and should be fetched faster. I don't have more than 200 MB data in this data set. I face problem when writing admin modules for redis db and I really missing the sql schema and power of django style admin modules. Now I am thinking of using MySQL. The requirement is, I want the persistent database but the data can be loaded into the memory like redis so that I can do the SQL queries REALLY faster. Is it possible to use MySQL in persistent mode and instruct MySQL to use the memory for querying purpose? What is the best suitable MySQL DB where I do not worry much on consistencies where our writes are very few.
fit mysql db in memory
4,061,848
0
1
1,165
1
python,mysql,sqlalchemy,performance
I would think you could have a persistent table, copy all of the data into a MEMORY engine table whenever the server starts, and have triggers on the memory db for INSERT UPDATE and DELETE write to the persistent table so it is hidden for the user. Correct me if I'm wrong though, it's just the approach I would first try.
0
0
0
0
2010-10-31T04:18:00.000
3
0
false
4,061,828
0
0
1
2
I am using Redis database where we store the navigational information. These data must be persistent and should be fetched faster. I don't have more than 200 MB data in this data set. I face problem when writing admin modules for redis db and I really missing the sql schema and power of django style admin modules. Now I am thinking of using MySQL. The requirement is, I want the persistent database but the data can be loaded into the memory like redis so that I can do the SQL queries REALLY faster. Is it possible to use MySQL in persistent mode and instruct MySQL to use the memory for querying purpose? What is the best suitable MySQL DB where I do not worry much on consistencies where our writes are very few.
Django Time issues
4,065,182
2
2
274
0
python,django
I'd make all my times UTC, as that's a good international-level reference point, and you can always shift that to a local time, given that you know the user's TZ. I'd also use the time on the server (datetime.datetime.now()) rather than rely on the client's system clock, as this makes it easy to fake what time something happened at.
0
0
0
0
2010-10-31T21:12:00.000
3
0.132549
false
4,065,157
0
0
1
1
My app in django requires to tell the user what time an action occurred. Aside from asking the user what timezone he/she is in, is it possible for me to generate the time on the client end? Off the top of my head, are there a particular representation of time that is timezone independent, (unix time?), and then I can simply paste it into the html and have the client end (browser) findout the timezone and then do the calculation?
passing data between java and python
40,502,477
0
5
5,214
0
java,python,django,jython
It might be what you wanted to avoid. but at the most simple way of things, using sockets / shared file with java will be the best solution. python socket can send information and revise it from java. On the other hand if that feel like a pain. if you use java and python at the same computer you can use a shared file, that java can read from and python can wright to.
0
0
0
0
2010-11-01T10:20:00.000
4
0
false
4,068,052
0
0
1
1
Apologies if my question is noob. I'm running Django 1.2 with pgsql 8.4 and I'm required to run a Java program after getting the inputs from the user, does some calculations and return the results back to the user. May I know what is the best way to pass data between the Java and Python Django, such that the above scenario are taken care of? I heard of Jython, but according to the Django docs, it requires the extension jython-Django, but currently it doesn't support django 1.2.x. Should I pass the data using stdout? thanks people for hearing me out.
Django + alwaysdata.com Noob Question
4,073,511
1
1
1,444
0
python,django
The devserver included with django is for testing purposes, only on your local machine and should not be used on a web host. From the docs: DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that's how it's gonna stay. We're in the business of making Web frameworks, not Web servers, so improving this server to be able to handle a production environment is outside the scope of Django.) If i have somehow misinterpreted your question, i apologise.
0
0
0
0
2010-11-01T21:47:00.000
4
0.049958
false
4,073,352
0
0
1
1
I'm learning Django and working on sample sites.. I registered at alwaysdata but am unable to view the site after I go 'manage.py runserver' in the SSH (this is after I've created the project and navigated to the appropriate directory, of course). I appreciate any help. Thanks
What is the best way to store change history of website articles?
4,076,484
0
0
289
0
php,.net,python,ruby
I presume you're using a CMS. If not, use one. WordPress is a good start. If you're developing from scratch, the usual method is to have two tables: one for page information (so title, menu position etc.) and then a page_content table, which has columns for page_id, content, and timestamp. As you save a page, instead of updating a database table you instead write a new record to the page_content table with the page's ID and the time of the save. That way, when displaying pages on your front-end you just select the latest record for that particular page ID, but you also have a history of that page by querying for all records by page_id, sorted by timestamp.
0
0
1
1
2010-11-02T06:11:00.000
3
1.2
true
4,075,309
0
0
1
2
Our client wants us to implement change history for website articles. What is the best way to do it?
What is the best way to store change history of website articles?
4,075,372
-1
0
289
0
php,.net,python,ruby
There is a wide variety of ways to do this as you alluded by tagging php, .net, python, and ruby. You missed a few off the top of my head perl and jsp. Each of these have their plusses and minuses and is really a question of what best suits your needs. PHP is probably the fastest reward for time spent. Ruby, i'm assuming Ruby on Rails, is the automatic Buzz Word Bingo for the day. .Net, are you all microsoft every where and want easy integration with your exchange server and a nice outlook API? python? Do you like the scripted languages but you're too good for php and ruby. Each of these languages have their strong points and their draw backs and it's really a matter of what you know, how much you have to spend, and what is your timeframe.
0
0
1
1
2010-11-02T06:11:00.000
3
-0.066568
false
4,075,309
0
0
1
2
Our client wants us to implement change history for website articles. What is the best way to do it?
Python - optimize by not importing at module level?
4,080,823
15
5
1,475
0
python,optimization,premature-optimization,python-import
No, don't do this. In a normal python execution environment on the web (mod_wsgi, gunicorn, etc.) when your process starts those imports will be executed, and then all subsequent requests will not re-execute the script. If you put the imports inside the functions they'll have to be processed every time the function is called.
0
0
0
0
2010-11-02T18:10:00.000
5
1.2
true
4,080,749
0
0
1
3
In a framework such as Django, I'd imagine that if a user lands on a page (running a view function called "some_page"), and you have 8 imports at the top of module that are irrelevant to that view, you're wasting cycles on those imports. My questions are: Is it a large enough amount of resources to make an impact on a high-traffic website? Is it such a bad practice to import inside of a function for this purpose that it should be avoided at said impact? Note: This could be considered premature optimization, but I'm not interested in that argument. Let's assume, for the sake of practical theory, that this is a completed site with loads of traffic, needing to be optimized in every way possible, and the application code, as well as DB have been fully optimized by 50 PhD database admins and developers, and these imports are the only thing left.
Python - optimize by not importing at module level?
4,080,821
4
5
1,475
0
python,optimization,premature-optimization,python-import
1) The answer is no. Django/Python is not like PHP. Your whole module will not be reinterpreted with each pageview like happens with PHP includes. The module will be in memory and each page view will make a simple function call to your view. 2) Yes, it will be a counter-optimization to make imports at the view level.
0
0
0
0
2010-11-02T18:10:00.000
5
0.158649
false
4,080,749
0
0
1
3
In a framework such as Django, I'd imagine that if a user lands on a page (running a view function called "some_page"), and you have 8 imports at the top of module that are irrelevant to that view, you're wasting cycles on those imports. My questions are: Is it a large enough amount of resources to make an impact on a high-traffic website? Is it such a bad practice to import inside of a function for this purpose that it should be avoided at said impact? Note: This could be considered premature optimization, but I'm not interested in that argument. Let's assume, for the sake of practical theory, that this is a completed site with loads of traffic, needing to be optimized in every way possible, and the application code, as well as DB have been fully optimized by 50 PhD database admins and developers, and these imports are the only thing left.
Python - optimize by not importing at module level?
4,080,836
5
5
1,475
0
python,optimization,premature-optimization,python-import
Yes, it is a bad practice to import at the function level. By using smarter imports at the top of the module, you create a one time, small cost. However, if you place an import in a function you will suffer the cost of the import each time that function is run. So, rather than import in the function, just import at the top of the module. A few things you can do to clean up and improve your imports: Don't use wild imports e.g. from x import * Where possible, just use a normal import e.g. import x Try to split your code up into smaller modules that can be called separately, so that fewer imports are made Also, placing imports at the top of the module is a matter of style. There's a reason why PEP 8 says that modules need to be imported at the top. It's far more readable and maintainable that way. Finally, some imports at function level will cause compatibility issues in the future, as from x import * is not valid Python 3.x at function level.
0
0
0
0
2010-11-02T18:10:00.000
5
0.197375
false
4,080,749
0
0
1
3
In a framework such as Django, I'd imagine that if a user lands on a page (running a view function called "some_page"), and you have 8 imports at the top of module that are irrelevant to that view, you're wasting cycles on those imports. My questions are: Is it a large enough amount of resources to make an impact on a high-traffic website? Is it such a bad practice to import inside of a function for this purpose that it should be avoided at said impact? Note: This could be considered premature optimization, but I'm not interested in that argument. Let's assume, for the sake of practical theory, that this is a completed site with loads of traffic, needing to be optimized in every way possible, and the application code, as well as DB have been fully optimized by 50 PhD database admins and developers, and these imports are the only thing left.
feature mobile phone tracking application
4,084,073
1
0
1,349
0
python,security,mobile
As far as I know, there is no way to get Python code running on that kind of mobile platform. Try looking up JavaME and/or Brew. Further, you will need the carrier and device maker to allow your app the get access to the phone's GPS information. This is not a given on the low-end devices. As a first step, most carriers have a free developer relation program. Sign up there and you will have access to many forums with experts in the field. Good luck. :)
0
0
0
0
2010-11-02T19:22:00.000
1
1.2
true
4,081,333
0
0
1
1
I would like to build a mobile phone tracking application for feature phones which have minimum of gprs connectivity. I would like a user to log in to the application and be able to see the location of their phone through google maps. Any resources or information will be highly appreciated. I would preferably use python.
Great flask / other python micro framework code I could learn from
4,083,522
0
0
1,700
0
python,web-applications,flask
IMHO your time would be better invested learning something like Django, because much of what you could improve in a micro framework is already builtin on a bigger framework.
0
0
0
0
2010-11-03T01:07:00.000
2
0
false
4,083,440
0
0
1
1
I'd like to look at some good web-app code written in python, just so I can learn some of the patterns / see how I can improve my code. I've already googled around a bit, used google code search and run a search on github too - but haven't come across a well built, comprehensive app. Perhaps a book could work as well. Basically, I'm just trying to find a way to learn the basic programming patterns for web-applications. Any suggestions?
Issues when writing a medium/large system
4,083,588
1
1
178
0
java,python,ruby,system,enterprise
You make a valid point in saying that Java is more suited to enterprise software. That's really where Java shines: it works very well for enterprise programming. However, your gripes about the tools in Python and Ruby are unfounded. PyDev for Eclipse takes full advantage of the same features that you would enjoy if you were developing in Java. Ruby has a similar plugin for Eclipse. Unit testing frameworks like pyunit, nose, and others exist for both languages (and I believe PyDev has support for unit tests). Also, just like a Java compiler would catch an error at compile time, a Python script will give syntax errors before you run it, along with an (IMO) much more understandable error system than a Java compiler. Since Python and Ruby are scripting languages, their area of expertise lies more in small tasks, rapid development, and using frameworks like Django or Rails. So yes, more heavy-duty languages like Java are great for enterprise, but there's something to be said for the elegance and ease of use of Python and Ruby.
0
0
0
0
2010-11-03T01:32:00.000
3
0.066568
false
4,083,554
1
0
1
3
There is some hype with languages like Python (that I like very much) and Ruby but I was writing a medium-size system in Python and feel the lack of some tools that I would have if I was using Java: Eclipse features, JUnit integration and some language-features like catching some errors in compile time. Some people says that Java is dead as a language. But large important software are written in Java: Hadoop, Lucene and many others. Is Java a better language than Python or Ruby for medium/large infrastructure software like these?
Issues when writing a medium/large system
4,083,633
0
1
178
0
java,python,ruby,system,enterprise
All much of a muchness really. There are features in Python/Ruby that your aware of that make them a more appealing offering than say Java. Static typing can be your best friend most of the time, and a pain for the other. Lack of tooling is related to adoption. Java/c# has a larger adoption. Corporates/Enterprises and medium to large organizations, like to procure solutions with contracts as opposed to technical merits. From experience Python does have some speed issues, I can't comment on Ruby, but I imagine that if your applications require dedicated speed I would not use python. Also threading and multi-core processing is not as good as it could be in python, although 2.7 seems to improve a lot of the old problems, I think the GIL problem still remains for threading. My only comment on Java is that it now has Oracle behind it, and depending where your sitting and how you like Oracle, might change your attitude to Java. especially if your designing for Open Source solutions.
0
0
0
0
2010-11-03T01:32:00.000
3
0
false
4,083,554
1
0
1
3
There is some hype with languages like Python (that I like very much) and Ruby but I was writing a medium-size system in Python and feel the lack of some tools that I would have if I was using Java: Eclipse features, JUnit integration and some language-features like catching some errors in compile time. Some people says that Java is dead as a language. But large important software are written in Java: Hadoop, Lucene and many others. Is Java a better language than Python or Ruby for medium/large infrastructure software like these?
Issues when writing a medium/large system
4,083,662
1
1
178
0
java,python,ruby,system,enterprise
This kind of question can get very argumentative... For enterprise software most of time the key factor is political, not technical. If you own the business, stick with the technology that best fits your vision. If not, use Java - it is politically safer. On the technical field, it is almost a tie.
0
0
0
0
2010-11-03T01:32:00.000
3
0.066568
false
4,083,554
1
0
1
3
There is some hype with languages like Python (that I like very much) and Ruby but I was writing a medium-size system in Python and feel the lack of some tools that I would have if I was using Java: Eclipse features, JUnit integration and some language-features like catching some errors in compile time. Some people says that Java is dead as a language. But large important software are written in Java: Hadoop, Lucene and many others. Is Java a better language than Python or Ruby for medium/large infrastructure software like these?
Is Django 1.2.3 competable with Python 2.6.5
4,085,840
3
0
102
0
python,django
Yes. You're having other problems.
0
0
0
0
2010-11-03T09:55:00.000
1
1.2
true
4,085,826
0
0
1
1
Just curious to know, Test module won't work properly with django 1.2.3 when update from django 1.1.1 (now on python 2.6.5)