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
How to format multiple python datetime instances to a simple format?
9,356,001
2
1
169
0
python,django,datetime,pattern-matching
It sounds like something that is fundamentally "business logic." For example, if the dates happen to all be Easter on consecutive years, do you expect that to be picked up? What about if they are all the last day of Hanukkah? This isn't likely to be something that's handled by a language or library directly--you'll need to write the logic and rules yourself, I imagine. There's definitely room to be innovative here--think about how you can express the rules in a uniform way...look at the existing timezone database and other such existing software for inspiration (or warnings of what to avoid!).
0
0
0
0
2012-02-20T03:48:00.000
2
1.2
true
9,355,952
1
0
1
1
I've got a Django app that needs to take a list of multiple datetimes and print out a simple string that explains what the pattern is. Example: With 3 datetime instances for Monday, Wednesday, and Friday at 3pm, the simple output would be something like Monday, Wednesday, Friday at 3:00pm With 3 datetime instances of the 4th of every month, the output would be The 4th of every month I searched and didn't find anything built into Python or Django, but does anyone know of any open source scripts that can do something similar? The only way I would know of doing it is manually trying to match the patterns of the list of datetimes and that sounds like a lot of if ... else ... statements.
How can i print unhandled exception to the Console instead of the Browser in Django?
9,356,177
10
3
408
0
python,django
Run the server with --traceback option and set DEBUG=False in settings.py. You will get the traceback on console.
0
0
0
0
2012-02-20T04:07:00.000
2
1.2
true
9,356,053
0
0
1
1
I got 500 errors in Django console but it doesn't print any information to the Console about the error. How can i print the detail to Console ?
Deploying a Python Script on a Server (CentOS): Where to start?
9,357,006
1
1
865
1
python,django,centos
Copy script to server test script manually on server set cron, "crontab -e" to a value that will test it soon once you've debugged issues set cron to the appropriate time.
0
1
0
0
2012-02-20T06:14:00.000
3
0.066568
false
9,356,926
0
0
1
1
I'm new to Python (relatively new to programing in general) and I have created a small python script that scrape some data off of a site once a week and stores it to a local database (I'm trying to do some statistical analysis on downloaded music). I've tested it on my Mac and would like to put it up onto my server (VPS with WiredTree running CentOS 5), but I have no idea where to start. I tried Googling for it, but apparently I'm using the wrong terms as "deploying" means to create an executable file. The only thing that seems to make sense is to set it up inside Django, but I think that might be overkill. I don't know... EDIT: More clarity
AppEngine python send email api is marked as SPAM by Gmail email reader
9,374,887
1
3
691
0
python,google-app-engine,email,gmail,spam-prevention
My guess would be that the content of the mail looks "spammy" for Google, but you can do some things that might help you. I would suggest you, since this is a confirmation mail, add another admin for your app an email like: [email protected] and use that one for the confirmation emails. Add more text to the body and include the unsubscribe links as well, so your users will have the possibility to not receive more email from your app. Maybe you wouldn't like the last part, but you have to give that options to your users, so this email won't be marked as SPAM.
0
1
0
1
2012-02-20T19:16:00.000
1
0.197375
false
9,367,049
0
0
1
1
We send email using appengine's python send_mail api. Is there any way to tell why an email that is sent to only one recipient would be marked as SPAM. This seems to only happen when appengine's python send_mail api sends to Gmail. In our case we are sending email as one of the administrators of our appengine application. And the email is a confirmation letter for an order that the user just purchased, so it is definitely NOT SPAM. Can anyone help with this? It seems odd because it is only GMail users that seem to be reporting this issue and we are sending from appengine (All Google servers) I love Google but sometimes Google is stricter to itself than to others :) I've added the spf TXT record to DNS such as "v=spf1 include:_spf.google.com ~all" (I'm hoping that will help) I've tried to add a List-Unsubscribe header to the email but it seems app engine python send mail does not support this header. Thanks, Ralph
ISO-8859-1 Not working on IE
9,370,450
4
3
1,203
0
python,html,utf-8,iso-8859-1
It is better to use UTF-8. Note that "iso-8859-1" is a common mislabeling of "windows-1252", also known as "cp1252". Try being more explicit and see if this resolves your issues.
0
0
1
1
2012-02-21T00:08:00.000
2
0.379949
false
9,370,343
0
0
1
2
I am working on some programs in spanish, so I need to use accent marks. This is why I use # -*- coding: iso-8859-1 -*- and <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> on all my programs (python). I tested in chrome,firefox and safari and they all work puttin the accent marks. The only one that does not work is IE8. It does not apply the accent mark, and add some other character instead. Does anyone know if there is a problem with IE8? Is it better to use UTF-8 instead?
ISO-8859-1 Not working on IE
9,370,369
2
3
1,203
0
python,html,utf-8,iso-8859-1
Yes, it is better to use UTF-8 instead. Your question really cannot be answered unless you also provide the bytes that you are sending.
0
0
1
1
2012-02-21T00:08:00.000
2
1.2
true
9,370,343
0
0
1
2
I am working on some programs in spanish, so I need to use accent marks. This is why I use # -*- coding: iso-8859-1 -*- and <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> on all my programs (python). I tested in chrome,firefox and safari and they all work puttin the accent marks. The only one that does not work is IE8. It does not apply the accent mark, and add some other character instead. Does anyone know if there is a problem with IE8? Is it better to use UTF-8 instead?
Ruby equivalent of Sphinx documentation generator?
37,973,198
0
6
3,534
0
ruby,markdown,documentation-generation,python-sphinx,restructuredtext
Another couple of options would be to use Middleman which is a static site generator that accepts either Kramdown or Markdown as input. There are also frameworks that are designed specifically for technical documentation that use Middleman (both of which are on GitHub) including lord/slate and pnerger/dpslate (the later is a fork of the former and provides some enhancements that were not appropriate for pulling). The Slate format provides a format for documentation that includes many of the features of Sphinx with some additional enhancements. It features a three-pane view of a document which includes an automatically generated Table of Contents, a Main center body, and then sample code panel to the right. Like Sphinx the sample code has syntax highlighting.
0
0
0
0
2012-02-21T04:29:00.000
3
0
false
9,372,188
0
0
1
1
Ruby has a few good document generators like Yard, rDoc, even Glyph. The thing is that Sphinx does websites, PDF's, epub, LaTex...etc. It does all these things in restructuredtext. Is there an alternative to this in the Ruby world? Maybe a combination of programs? If I could use Markdown as well that would be even better.
Send image as an attachment in browser
9,378,819
1
4
219
1
python,browser,flask
You can force the contents to be a downloadable attachment using http headers. In PHP that would be: $fileName = 'dummy.jpg'; header("Content-Disposition: attachment; filename=$fileName"); Then, the script dumps the raw contents of the file.
0
0
0
0
2012-02-21T13:46:00.000
2
0.099668
false
9,378,664
0
0
1
1
I have a static folder that is managed by apache where images are stored. I wonder if it's possible by configuring apache to send all files from that folder as downloadable files, not opening them as images inside browser? I suppose I can do it by creating a special view in Flask, but I think it would be nicer if I could do it with some more simple solution.
How to keep track of all the components used by my Django app
9,379,383
7
1
100
0
python,django
Use virtualenv. Create a virtualenv, activate it, install what you need, then do pip freeze > requirements.txt to create a file listing all your requirements. Then on your new machine (also inside a virtualenv) you can do pip install -r requirements.txt to reinstall all those libraries.
0
0
0
0
2012-02-21T14:31:00.000
1
1.2
true
9,379,307
0
0
1
1
I've been developing a Django app and in the process I installed a couple of component using pip (e.g. pip install django-ajax-selects). I just realized that those components aren't installed in my app directory but somewhere which is machine specific. First, how do I keep track of all the components I installed. Second, how do I install those component in my app directory so that I can move the code from machine to machine without having to do "pip install ...". Thanks!
How to make a variable accessible across all pages in HTML / Template (Django)..?
9,381,932
0
2
487
0
javascript,python,html,django
Well, presumably you are dealing with form posts whenever you want to access the option you refer to. You could either have your whole page be contained by a form, or use javascript to set a hidden field within your main form which is submitted. You can then access it as a raw property of the POST object, or bind a Form object to handle it.
0
0
0
0
2012-02-21T17:02:00.000
2
0
false
9,381,772
0
0
1
1
I am using Django-Python for my project..I have created a "Master HTML page" and all other pages extends this master page.. There is a Drop down (Select Menu) in Master page..and i want to access the value of selected option across all Django Function and views.. How can i achieve that..??
How can I detect Heroku's environment?
41,711,924
2
42
13,817
0
python,django,deployment,heroku,environment
The most reliable way would be to set an environment variable as above. If that's not possible, there are a few signs you can look for in the filesystem, but they may not be / are not foolproof Heroku instances all have the path /app - the files and scripts that are running will be under this too, so you can check for the presence of the directory and/or that the scripts are being run from under it. There is an empty directory /etc/heroku /etc/hosts may have some heroku related domains added ~ $ cat /etc/hosts <snip>.dyno.rt.heroku.com Any of these can and may change at any moment. Your milage may vary
0
0
0
0
2012-02-21T18:58:00.000
7
0.057081
false
9,383,450
0
0
1
1
I have a Django webapp, and I'd like to check if it's running on the Heroku stack (for conditional enabling of debugging, etc.) Is there any simple way to do this? An environment variable, perhaps? I know I can probably also do it the other way around - that is, have it detect if it's running on a developer machine, but that just doesn't "sound right".
Plone: Query Archetype content items/objects inside a particular folder during content submission
9,405,455
0
0
153
0
python,plone,archetypes
Alternative 1: Use PloneFormGen, make a form with a button and an action adapter. The button is called "Apply". The action adapter has a python script that checks if user has already applied, if so redirects to edit view of existing item, if not calls invokeFactory on the Applications folder. You may want to hide the "Add content" menu, possibly simply with CSS for that location. Alternative 2: Make an event handler that intercepts creating content on the folder. Might also work with a content rule. Try a content rule and see when it kicks in, otherwise you can make an event handler that can intercept at the right time. One can start with listening for zope.event (I believe it's called or somesuch) which is the base class for all events and log the events generated when you add content. Pick an event the seems right and add python code that redirects to edit view of existing item or just lets the content creation process go on if the user has not already applied.
0
0
0
0
2012-02-22T07:15:00.000
1
0
false
9,390,586
0
0
1
1
Is it possible to access or navigate saved content items under the same folder during every content submission so that every content submitted must be verified to avoid submission of content that already exists? I have application content type where members can submit their applications but shouldn't accept applications more than one per member. If yes, please help me. Thanks in advance.
Does django AppDirectoriesFinder looks in compressed files?
9,406,387
0
0
213
0
python,django
Looks like Django does not look inside zipped eggs. But you can make your own ZipFileFinder based on Django's FileFinder, I think it will not be very much to code.
0
0
0
0
2012-02-22T09:15:00.000
1
0
false
9,391,963
0
0
1
1
I have several third party django apps downloaded from pip as python eggs. Some of them have zip-safe flag set so they are compressed. I've noticed that django collectstatic command can't find static files from compressed eggs. Is there any posibility to make django taking staticfiles out of zipped eggs?
python 2.7 import a class from the same directory
9,413,623
1
0
2,369
0
python,python-2.7
Because there is an order in which Python searches for models. Amongst the paths Python looks for is your current directory (but not the directory above it). When you are inside your blimp folder there is no blimp.models, only a models. The solution is to always run your code from one directory up (e.g. python -m blimp.stuff).
0
0
0
0
2012-02-23T12:58:00.000
2
0.099668
false
9,413,559
1
0
1
1
I have a folder blimp with an __init__.py, models.py and views.py When I import from outside the folder I use from blimp.models import .. but inside folder it gives an import error unless I use from models import .. I was wondering why this is? Thanks
Show different profile based on user type
9,421,485
1
1
225
0
python,django
Create a profile model and link the user to this profile model. (via a foreign key) The profile model will then have different attributes for different behaviours. These different behaviours would then be exposed in the web application either by branching the template (as you say using if in the template) or returning different data to the template or being sent to javascript functions in the font end to modify behaviour Another alternative is to direct users to different pages based of there profile. The challenge with this is different urls will be needed to different users. This may lead to lots of code duplication.
0
0
0
0
2012-02-23T21:09:00.000
3
0.066568
false
9,421,345
0
0
1
1
I have two types of users. After a user logs in, I take the user to their user profile at /profile Based on the type of user, their profile may contain different navigation items and forms. Is there an easier way to construct the navigation based on the user type instead of putting {% if %} tags everywhere in the template.
What is the best way to run a django project on aws?
9,424,119
11
5
2,360
0
python,django,deployment,amazon-web-services
It depends on your configuration. We are using the following stack for our environment on Rackspace, but you can setup the same thing on AWS with EC2 instances. Ubuntu 11.04 Varnish (in memory cache) to avoid disk seeks NginX to server static content Apache to server dynamic content (MOD-WSGI) Python 2.7.2 with Django Jenkins for our continuous builds GIT for version control Fabric for the deployment. So the way it works is that a GIT push to the origin repository is being polled by Jenkins. Jenkins then pulls the changes down from the origin. Builds a Python Egg, runs Unit tests, uses Fabric to deploy this egg to the environments necessary and reloads the Apache config to make sure the forked Apache processes are picking up the new Python egg. Hope this helps.
0
0
0
0
2012-02-24T00:27:00.000
3
1.2
true
9,423,620
0
0
1
1
How should the project be deployed and run. There are loads of tools in this space. Which should be used and why? Supervisor Gunocorn Ngnix Fabric Boto Pip Virtualenv Load balancers
Google App Engine - prohibitively slow and expensive backup and restore?
13,692,611
5
11
1,978
0
python,google-app-engine,backup,restore
Bet you've found a solution by now Yasser, but for anyone else ending up here from Google, here's an updated answer: The backup option in the appstore admin has been upgraded to support both datastore and cloud storage. It also uses mapreduce to do the backup, which makes the query much lighter on the system.
0
1
0
0
2012-02-24T10:48:00.000
4
0.244919
false
9,429,436
0
0
1
1
After working on several GAE apps, some of which are being used for production, I have come to the conclusion that on this platform, backing up your production data is slow enough and expensive enough for us to transition to some other cloud based technology stack. In one of our production apps, we have around a million entities with an average size per entity of 1KB. So the total size of the data is around a GB which should not be a big deal, right? Here is the output of the bulkloader tool after fetching the entities from the app engine with default options: [INFO ] 948212 entities (608342497 bytes) transferred in 47722.7 seconds That is almost 13 hours. So if we wanted to set up an hourly backup system for our production data, that would be way beyond impossible with the current GAE toolset. The cost is another story. I tried using the datastore admin to copy entities to a different app which i thought we could use for backup. I first set the budget to $2 per day which quickly ran out at around 5000 entities, then i increased the budget to $10 per day which ran out again without being anywhere close to replicating the million entities. I obviously dont intend to spend $100 every time i need to back my 1 GB data up neither do i want to wait for hours (or even days) just so that my data would be backed up. So either I dont know something or Google App Engine is currently just an impractical way to write scalable production quality apps of meaningful size that can be easily backed up and restored. Is there a fast and cost-effective way to backup your data from a GAE app?
Generating DOC (and DOCX) templates using Python or Java with absolute positioned boxes
9,431,308
1
0
1,110
0
java,python,ms-word,docx,doc
Anything you can do with word, you can do with the word com object. Install PythonWin. Use the object browser under "Tools->COM browser" to find what you need.
0
0
0
0
2012-02-24T12:31:00.000
3
0.066568
false
9,430,829
0
0
1
1
For a web-to-print we need to generate a .doc (Microsoft Word 2003+) compatible templates/documents where we need to position some data inside the document (basically we need to auto-generated letter heads for address, phone, contact information etc.). Which Python or Java based solutions can be used here that providing support for absolute positioning of text boxes in .doc (perhaps even through .DOCX). We tried: XFC (FO-based which does not support absolute positioning) and tried Aspose Words for Java (also no support for absolute positioning). Money does not play a major role. The solution has to work and it must not be open-source. Any more options?
Update python in server running centos/whm?
9,775,582
0
1
2,583
0
python,django,centos,cpanel,yum
You can install any version of python from source as long as you don't overwrite cPanel's python 2.4 installation at /usr/bin. To do this, use the -prefix= option when you configure the python 2.x or python 3.x source for build.
0
1
0
0
2012-02-24T17:29:00.000
4
0
false
9,435,259
0
0
1
2
I have a server which is running CentOS with cpanel/whm. Otherwise, it is pretty much a standard set up. My problem is that such server is running python 2.4 and I need python 2.6 or later. How do I upgrade without breaking anything? By the way, I currently have a django application running on that server, which I would also like to move to python 2.6 without breaking it. Is there anything extra that I have to do to do that?
Update python in server running centos/whm?
10,049,589
0
1
2,583
0
python,django,centos,cpanel,yum
The simplest way to install an alternate version of Python is to download the source and compile it. When you've finished running ./configure and make, you'll want to install using make altinstall, with python 2.6 you'd end up with an interpreter named python26
0
1
0
0
2012-02-24T17:29:00.000
4
0
false
9,435,259
0
0
1
2
I have a server which is running CentOS with cpanel/whm. Otherwise, it is pretty much a standard set up. My problem is that such server is running python 2.4 and I need python 2.6 or later. How do I upgrade without breaking anything? By the way, I currently have a django application running on that server, which I would also like to move to python 2.6 without breaking it. Is there anything extra that I have to do to do that?
upload file with python script in plone
9,456,924
1
2
890
1
python,plone,zope
You are not saving the file on the filesystem, but in the Zope object database. You'd have to use python code (not a python script) to open a filepath with the open built-in function to save the data to.
0
0
0
0
2012-02-25T18:27:00.000
1
0.197375
false
9,446,769
0
0
1
1
I am using plone to build my site. In one page template, I have the <input type="file" name="file"> and this form: <form method="post" action="addintoDb" enctype="multipart/form-data" The addintoDb is a python script that save my information into db:context.addParam(name=request.name, path=request['file']). in my db i have name and in the path: <ZPublisher.HTTPRequest.FileUpload instance at 0x081F98C8> but i want to have the put where the file was uploaded (like c:...) I hope somebody can help me.
Do HTML5 mobile app run on server and are accessed via web browser of sorts?
10,339,850
1
1
1,089
0
android,python,html,cordova,titanium
PhoneGap: Simply put your HTML(5), JavaScript and CSS code. You can use 3rd party JavaScript libraries like jQuery, MooTools, etc. You need to code or use libraries to get native feel/UI look. Nothing much different than straight way. PhoneGap just gives you additional mobile features and events which you can bring native features which you can use in your JavaScript code, like accelerometer orientation, contact list, camera, etc. Titanium Mobile: It has custom JavaScript API which your code is compiled to "native" code. You can also use WebView UI component to include your HTML(5), JavaScript and CSS code into application. You can bridge native API to your JavaScript code running in WebView with firing custom events (see Titanium.App.fireEvent and Titanium.UI.WebView.evalJS methods in documents).
0
0
0
0
2012-02-26T07:03:00.000
1
0.197375
false
9,451,214
0
0
1
1
I don't have much experience developing native mobile apps. But I am in need of developing an app that runs in all mobile platforms. I came across Titanium and Phonegap as possible solution. And I am not sure how they work? Is it basically that you create a web-app that runs on server. And PhoneGap/Titatnium simply wrap it up inside a custom browser app. So, instead of user accessing your website user actually installs your app? But behind the scenes, this installed app is simply a browser that loads your webapp in the background? Is that it? Let's say you are developing a "store locator" app. Say, you list ALL Wal-Mart. And user can search for them by zipcode, intersection, address. Results are displayed as text list and also plotted on a map. Admin can add more and more stores. So, not just Wal-Mart, but we can also add Kroger, Safeway, Costco. Now, if I were to create a web app (Python/Django) for this. How would I port this into a mobile app? I am thinking all I've to do is: -> limit the output to say 320px (my webapp usually uses 960px) -> use HTML5 instead of HTML -> somehow wrap this up using Titanium/PhoneGap -> User installs this Titanium thing -> When user opens this app, it simply loads my mobile site(?) Is this it? I'd basically be developing a website in Python/Django? I know Titatinum/PhoneGap also have JavaScript API that may allow me to access phone's GPS, Acclerometer etc. So, basically, I am developing a web-app (it could be php, python, ruby on rails etc.) and I am using some JS libraries to get access to phone's hardware? Oh, and, if the phone doesn't have internet access, the app will simply not load. Correct? I keep hearing you can use JavaScript, HTML5 to create apps. But JS is for client side stuff. A lot of apps would require backend work. For eg, this store locator script. I'd need to store list of stores somewhere (DB). So, I can't possibly use JS for querying my backend DB. I'd have to write some sort of Python/Django app for that. I don't think there is anyway to simply install do this in JS. Finally, user will never have to upgrade the app. Correct? Behind the scenes, it's just a website. So, when I roll-out new features, I simply update my website. All user is doing is opening my website in a titanium-browser. The browser looks like a native-app but it's just a browser. Correct?
How to get logged in user in django views across different apps
9,459,943
1
1
229
0
python,django,views,request
If applications placed in one project (work in one site) doesn't matter what application. But if applications runs in different sites you need, for example, shared between sites session storage and, i think, user table.
0
0
0
0
2012-02-27T03:44:00.000
1
0.197375
false
9,459,780
0
0
1
1
I have a django application called 'main'. user authentication and everything seems fine. And I created a new app called 'upload' from startapp command. user can login on 'main' app but I can not get the logged in user from request.user on views of another app ('upload' app). It returns Anonymous user all the time. any way to get the logged in user? many thanks in advance.
Password Protect Static Page AppEngine HowTo?
9,461,964
2
0
1,804
0
python,google-app-engine,.htaccess,openid,.htpasswd
AFAIK, GAE does not support such setup (static password after OpenID login). The only way I see to make this work would be to serve static content via your handler: Client makes a request for static content Your handler is registered to handle this URL Handler checks is user is authenticated. If not, requests a password. When authenticated, handler reads static file and sends it back to user.
0
1
0
0
2012-02-27T06:49:00.000
2
0.197375
false
9,461,085
0
0
1
1
So I'm working with AppEngine (Python) and what I want to do is to provide OpenID Login setting a Default provider so the user can Log-In without problems using that provider. The thing is, I want to prompt the user a Password right after they login in order to show static content (HTML Pages); If the user doesn't enter the correct password then I want to redirect them to another page. The protection has to be server side please :) Any Ideas?? P.S. I'm seeking for a solution similar to ".htaccess/htpasswd" but for app engine.
Import Error: No module named django
47,015,891
47
30
170,766
0
python,django,centos,pythonpath
I had the same error, and this fix my issue python -m pip install django :) Done!
0
0
0
0
2012-02-27T08:48:00.000
8
1
false
9,462,212
0
0
1
2
I am using centos linux. I had python 2.6 with django and now i upgraded to python 2.7. Python 2.6 is located in /usr/lib/python2.6. Python 2.7 is located in /usr/local/lib/python2.7. They both have site-packages directory and they both contain django 1.2. If i run python i get the 2.7 version. My problem is that if try to import django i get ImportError: No module named django I am not sure where is my PYTHONPATH defined and if this is what i need to change. anyone ? i ended up making a symbolic link to the 2.6 site-packages directory.
Import Error: No module named django
66,738,274
1
30
170,766
0
python,django,centos,pythonpath
python3 -m django --version1 for me it was that^
0
0
0
0
2012-02-27T08:48:00.000
8
0.024995
false
9,462,212
0
0
1
2
I am using centos linux. I had python 2.6 with django and now i upgraded to python 2.7. Python 2.6 is located in /usr/lib/python2.6. Python 2.7 is located in /usr/local/lib/python2.7. They both have site-packages directory and they both contain django 1.2. If i run python i get the 2.7 version. My problem is that if try to import django i get ImportError: No module named django I am not sure where is my PYTHONPATH defined and if this is what i need to change. anyone ? i ended up making a symbolic link to the 2.6 site-packages directory.
Using QWebFrame.setContent() with unicode (Python+PySide)
9,470,209
1
0
284
0
python,pyside,qwebpage
The way to get a byte array out of a unicode is to encode it.
1
0
0
0
2012-02-27T18:25:00.000
1
1.2
true
9,470,170
0
0
1
1
I'm using QWebKit to render a a pdf-page. Untill now, I used setHtml(), to feed the html code to the QMainFrame and then render() to print the content or export it to pdf. So far so good, but I want to use setContent() to include inline-svg-images to the frame, which get not displayed, using setHtml(). But setContent() only accepts QByteArray, and the html-Code is in unicode. How do I feed the unicode string to setContent()?
Ipython in pydev interactive debugging console(eclipse)
9,502,749
0
4
1,810
0
pydev,ipython
Actually, Eclipse itself can have multiple consoles open at the same time... if you want, you can create multiple console views and pin a different console to each view (if you don't pin the console, one console will be shown on top of the other and you'll have to do the switching from one to the other manually). As it is now, the debug console is not the same as the interactive console (it's a simpler version because of issues with the eclipse integration, although there are plans to be able to attach an interactive console to a debug session). So, what you described is what should really happen (not really a bug).
0
0
0
0
2012-02-28T01:18:00.000
2
0
false
9,475,014
1
0
1
1
I have ipython working in pydev when using the normal interactive console, however when entering debug mode the console reverts to the standard pydev console. If I close this console and re-open it, ipython returns and I can use it as normal. Am I missing something, or is this a bug? -Eric
Can I turn off the "no_cookies" option in Google App Engine Launcher (version 1.6.2) on Windows?
9,477,977
0
1
650
0
python,windows,google-app-engine,deployment,credentials
The launcher will always prompt you for credentials, it uses the no_cookies flag to make sure the given credentials are passed and not the one stored in the system. What you can do is create a batch file that will deploy the application, you can provide credentials using the --email and --passin flags.
0
1
0
0
2012-02-28T01:24:00.000
1
1.2
true
9,475,063
0
0
1
1
When I deploy an application using the Google App Engine Launcher (version 1.6.2) on Windows, the following command options show in the output window: Running command: "[u'C:\Python27\pythonw.exe', '-u', u'C:\Program Files (x86)\Google\google_appengine\appcfg.py', '--no_cookies', u'[email protected]', '--passin', 'update', u'C:\path\to\project']" I want the launcher to store my application-specific password, and I know that it needs to use a cookie to do that, but for some reason the launcher is defaulting to send the "no_cookies" option. Is there a way to turn this option off?
Do multiple Python interpreters on a server share pages in memory?
9,475,336
1
0
94
0
python,operating-system,multiprocessing
Not on purpose. They let the OS worry about sharing pages between the instances of the library.
0
0
0
0
2012-02-28T01:55:00.000
2
0.099668
false
9,475,290
0
0
1
2
One of the more clever things Android does to conserve memory and increase startup time is share pages between multiple Dalvik interpreters by forking processes from a the zygote process. When an application loads, the static, readonly library code pages are shared between the parent and the child. Does python or multiprocessing do anything on these lines?
Do multiple Python interpreters on a server share pages in memory?
9,475,484
2
0
94
0
python,operating-system,multiprocessing
This is an operating system feature (not a language feature) that at least Linux and probably most OSes offer. It's nothing unique to Android. So yes, Python and multiprocessing do essentially the same thing if you are running on Linux, simply because they use fork() to spawn additional processes.
0
0
0
0
2012-02-28T01:55:00.000
2
1.2
true
9,475,290
0
0
1
2
One of the more clever things Android does to conserve memory and increase startup time is share pages between multiple Dalvik interpreters by forking processes from a the zygote process. When an application loads, the static, readonly library code pages are shared between the parent and the child. Does python or multiprocessing do anything on these lines?
Mixing HTML5 Canvas and Python
9,485,888
2
13
29,496
0
python,django,html,google-app-engine
A viable approach for a rich client widget like this is to use a stack like: [ your javascript user interface ] [ a js lib for your graphics ] backbone.js for managing your objects client side django-tastypie for wrapping your django objects in a RESTful API django for defining your backend
0
0
1
0
2012-02-28T16:27:00.000
3
0.132549
false
9,485,761
0
0
1
2
I have used both of these (Python and HTML5) seperately, however I'm keen to use the full power of Python over the web using HTML5 to draw things and handle the client side of things. I guess I'm looking for avenues to go down in terms of implementation. Here are some things I'd like to do if possible: Have very interactive data, which will need to processed server-side by Python but displayed and locally manipulated by HTML5 Canvas. Clickable components on the HTML5 Canvas which will communicate with the server side. Is there an implementation that people can recommend? I.e. would Google App Engine be any good. Django? Pyjamas? Thanks - apologies if this seems a little vague. I'm asking before trying one path to see if there is a heads-up to save time and effort.
Mixing HTML5 Canvas and Python
9,486,058
4
13
29,496
0
python,django,html,google-app-engine
I do exactly what you have mentioned using Django on the server side and HTML5 canvas/javascript on the client side. I'm pretty happy with the results but would like to point out that what you do with a Canvas on the client side doesn't have anything to do with what you use on the server side for Python.
0
0
1
0
2012-02-28T16:27:00.000
3
0.26052
false
9,485,761
0
0
1
2
I have used both of these (Python and HTML5) seperately, however I'm keen to use the full power of Python over the web using HTML5 to draw things and handle the client side of things. I guess I'm looking for avenues to go down in terms of implementation. Here are some things I'd like to do if possible: Have very interactive data, which will need to processed server-side by Python but displayed and locally manipulated by HTML5 Canvas. Clickable components on the HTML5 Canvas which will communicate with the server side. Is there an implementation that people can recommend? I.e. would Google App Engine be any good. Django? Pyjamas? Thanks - apologies if this seems a little vague. I'm asking before trying one path to see if there is a heads-up to save time and effort.
What should be used to store data in GAE?
9,498,169
0
1
109
0
python,google-app-engine,memcached,google-cloud-datastore
I'd suggest you split your entities in a root entity and a couple linked ones holding each some of the 150 attributes - this way, when you update one attribute, you only need to save one (or two, if the update reflects on the root entity) smaller entities to the datastore instead of a huge one. Use memcache to prevent reads, not to store data that's going to the datastore. Memcache can be flushed and the data there can be destroyed before it hits permanent storage. Going one step further, the grouping of attributes could reflect data that's updated together - say, if you always update street and zipcode together, it makes sense to keep them together in a single structure.
0
1
0
0
2012-02-28T17:16:00.000
3
0
false
9,486,574
0
0
1
3
My web application will have ~150 fields and when value is changed in any field (at least one), I should save changed value. How should I store such values with GAE? Should I save them directly in datastore? Should I use memcache temporarily and then save all values at once in datastore? Or, some other approach should be followed?
What should be used to store data in GAE?
9,487,492
0
1
109
0
python,google-app-engine,memcached,google-cloud-datastore
First of all you should find out how you are going to use your data. Which queries are you planning to make? What is the size of your entities? Datastore is very different from relational databases. That is It doesn't really matter how many properties are changed, because there is no way to update a property on its own. You can only save entity as a whole. I don't know about your use case, but there should probably be a better approach for structuring your data, than having ~150 properties for a single entity. What is your use case? Also having too much properties for an entity may lead to index explosion, or to slow down datastore writes.
0
1
0
0
2012-02-28T17:16:00.000
3
0
false
9,486,574
0
0
1
3
My web application will have ~150 fields and when value is changed in any field (at least one), I should save changed value. How should I store such values with GAE? Should I save them directly in datastore? Should I use memcache temporarily and then save all values at once in datastore? Or, some other approach should be followed?
What should be used to store data in GAE?
9,486,718
3
1
109
0
python,google-app-engine,memcached,google-cloud-datastore
The datastore is your database. Memcache is to store data that's fetched from the datastore and kept temporarily in memory to avoid too many calls back to the database. You should first design your app around the datastore and then use memcache to improve performance. Depending on your programming language of choice (java, python, go) there are many tools out there to help you map objects in your app to the datastore and to use memcache effectively.
0
1
0
0
2012-02-28T17:16:00.000
3
0.197375
false
9,486,574
0
0
1
3
My web application will have ~150 fields and when value is changed in any field (at least one), I should save changed value. How should I store such values with GAE? Should I save them directly in datastore? Should I use memcache temporarily and then save all values at once in datastore? Or, some other approach should be followed?
How to handle merges/conflicts in my git based wiki?
9,489,348
2
1
311
0
python,git,merge,conflict,resolve
Study how other systems (like e.g. ikiwiki) handle these things. Commit requests will come in sequentially. Try to commit them. If there are conflicts or if a commit request is based on a previous HEAD, report that back to the person sending the commit request complete with the differences of the edits with the current HEAD.
0
0
0
0
2012-02-28T19:40:00.000
1
0.379949
false
9,488,543
1
0
1
1
I'm working on a django-based wiki. It has section edit capabilities (the sections being delimited by the markdown headers) and it is using git (a single repo) to store the revisions, via the Git Python library. I'm trying to figure out how I can handle several concurrent edits of the same page (using git-python). Thanks,
GAE-ready asynchronous operations in Python?
9,491,366
1
3
182
0
python,http,google-app-engine,asynchronous,web2py
If you're brave, you might try the Experimental new DB api, NDB. It has async APIs for working with the datastore + URL fetch. If those are the things you hoped to do async-ly, then you're in luck.
0
1
0
0
2012-02-28T23:07:00.000
3
0.066568
false
9,491,227
1
0
1
1
I've got a Python app making 3 different api calls one after another in the same block of code. I'd like to execute these calls asynchronously, and then perform an action when they're all complete. A couple notes: Other answers regarding async actions point to frameworks like Twisted and Celery, but I'm building a Web2Py app for the GAE, so those daemon-based frameworks aren't an option AFAIK. I'm using api wrapper libraries for the various apis, so I'm wondering if there's an async solution that can be implemented at the thread level, rather than the http request level?
How to properly redirect to another site without breaking the browser back button?
9,499,524
2
2
219
0
python,http,redirect,pylons
The correct way is sending HTTP status code 302 instead of 200 and adding Location: <url> to response headers. How to do this depends on the WEB framework you are running your Python app on.
0
0
1
0
2012-02-29T12:27:00.000
1
1.2
true
9,499,173
0
0
1
1
I am trying to make a redirection from a python app to another site. I am currently doing it in the controller which works just fine but breaks the back browser button. I know that a redirection with meta refresh or js, will allow me to add a delay so the user will have time to go back but I read everywhere that these techniques are deprecated and better be avoided. Any thoughts or ideas? Thanks
Django to share login session with Jasperserver
10,683,426
0
0
506
0
python,django,jasperserver
You could, for example, in an iframe, do a post to j_spring_security_check to authenticate the user, that way when you redirect him to the login page, the user would be authenticated
0
0
0
0
2012-02-29T16:10:00.000
2
0
false
9,502,596
0
0
1
1
I have a Django application and I use Jasperserver to generate reports. Can I somehow share the login session from Django to jasperserver to eliminate login step in jasperserver ? Thanks.
Check a SWF's Flash Version and ActionScript version from Python?
9,521,701
0
0
587
0
python,django,actionscript,flash
Hexagonit.swfheader checks Flash version, which is part of Michael's question, but doesn't cover ActionScript version, does it?
0
0
1
0
2012-03-01T04:20:00.000
2
0
false
9,510,565
0
0
1
1
I need to validate an uploaded SWF to ensure it meets certain Flash and ActionScript version limitations. Anyone know a good Python library to parse metadata out of a SWF?
Concurrency handling in python based webapp
9,521,531
6
1
2,325
0
python,multithreading,postgresql,web-applications,concurrency
Flask will execute each request in a separate thread or even in separate processes. The number of threads and processes to spawn is determined by the WSGI server (for example, Apache with mod_wsgi). If you use SQLAlchemy ScopedSessions, the session is perfectly thread-safe. You must not share ORM-controlled objects across threads (but in the large majority of cases, you won't let your objects live longer than a request anyway so this is usually not a concern). In other words, as long as you don't intend to share state between requests other than through the database or cookies, you don't need to worry about concurrency issues. You don't need to create a lock for writing to the database. If you create your own long-lived objects within your application, which you most likely don't need to do, and if those objects communicate or share state with request handling code, then you must take appropriate precautions to avoid synchronization issues (race conditions, deadlocks, use of libraries that are not thread-safe, etc.)
0
0
0
0
2012-03-01T13:26:00.000
1
1.2
true
9,517,054
0
0
1
1
I am developing web app on flask, python, sqlalchemy and postgresql. My question is here regarding concurrency handling in this app. How I wrote the app : I take the example of adding user in database. I post the form and a view is called. I process all the form data and then call add_user(*arg) which uses sqlalchemy code to insert user in database and returns on successful execution and I return the response from the view. What I assumed: Ok now I assumed that my web server (which I have not decided yet) will either spawn a thread or a process if two users are trying to signup at the same time and will handle all the concurreny requirements. Do i need to write threaded code here? By threaded code I mean that before writing I acquire a lock and after write release it. I am pretty new to web development and multithreading/multiprocessing programing and would like some guidance on how write web app which can handle concurrency well. Writing concurrency handling from start is right or this thought should come when a large number of concurrent users are using the webapp. Even If it should be done later I would like some pointers about it. Basically I have no idea about concurrency part of webapp development. If you can point to resources from where I can learn more about it would be really helpful.
django: creating a model for Person who can be Writer or Actor or both
9,517,891
2
1
98
0
python,django,django-models
It sounds like you want each category to have a ForeignKey to Person.
0
0
0
0
2012-03-01T14:22:00.000
3
0.132549
false
9,517,829
0
0
1
2
i am new to both python and Django, trying to create a database that hold general information about people, so i have this: a model for a Person (contain general info). a model for a Category that a person belongs to (a person can be in multiple categories at the same time). each category contain its own extra data (a person who is in "Writers" category might have some books that we want to store in DB) i thought about model sub-classing, but it seems that this will not work if a person can be in multiple categories the same time (especially dynamically) another thought is creating profiles that have OneToOne relationship with the Person model, but i am not sure if it is the best way what is the best/other ways to tackle this?
django: creating a model for Person who can be Writer or Actor or both
9,519,078
0
1
98
0
python,django,django-models
The multiple 1to1 rel is the way to go. Define an ActorProfile model, a WriterProfile model etc, with each having a fk to User. Use some orm magic to load then when necessary. It's basic that the FK is in the profile model, otherwise you'll need to add a new column on the user table each time you need a new kind of profile. As the profiles will be probably somewhat overlapping, I'd suggest to use composition (instead of inheritance), do more profile types which store the common data, and keep the specific profiles for very specific data. EDIT Use a document-based database (mongodb?) and forget about migrations, fixed schemata, artificial joins... You have to think only about structuring the data the way you really need, but the advantages are worth considering.
0
0
0
0
2012-03-01T14:22:00.000
3
0
false
9,517,829
0
0
1
2
i am new to both python and Django, trying to create a database that hold general information about people, so i have this: a model for a Person (contain general info). a model for a Category that a person belongs to (a person can be in multiple categories at the same time). each category contain its own extra data (a person who is in "Writers" category might have some books that we want to store in DB) i thought about model sub-classing, but it seems that this will not work if a person can be in multiple categories the same time (especially dynamically) another thought is creating profiles that have OneToOne relationship with the Person model, but i am not sure if it is the best way what is the best/other ways to tackle this?
cursor and with_cursor() in GAE
9,521,520
0
0
550
1
python,google-app-engine
i am not 100% sure about that but what i used to do is compare the last cursor with the actual cursor and i think i noticed that they were the same so i came to the conclusion that it was the last cursor.
0
1
0
0
2012-03-01T17:47:00.000
3
0
false
9,521,289
0
0
1
1
I am fetching records from gae model using cursor() and with_cursor() logic as used in paging. but i am not sure how to check that there is no any other record in db that is pointed by cursor. i am fetching these records in chunks within some iterations.when i got my required results in the first iteration then in next iteration I want to check there is no any record in model but I not get any empty/None value of cursor at this stage.please let me know how to perform this check with cursors in google app engine with python.
Website to computer communications
9,523,459
0
3
232
0
php,python,web
You can set up a web server also on the remote computer, perhaps using the same software as on the public server, so you do not need to learn another technology. The public server can make HTTP requests and the remote server responds by communicating with the serial device.
0
0
1
1
2012-03-01T20:02:00.000
2
0
false
9,523,147
0
0
1
1
I am working on my senior project at university and I have a question. My advisor and other workers don't know much more on the matter so I thought I would toss it out to SO and see if you could help. We want to make a website that will be hosted on a server that we are configuring. That website will have buttons on it, and when visitors of that website click a certain button we want to register an event on the server. We plan on doing this with PHP. Once that event is registered (this is where we get lost), we want to communicate with a serial device on a remote computer. We are confident we can set up the PHP event/listener for the button press, but once we have that registered, how do we signal to the remote computer(connected via T1 line/routers) to communicate with the serial device? What is this sequence of events referred to as? The hardest thing for us (when researching it) is that we are not certain what to search for! We have a feeling that a python script could be running on the server, get signals from the PHP listener, and then communicate with the remote PC. The remote PC could also be running a python script that then will communicate with our serial device. Again, most of this makes sense, but we are not clear on how we communicate between Python and PHP on the web server (or if this is possible). If any one could give me some advice on what to search for, or similar projects I would really appreciate it. Thanks,
What's the best way to have value object using Django data model?
9,540,376
0
1
676
0
python,json,django-models
Once I dropped the notion of Value Object carried over from JAVA background, and started to focus on what I really want, I found a simple way to get this: to custom build a dictionary in views.py, based on the data coming back from related models. And then add each dictionary to a list bucket and use json dumps prior to rendering JSON feeds.
0
0
0
0
2012-03-01T21:41:00.000
2
0
false
9,524,574
0
0
1
1
Our Django data model objects are nicely mapped to database tables. We want a way to package data from two or more tables into a customized structure, so that we can easily serve it up as JSON feed, having all the attributes and is in the desired format. It is kind of like "value objects" (POJO) in other environment such as JAVA, providing convenience when packaging and displaying data. They should be transient and not persisted in database; yet at the same time contains all the necessary attributes and in the original data types (in Django world this is called "_meta"). Appreciate your reply and suggestions.
how to find the authentication used on a website
9,542,705
0
0
829
0
python,http,authentication,screen-scraping,web-scraping
It's very unlikely that any of the sites you are interested in use basic auth. You will need a library like mechanize that manages cookies and you will need to submit the login information to the site's login page.
0
0
1
1
2012-03-02T05:23:00.000
1
0
false
9,528,395
0
0
1
1
I've been reading about beautifulSoup, http headers, authentication, cookies and something about mechanize. I'm trying to scrape my favorite art websites with python. Like deviant art which I found a scraper for. Right now I'm trying to login but the basic authentication code examples I try don't work. So question, How do I find out what type of authentication a site uses so that I know I'm trying to login the correct way? Including things like valid user-agents when they try to block bots. Bear with my ignorance as I'm new to HTTP, python, and scraping.
First project what should I look out for
9,528,803
2
2
177
0
python,django
The first thing to look out for is overplanning. This, along with overengineering, is even more true for your second project. You have lots of ideas about how this program will behave, but don't get ahead of yourself. Remember what the problem is you want to solve, and try to keep focused on the simplest way to solve that, without tons of options or cases. For example, in its simplest form you want to programmatically add a calendar event, so create a simple html form and the simplest possible back-end to take the user input and add it to a calendar. Don't worry about HIPAA up front, as you're going to make lots of security mistakes anyway, it's better to focus on the functionality for now. Also don't worry too much about the interface, because you're going to decide this version sucks and you need to throw it away at some point. Then (and not a moment sooner) will be the right time to think about the interface, json vs. soap vs. web app, etc. For now, just start building the thing and prove that you can provide the value you believe this will provide.
0
0
0
0
2012-03-02T06:02:00.000
1
1.2
true
9,528,748
1
0
1
1
I want to create a program that will take user input and create a calendar using the input. example: John,Conner 1/3/10 birthday This information will also be sortable by the obvious: last name,first name, date, (other). It will be able to print this information as a list or a calendar. It will have to have exceptions like 1/3/10 is put on the 2nd (because the 3rd is a sat and weekends aren't usable dates) Security is a must as its HIPPA information Possible will be only used by myself on a work computer... but i would like to think others might use it eventually I'm new to programming and have the following under my belt: Learn python the hard way How to think like a computer scientist learn python 3 python for informatics Given what i know the programming part of this doesn't really worry me. I feel like i have done similar if not more difficult things already. with the exception being the user interface setup... err the graphical part the user see's. I don't know how to set that up at all. (i used turtle does that count?) Limitations: I'm not sure what the computers at work are running. If its a server that the computers boot into or what. They are using Internet explorer. So... i have researched some points i know i need to plan ahead about such as: GUI vs web application. --- i'm learning towards web application because I like the eventually seeing something i made get used on a more widespread basis... also i hear that GUI's area a pain. With this in mind i was going to learn Django. But as a newbie i feel I might be sailing into a storm of things i haven't envisioned. And while i understand trail by fire is a good way to learn i feel it also pays to seek advice as to limit yourself... especially when you work 9 to 5 like i do. So after all my to do. Is learning Django a logical next step for my I have in mind? What else might i want to consider..? finally maybe stackoverflow isn't the right spot for these types of questions! if so, where?
How to transfer message between different request in web.py?
9,531,601
0
0
569
0
python,web.py
you can use a Get Variable: web.seeother('/somepage?message=hello') bye
0
0
1
0
2012-03-02T06:39:00.000
2
0
false
9,529,113
0
0
1
1
In web.py, I use web.seeother() to redirect to another page, is there a way to transfer some message to that page too?
Django - Managing page content in Django Admin
9,537,653
0
0
984
0
python,django,django-models,content-management-system,django-admin
I would find out how much they need to change? If they plan a complete redesign every week then you're still looking for an answer. If they just need a dynamic front page then you can split it up into variables and let them edit sections of html. Much safer and less prone to breaking the html.
0
0
0
0
2012-03-02T17:01:00.000
3
0
false
9,537,326
0
0
1
3
I'm new to working with Django and am developing for a client who wants to be able to change page content in the Django Admin. They need to be able to change the html of the index page without editing the files on the server. I know about flatfiles but I'm not sure that's completely what I'm after as I can't display stuff such as Django forms for example. EDIT: Kind of like how a CMS works but without the users/group stuff and be able to use Django View modules such as forms. Any advice? Thanks
Django - Managing page content in Django Admin
9,537,377
0
0
984
0
python,django,django-models,content-management-system,django-admin
I don't believe that is possible at this time. Of course you can edit your models but templates, I think not.
0
0
0
0
2012-03-02T17:01:00.000
3
0
false
9,537,326
0
0
1
3
I'm new to working with Django and am developing for a client who wants to be able to change page content in the Django Admin. They need to be able to change the html of the index page without editing the files on the server. I know about flatfiles but I'm not sure that's completely what I'm after as I can't display stuff such as Django forms for example. EDIT: Kind of like how a CMS works but without the users/group stuff and be able to use Django View modules such as forms. Any advice? Thanks
Django - Managing page content in Django Admin
9,537,635
1
0
984
0
python,django,django-models,content-management-system,django-admin
Honestly, the scope of what you're looking for is too huge to cover in this format. There's a number of ways this could be done, but they're all going to require some work and customization based on the client's needs. Flatpages could work if you allow HTML content and make sure the content is rendered as "safe" in the template. This really only covers the "content" area of the site, though. It wouldn't be wise to use flatpages for an entire site template, including header, sidebar, footer, etc. You could create editable areas. So, you actually create models for things like headers, sidebars, footers, and modules within those areas, and then just pull them into the template as needed. Then, the client is only editing pieces of the template instead of responsible for the whole HTML document. Forms are going to be a challenge, because they require backend-processing that requires a connected view. The client won't be able to just arbitrarily drop in some form code and have a form. But, you could use a third-party service form forms and just embed them in the available content regions. Or, there's a couple of django apps that try to implement a type of "form builder" in the admin. That might somehow let the client add a form via something like the shortcodes used in Wordpress, but you'd likely have to lay down some infrastructure to make that work. At a certain point, stuff like this reaches a point of diminishing returns, though. The only way to allow total customization of the template is to drop down into the actual physical file and make changes there. You can make certain things easier for the client, but ultimately, they either need to scale back their customization needs or deal with the fact that they'll have to work with the filesystem.
0
0
0
0
2012-03-02T17:01:00.000
3
1.2
true
9,537,326
0
0
1
3
I'm new to working with Django and am developing for a client who wants to be able to change page content in the Django Admin. They need to be able to change the html of the index page without editing the files on the server. I know about flatfiles but I'm not sure that's completely what I'm after as I can't display stuff such as Django forms for example. EDIT: Kind of like how a CMS works but without the users/group stuff and be able to use Django View modules such as forms. Any advice? Thanks
Which database engine to choose for Django app?
9,540,685
6
48
41,120
1
python,database,django,sqlite
MySQL and PostgreSQL work best with Django. I would highly suggest that when you choose one that you change your development settings to use it while development (opposed to using sqlite3 in dev mode and a "real" database in prod) as there are subtle behavioral differences that can caused lots of headaches in the future.
0
0
0
0
2012-03-02T20:49:00.000
4
1
false
9,540,154
0
0
1
1
I'm new to Django and have only been using sqlite3 as a database engine in Django. Now one of the applications I'm working on is getting pretty big, both in terms of models' complexity and requests/second. How do database engines supported by Django compare in terms of performance? Any pitfalls in using any of them? And the last but not least, how easy is it to switch to another engine once you've used one for a while?
Global variables in Python and Apache mod_wsgi
9,541,433
3
4
3,538
0
python,apache,mod-wsgi
Web-apps are generally “shared-nothing”. In the context of WSGI, that means you have no idea how many times your application (and the counter with it) will be instantiated; that choice is up to the WSGI server which acts as your app's container. If you want some notion of user sessions, you have to implement it explicitly, typically on top of cookies. If you want persistence, you need a component that explicitly supports it; that can be a shared database, or it can piggy-back on your cookie sessions.
0
0
0
0
2012-03-02T22:31:00.000
2
1.2
true
9,541,301
1
0
1
1
I know there are frameworks that exist, but I am trying to use wsgi directly to improve my own understanding. I have my wsgi handler, and up at the top I have declared a variable i = 0. In my application(environ, start_response) function, I declare global i, then I increment i whenever a button is pressed. It is my understanding that the state of this variable is preserved as long as the server is running, so all users of the web app see the same i. If I declare i inside the application function, then the value of i resets to 0 any time a request is made. I'm wondering, how do you preserve i between a single user's requests, but not have it preserved across different users' sessions? So, a single user can make multiple posts, and i will increment, but if another user visits the web app, they start with i=0. And I know you could store i in a database between posts, but is it possible to just keep i in memory between posts?
In need of a light, changing database/storage solution
9,545,480
1
3
168
1
python,database,flask
You might look at mongoengine we use it in production with flask(there's an extension) and it has suited our needs well, there's also mongoalchemy which I haven't tried but seems to be decently popular. The downside to using mongo is that there is no expire automatically, having said that you might take a look at using redis which has the ability to auto expire items. There are a few ORMs out there that might suit your needs.
0
0
0
0
2012-03-03T08:17:00.000
1
1.2
true
9,544,618
0
0
1
1
I have a Python Flask app I'm writing, and I'm about to start on the backend. The main part of it involves users POSTing data to the backend, usually a small piece of data every second or so, to later be retrieved by other users. The data will always be retrieved within under an hour, and could be retrieved in as low as a minute. I need a database or storage solution that can constantly take in and store the data, purge all data that was retrieved, and also perform a purge on data that's been in storage for longer than an hour. I do not need any relational system; JSON/key-value should be able to handle both incoming and outgoing data. And also, there will be very constant reading, writing, and deleting. Should I go with something like MongoDB? Should I use a database system at all, and instead write to a directory full of .json files constantly, or something? (Using only files is probably a bad idea, but it's kind of the extent of what I need.)
Scraping with JQuery or Python?
9,551,356
0
0
1,586
0
jquery,python,screen-scraping
If I'm reading your question right, you're not trying to build a web app (client- or server-side), but rather a standalone app that simply requests and downloads pages from the Web. You can write a standalone app in JavaScript, but it's not common. The primary use of JavaScript is for code that's going to run in a user's Web browser. For standalone apps, Python is the better choice. And it has very good support (in the form of the urllib2 and related libraries) for tasks like Web scraping. Of course, if your scraping task is relatively simple, you might be better off just using wget.
0
0
1
0
2012-03-03T23:13:00.000
2
0
false
9,550,690
0
0
1
2
So lets say I'm scraping multiple pages (lets say a 1000) on a website. I want to know which language is best to use to scrape those pages with - javascript or python. Further, I've heard about javascript scrapers being faster (due to multiple get requests), but am unsure how to implement this - can anyone enlighten me? Thanks!
Scraping with JQuery or Python?
9,551,757
3
0
1,586
0
jquery,python,screen-scraping
This is just my opinion but I would rank them like this javascript might be the best choice but only if you have a node environment already set up. The advantage of javascript scrapers is they can interpret the js in the pages you're scraping. next is a three way tie between perl python and ruby. They all have a mechanize library and do xpath and regex in a sensible way. Down at the bottom is php. It's lack of a cookie handling library like mechanize (curl isn't great) and it's clumsy dom and regex functions make it a poor choice for scraping.
0
0
1
0
2012-03-03T23:13:00.000
2
1.2
true
9,550,690
0
0
1
2
So lets say I'm scraping multiple pages (lets say a 1000) on a website. I want to know which language is best to use to scrape those pages with - javascript or python. Further, I've heard about javascript scrapers being faster (due to multiple get requests), but am unsure how to implement this - can anyone enlighten me? Thanks!
besides google and bing, what other search engine has an python api?
10,133,419
1
0
332
0
python,search-engine
pySearch is no longer supported, the only way to search yahoo is to use their BOSS API. The BOOS api would require payments for every 1000 queries.
0
0
1
0
2012-03-04T00:16:00.000
2
1.2
true
9,551,108
0
0
1
1
Google and Bing are both free, for Google I use urllib and json to get the results. For Bing i use pyBing. Yahoo requires me to pay per 1000 queries, which I don't want to do for a homework assignment. Is there any other SEs that has a python api? Or has something similar to Google's ajax googleapis?
Overloading DateTimeShortcuts.js in Django
9,768,878
1
0
1,664
0
javascript,python,django
Yeah I had to edit the widget contained in the django install (... site-packages/django/contrib/admin/media/js/admin/DateTimeShortcuts.js). I was getting confused as even when I edited it, it was not working. It was my fault, as even though I was working on a local machine the settings were still pointing to the remote server for the media files, so editing the local didn't show any effect, fixed that and it worked.
0
0
0
0
2012-03-04T11:48:00.000
1
1.2
true
9,554,610
0
0
1
1
Simple question really, is there any programmatic way to over load the "choose a time" options in django for the DateTimeShortcuts.js when used in the admin? The options they present aren't very helpful the last option of the day is noon. I was hoping to have every hour of the day as an option
Setup Cherrypy with Google App Engine
15,619,684
1
1
1,132
0
python,google-app-engine,cgi,wsgi,cherrypy
The problem was that cherrypy was not in the root of the working directory, all of which I uploaded with the app engine tool. Not 100% sure if its the correct way to use GAE but it works.
0
1
0
0
2012-03-04T15:46:00.000
1
1.2
true
9,556,280
0
0
1
1
Can someone please show me how to get cherrypy to work with Google App Engine, I have made applications with cherrypys built in server, but I have no idea how to make an app that works with WSGI and GAE. I have read the documentation for cherrypy and GAE but can't find anything. And I would prefer cherrypy to the webapp2 which is in the GAE example.
Redis and RDBMS coexistence (hopefully cooperation) in Flask applications
9,557,895
3
4
532
1
python,nosql,redis,rdbms,flask
You should have no problem using an ORM because, in the end, it just stores strings, numbers and other values. So you could have a game in progress, and keep its state in Redis, including the players' IDs from the SQL player table, because the ID is just a unique integer.
0
0
0
0
2012-03-04T18:17:00.000
1
1.2
true
9,557,552
0
0
1
1
I'm developing a multi-player game in Python with a Flask frontend, and I'm using it as an opportunity to learn more about the NoSQL way of doing things. Redis seems to be a good fit for some of the things I need for this app, including storage of server-side sessions and other transient data, e.g. what games are in progress, who's online, etc. There are also several good Flask/Redis recipes that have made things very easy so far. However, there are still some things in the data model that I would prefer lived inside a traditional RDBMS, including user accounts, logs of completed games, etc. It's not that Redis can't do these things, but I just think the RDBMS is more suited to them, and since Redis wants everything in memory, it seems to make sense to "warehouse" some of this data on disk. The one thing I don't quite have a good strategy for is how to make these two data stores live happily together. Using ORMs like SQLAlchemy and/or redisco seems right out, because the ORMs are going to want to own all the data that's part of their data model, and there are inevitably times I'm going to need to have classes from one ORM know about classes from the other one (e.g. "users are in the RDBMS, but games are in Redis, and games have users participating in them.) Does anyone have any experience deploying python web apps using a NoSQL store like Redis for some things and an RDBMS for others? If so, do you have any strategies for making them work together?
What is the possibility of using a Python app, deployed online, that has access to a users local disk?
9,561,004
2
0
139
0
python,google-app-engine,web.py
You could create a signed java applet that will run along side the javascript and allow access to local files. You may be able to find an applet already developed that you can call from javascript. You have to be careful with this though because once the user trusts the applet it's installed and any site can call the applet unless the applet code is restricted to a specific site.
0
1
0
0
2012-03-05T02:30:00.000
2
0.197375
false
9,560,950
0
0
1
2
I currently have a local python application that scans a users drive, maps it into a tree and displays this information with javascript. I would really like to try to develop something with a Drop-Box like system to manage drive trees. I have searched and read that App Engine specifically doesn't allow access to a user's local disk. Is there a way to use webpy or something else to access a user's local drive to create a tree directory out of it?
What is the possibility of using a Python app, deployed online, that has access to a users local disk?
9,560,968
4
0
139
0
python,google-app-engine,web.py
You'd have to create a "client" and "server" type of interface to do this. So it wouldn't be a solely JavaScript with Python on the server program. They'd have to have something running on their end as well, communicating in the background. HTML5 allows some local storage, but not what you're looking for.
0
1
0
0
2012-03-05T02:30:00.000
2
1.2
true
9,560,950
0
0
1
2
I currently have a local python application that scans a users drive, maps it into a tree and displays this information with javascript. I would really like to try to develop something with a Drop-Box like system to manage drive trees. I have searched and read that App Engine specifically doesn't allow access to a user's local disk. Is there a way to use webpy or something else to access a user's local drive to create a tree directory out of it?
removing buttons/links in django admin
9,564,009
7
2
2,890
0
python,django,django-admin
Do not remove or change anything in the admin. Instead remove user's/group's permission to delete given model. If user does not have the permission to delete, the delete button won't appear at any page related to that model.
0
0
0
0
2012-03-05T08:59:00.000
2
1.2
true
9,563,935
0
0
1
1
I have an apps and I am making used of django admin, but my apps does not allow deleting of data and django admin have a delete button/link. I have already removed the delete action. my question is, how can i remove the delete button/link in admin page in django?
Django models - field dependency
9,586,795
1
3
2,667
0
python,django,validation,model
Case 1: Don't do it like that, have a different table for telephone numbers and have a ForeignKey from the Person (I'm assuming it's a person) to the the telephone number. If you have more than one telephone number per person, do it the other way around, otherwise consider using a OneToOne. Obviously you'll want the ForeignKey to be nullable. That way, the only way to have a telephone number is if the person provided one. Case 2: I don't understand your database design here, so I can't answer. You'll have to explain more - why do you need a ManyToMany here?
0
0
0
0
2012-03-05T14:30:00.000
2
0.099668
false
9,568,336
0
0
1
1
How can I have field dependency? Case 1: If boolean field call_me is set, then telephone must be set, else it should be blank Case 2: If many to many field category (with values sale, rent) has one of the values as sale, then price_sale must be set, else it should be blank
Do I need to create a separate class in my models.py when using the django.contrib.auth.models import user?
9,575,013
0
0
104
0
python,django
All installed apps can contribute to the database schema. django.contrib.auth.models contributes, among others, the auth_user table behind the django.contrib.auth.models.User model, therefore you do not have to worry about recreating it unless you have a specific reason to do so.
0
0
0
0
2012-03-05T22:23:00.000
4
1.2
true
9,574,970
0
0
1
2
The import statement import the needed parts. but is the "user" class already made when you put that into your installed apps? or do you still need to clarify in models.py in order to make the table in the db? or can someone expand on how to use django users and sessions? I'm looking over the django docs right now and they all just go over how to use the thing once. they never put the code in a syntax where users are going to be the ones using the code through a browser and not you through a python shell.
Do I need to create a separate class in my models.py when using the django.contrib.auth.models import user?
9,575,285
0
0
104
0
python,django
There's a number of things going on here. As you're aware, Django comes with a number of "contrib" packages that can be used in your app. You "activate" these by putting them into your INSTALLED_APPS. When you run python manage.py syncdb, Django parse the models.py files of every app in INSTALLED_APPS and creates the associated tables in your database. So, once you have added django.contrib.auth to your INSTALLED_APPS and ran syncdb, the tables for User and Group are there and ready to be used. Now, if you want to use these models in your other apps, you can import them, as you mention, with something like from django.contrib.auth.models import User. You can then do something like create a ForeignKey, OneToOneField or ManyToManyField on one of your models to the User model. When you do this, no tables are created (with the exception of ManyToManyField; more on that in a bit). The same table is always used for User, just as for any of your own models that you might create relationships between. ManyToManyFields are slightly different in that an intermediary table is created (often called a "join table") that links both sides of the relationship together. However, this is purely for the purposes of that one particular relationship -- nothing about the actual User table is different or changed in any way. The point is that one table is created for User and this same table is used to store all Users no matter what context they were created in. You can import User into any and all of your apps, create as many and as varied relationships as you like and nothing really changes as far as User is concerned.
0
0
0
0
2012-03-05T22:23:00.000
4
0
false
9,574,970
0
0
1
2
The import statement import the needed parts. but is the "user" class already made when you put that into your installed apps? or do you still need to clarify in models.py in order to make the table in the db? or can someone expand on how to use django users and sessions? I'm looking over the django docs right now and they all just go over how to use the thing once. they never put the code in a syntax where users are going to be the ones using the code through a browser and not you through a python shell.
Is cookie a common and secure implementation of session?
9,576,386
2
1
365
0
python,session,cookies,pyramid
In general, the cookie stored with the client is just a long, hard-to-guess hash code string that can be used as a key into a database. On the server side, you have a table mapping those session hashes to primary keys (a session hash should never be a primary key) and expiration timestamps. So when you get a request, first thing you do is look for the cookie. If there isn't one, create a session entry (cookie + expiration timestamp) in the database table. If there is one, look it up and make sure it hasn't expired; if it has, make a new one. In either case, if you made a new cookie, you might want to pass that fact down to later code so it knows if it needs to ask for a login or something. If you didn't need to make a new cookie, reset the expiration timestamp so you don't expire the session too soon. While handling the view code and generating a response, you can use that session primary key to index into other tables that have data associated with the session. Finally, in the response sent back to the client, set the cookie to the session key hash. If someone has cookies disabled, then their session cookie will always be new, and any session-based features won't work.
0
0
0
1
2012-03-06T00:35:00.000
3
1.2
true
9,576,263
0
0
1
2
I'm using pyramid web framework. I was confused by the relationship between the cookie and session. After looked up in wikipedia, did I know that session is an abstract concept and cookie may just be an kind of approach (on the client side). So, my question is, what's the most common implementation (on both the client and server)? Can somebody give some example (maybe just description) codes? (I wouldn't like to use the provided session support inside the pyramid in order to learn)
Is cookie a common and secure implementation of session?
9,576,390
1
1
365
0
python,session,cookies,pyramid
A session is (usually) a cookie that has a unique value. This value maps to a value in a database or held in memory that then tells you what session to load. PHP has an alternate method where it appends a unique value to the end of every URL (if you've ever seen PHPSESSID in a URL you now know why) but that has security implications (in theory). Of course, since cookies are sent back and forth with every request unless you're talking over HTTPS you are sending the only way to know (reliably) that the client you are talking to now is the same one you logged in ten seconds ago to anyone on the same wireless network. See programs like Firesheep for reasons why switching to HTTPS is a good idea. Finally, if you do want to build your own I, was given some advice on the matter by a university professor. Give out a new token on every page load and invalidate all a users tokens if an invalid token is used. This just means that if an attacker does get a token and logs in to it whilst it is still valid when the victim clicks a link both parties get logged out.
0
0
0
1
2012-03-06T00:35:00.000
3
0.066568
false
9,576,263
0
0
1
2
I'm using pyramid web framework. I was confused by the relationship between the cookie and session. After looked up in wikipedia, did I know that session is an abstract concept and cookie may just be an kind of approach (on the client side). So, my question is, what's the most common implementation (on both the client and server)? Can somebody give some example (maybe just description) codes? (I wouldn't like to use the provided session support inside the pyramid in order to learn)
django-admin-tools : change header 'Django Administration'
9,588,284
1
0
2,081
0
python,django,django-admin
The django-admin-tools header is controlled by the theming.css file which is by default sitting under \admin_tools\theming\static\admin_tools\css\theming.css, and the default header should display the "Django" png that comes with django-admin-tools and is placed under \admin_tools\theming\static\admin_tools\images\django.png. I guess that if the default admin tools header doesn't display then your admin tools theme is not kicking in either. This means django can't see your theming folder of admin tools. Check that your MEDIA_ROOT, STATIS_ROOT andADMIN_MEDIA_PREFIX parameters in setting.py are set correctly. Check the PYTHONPATH env param is also set to all the needed folders. When the default admin tools theme will load you can drop a new header image in the images folders as above and edit the theming.css to load it instead of the default.
0
0
0
0
2012-03-06T01:50:00.000
1
1.2
true
9,576,822
0
0
1
1
I am using django-admin-tool to customized my django admin page. my problem is, how can I change the header of 'Django Administration' with django-admin-tools? i know how to change it using base_site.html but the problem is my custom menu that i have done in django-admin-tools is not appearing.
dreamhost+django: cannot get domain name using site framework
9,588,891
0
0
152
0
python,django,web,dreamhost,domain-name
The problem waas that it was executing the old instance of webapp (that didn't use sites module) So i have resolved with pkill python command.
0
0
0
0
2012-03-06T03:44:00.000
1
1.2
true
9,577,614
0
0
1
1
In my view i execute Site.objects.get_current().domain but the result is empty string. So, how can i get the domain name to compose right url? Hosting is dreamhost.
Need to send a HTTP request in Python that'll authenticate with Google Accounts
9,596,143
2
0
425
0
python,google-app-engine,cookies,oauth
Can you use OAUth to authenticate with Google, then use the OAuth token to ensure the messages are legitimate?
0
0
1
0
2012-03-06T23:39:00.000
2
0.197375
false
9,593,659
0
0
1
1
I have an app which amounts to a Python script, running on the user's phone, and a JS client, running in the user's browser. The Python script sends messages to App Engine as HTTP requests. The server then pushes the messages to the JS client. The problem is authentication: The server can easily use Google Accounts to authenticate anything coming from the JS client as being sent by a particular user, but I do not know how to get the Python script to make HTTP requests which will also authenticate. Any ideas?
Cross Platform Event Notification
9,595,261
0
0
335
0
python,notifications,push-notification,server-push
Maybe have a look at www.pubnub.com .. its commercial, but lets you send 5 million messages a month for free. Essentially it lets you create a named channel, and have X number of clients connect to it and send messages back and forth. Using one of these services would of course require you to write a client to distribute to your users (in your language of choice) and tie's you in somewhat (shouldn't really be a problem as you could swap in some other solution later if they go under or whatever.) The upside would be, very good x-platform support and a very clean API, infrastructure taken care of for you (for example clients can still connect the the channel even if your asterisk box is down or whatever) (and no, I don't work for pubnub! but it seems like a no-brainer to use it with the 5mil messages free deal!)
0
0
0
1
2012-03-07T02:39:00.000
2
0
false
9,595,076
0
0
1
1
I hope you guys can spare a moment with some ideas on how to develop my idea. I have an Asterisk-based telephone switch . When an incoming call is arriving, I can make sure the server runs an external script of any language. Here comes my development work. I would like to notify a group of listening clients about the call, and probably open a browser page on their computer. What kind of approach would you take for this sort of server-based push notification? (with no iPhone involved) I am open to any language. Thanks
How do I redirect an user back to the page they were trying to access once they log in? (Django)
9,595,612
0
1
135
0
python,django
You can pass a url parameter back to your login page and use that to direct the user once they complete the login successfully.
0
0
0
0
2012-03-07T03:43:00.000
3
0
false
9,595,497
0
0
1
1
So currently I'm using @login_required to block certain pages from users and redirect them, telling them they need to log in. but what I can't understand is how do I "let them" go to the page they were trying to go to once they log in. Currently I'm just using a typical render_to_response('with a certain view') but what if i want that response to be anywhere where they were trying to access. How do i code that?
Is there a way to send html emails with django-mailer?
9,677,080
4
1
1,554
0
python,django
Roam's answer pointed me in the right direction, but it wasn't a complete answer. The real answer to this is that you can't normally send html emails with django-mailer. It might be possible to hack django-mailer or work around it in someother way - but I haven't yet heard of any way of doing that. The better alternative is to use send_html_email but this doesn't actually come with django-mailer, although it does come with pinax-django-mailer which is a fork of django-mailer, so mostly the same but with the addition of send_html_email. If you have already installed django-mailer then you should make sure it is completely removed before attempting to install pinax-django-mailer otherwise you will encounter problems. I had to go into my Python directory and manually remove django-mailer in order to then get pinax-django-mailer installed cleanly. Assuming that you have properly removed django-mailer (or not installed it in the first place) then you will find it quite easy to get up an running with pinax-django-mailer.
0
0
0
0
2012-03-07T06:48:00.000
2
1.2
true
9,596,975
0
0
1
1
I am developing a site using Django and Python. I am using django-mailer to send out a newsletter to registered subscribers. It can do text emails ok, but passing html into the send_mail function doesn't have the desired result. Is it possible to use django-mailer to send html or otherwise is there a way I can adjust/modify/hack it to do what I want?
Django JSON De-serialization Security
9,604,106
3
12
2,992
0
python,django,json,security
I'm having trouble working out what you think could be insecure (or secure) about JSON. JSON is a text-based data exchange format. It doesn't have any security built-in. Django comes with some functions to serialize and deserialize querysets to JSON. But these can't be "malicious" or "insecure" - they're just data. Some serialization protocols, eg pickling, can potentially be insecure because they can contain code, so could possibly be deserialized to run something that harms your system. Serialized models don't have that problem, because they don't contain code. Of course, if you were using JSON to (for example) pass a list of model IDs to be deleted, then there is the potential for a malicious user to include a whole load of IDs you don't want deleted. But again this isn't the fault of JSON - it's up to you to ensure that your business logic correctly determines which elements a user is allowed to delete or modify.
0
0
0
0
2012-03-07T15:02:00.000
2
0.291313
false
9,603,841
1
0
1
1
Are there any known security vulnerabilities with Django's JSON deserializer? Regarding Python deserializing protocols, the general concensus seems to be they're completely insecure, so avoid parsing untrusted data. However, I'm considering a distributed web application where different servers exchange model records, formatted as JSON. The records themselves don't contain sensitive data, but I'm concerned about the ability for a hacked server breaching another server by sending maliciously formatted JSON. Is this possible? I usually see Django's JSON serializer in public-facing environments, so I would hope it's hardened against this kind of thing, but I haven't been able to find any documentation addressing any security issues.
apache mpm worker run only single process
9,608,216
1
0
452
0
python,django,apache,process
Another alternative could be to use something like mod_wsgi in daemon mode configured with only one process, then hand off to that. This is all assuming that your web server only ever needs to be single process, and that no other request should be served in parallel? Do you have other views which aren't rate limited? In which case, you could do this via some sort of lock file for this view only, rather than trying to make the web server single process?
0
1
0
0
2012-03-07T16:50:00.000
1
1.2
true
9,605,759
0
0
1
1
I need to make apache mpm worker use only a single process to run my django server . I have a view which needs to be run only once when the first request hits the apache . But i see it running twice. I made the runprocess configuration from 2 to 1 . what else should i do to make apache run only one process..
Django Template Test Coverage
9,618,165
1
24
1,443
0
python,django,unit-testing,code-coverage
Templates do not store any kind of line number information like python source code does. The best you could do is monkey patch the NodeList object to record how many times each node has been evaluated, and then re-render the templates in a special mode that will show which nodes are evaluated. EDIT: I have been corrected. Templates DO store line number information, but only for the start of a token. I.E. if you have a TextNode span multiple lines, you will need to handle that yourself. There is some interesting code in django.templates.debug that may be useful for constructing such a coverage reporter.
0
0
0
0
2012-03-08T06:30:00.000
3
0.066568
false
9,613,759
0
0
1
1
Is there any way to produce a report containing the code coverage in my django test suite for my site's templates? I already have coverage for python, but coverage for templates to identify dead or untested template code would be awesome. To clarify: I want to find lines in my templates that are never executed or emitted during my test suite.
How to properly handle page refresh?
9,615,608
0
1
279
0
javascript,jquery,python,google-app-engine,google-cloud-datastore
The two scenarios you have explained are behaviours built into your browser. Most browsers will try to resubmit form data if you press F5 on a page where data has been submitted. This is to try to avoid data being lost by the average user. It is as though you were to enter the site, complete the form and click Submit all over again. To avoid handling this data again you could generate a random key and store it in a hidden form field. Then when the data is submitted, save this key in a session variable. If the data is resubmitted, you can put a check around your postback which compares the random key in the form data to that in the session. If they are the same then the data has already been handled.
0
0
0
0
2012-03-08T09:41:00.000
3
0
false
9,615,514
0
0
1
3
I have a form on my page with many fields. I save field values in the datastore once user input a value (without waiting for form submission). Some score is calculated based on field values and displayed to the user. I also generate user's client id and store that in user's cookies for one hour. I am not sure what should happen when user refreshed the page in browser: if user pressed F5 in FF, then field values are still displayed in the browser; when user pressed Ctrl+F5, then values are cleared. In both cases I don't want to create new record for this user, so client id should remain the same. But in scenario (1) I should NOT clear field values in datastore and its score, but I should do it in scenario (2). How can I recognize that on the server side?
How to properly handle page refresh?
9,615,888
0
1
279
0
javascript,jquery,python,google-app-engine,google-cloud-datastore
Create a SESSION ID when the user enters the Registration page and store it in the database. I think session id will change only when user close the browser. If user refresh the page retrive the values from the database with the SESSION ID. When user click submit button and successfully query the values to database. Destroy the SESSION ID reset the form fields...
0
0
0
0
2012-03-08T09:41:00.000
3
0
false
9,615,514
0
0
1
3
I have a form on my page with many fields. I save field values in the datastore once user input a value (without waiting for form submission). Some score is calculated based on field values and displayed to the user. I also generate user's client id and store that in user's cookies for one hour. I am not sure what should happen when user refreshed the page in browser: if user pressed F5 in FF, then field values are still displayed in the browser; when user pressed Ctrl+F5, then values are cleared. In both cases I don't want to create new record for this user, so client id should remain the same. But in scenario (1) I should NOT clear field values in datastore and its score, but I should do it in scenario (2). How can I recognize that on the server side?
How to properly handle page refresh?
9,616,023
0
1
279
0
javascript,jquery,python,google-app-engine,google-cloud-datastore
The best way, when you load the page, you should check it if there was any content for each form field already saved in db otherwise try some client side form field cache technique.
0
0
0
0
2012-03-08T09:41:00.000
3
0
false
9,615,514
0
0
1
3
I have a form on my page with many fields. I save field values in the datastore once user input a value (without waiting for form submission). Some score is calculated based on field values and displayed to the user. I also generate user's client id and store that in user's cookies for one hour. I am not sure what should happen when user refreshed the page in browser: if user pressed F5 in FF, then field values are still displayed in the browser; when user pressed Ctrl+F5, then values are cleared. In both cases I don't want to create new record for this user, so client id should remain the same. But in scenario (1) I should NOT clear field values in datastore and its score, but I should do it in scenario (2). How can I recognize that on the server side?
How to ensure several Python processes access the data base one by one?
9,618,894
0
0
157
0
python,database,queue
You could create a function that each process must call in order to talk to the DB. You could re-write the scripts so that they must call that function rather than talk directly to the DB. Within that function, you could have a scope-based lock so that only one process would be talking to the DB at a time.
0
0
0
0
2012-03-08T13:59:00.000
3
0
false
9,618,773
0
0
1
2
I got a lot scripts running: scrappers, checkers, cleaners, etc. They have some things in common: they are forever running; they have no time constrain to finish their job; they all access the same MYSQL DB, writting and reading. Accumulating them, it's starting to slow down the website, which runs on the same system, but depends on these scripts. I can use queues with Kombu to inline all writtings. But do you know a way to make the same with reading ? E.G: if one script need to read from the DB, his request is sent to a blocking queue, et it resumes when it got the answer ? This way everybody is making request to one process, and the process is the only one talking to the DB, making one request at the time. I have no idea how to do this. Of course, in the end I may have to add more servers to the mix, but before that, is there something I can do at the software level ?
How to ensure several Python processes access the data base one by one?
9,619,460
1
0
157
0
python,database,queue
You say that your dataset is <1GB, the problem is CPU bound. Now start analyzing what is eating CPU cycles: Which queries are really slow and executed often. MySQL can log those queries. What about the slow queries? Can they be accelerated by using an index? Are there unused indices? Drop them! Nothing helps? Can you solve it by denormalizing/precomputing stuff?
0
0
0
0
2012-03-08T13:59:00.000
3
0.066568
false
9,618,773
0
0
1
2
I got a lot scripts running: scrappers, checkers, cleaners, etc. They have some things in common: they are forever running; they have no time constrain to finish their job; they all access the same MYSQL DB, writting and reading. Accumulating them, it's starting to slow down the website, which runs on the same system, but depends on these scripts. I can use queues with Kombu to inline all writtings. But do you know a way to make the same with reading ? E.G: if one script need to read from the DB, his request is sent to a blocking queue, et it resumes when it got the answer ? This way everybody is making request to one process, and the process is the only one talking to the DB, making one request at the time. I have no idea how to do this. Of course, in the end I may have to add more servers to the mix, but before that, is there something I can do at the software level ?
How can I get the HTML generated with javascript?
9,618,891
3
3
2,524
0
javascript,python,html
The only way I know of to do this from your server is to run the page in an actual browser engine that will parse the HTML, build the normal DOM environment, run the javascript in the page and then reach into that DOM engine and get the innerHTML from the body tag. This could be done by firing up Chrome with the appropriate URL from Python and then using a Chrome plugin to fetch the dynamically generated HTML after the page was done initializing itself and communicate back to your Python.
0
0
1
0
2012-03-08T13:59:00.000
3
0.197375
false
9,618,776
0
0
1
2
I want to get the HTML content of a web page but most of the content is generated by javascript. Is it posible to get this generated HTML (with python if posible)?
How can I get the HTML generated with javascript?
9,618,929
0
3
2,524
0
javascript,python,html
If most of the content is generated by Javascript then the Javascript may be doing ajax calls to retrieve the content. You may be able to call those server side scripts from your Python app. Do check that it doesn't violate the website's terms though and get permission.
0
0
1
0
2012-03-08T13:59:00.000
3
0
false
9,618,776
0
0
1
2
I want to get the HTML content of a web page but most of the content is generated by javascript. Is it posible to get this generated HTML (with python if posible)?
What alternatives to pinax exists?
10,642,779
0
7
1,366
0
python,django,pinax
I don't think there's any alternative, luckily it's active again lately.
0
0
0
0
2012-03-08T16:44:00.000
1
0
false
9,621,385
0
0
1
1
I am planning on transferring my django site to pinax so I dont have to deal with the user registration and what not. Before I make this move, I was wondering what the alternative options are so I dont have to make this transfer twice. So what alternatives to pinax exists? and which one is your favorite?
celery with multiple django instances
9,635,351
1
5
1,580
0
python,django,linux,celery
If you make changes in tasks.py for celery, then you will have to restart it once to apply changes by running command ./manage.py celeryd start or python manage.py celeryd start --settings=settings for using settings.py as configuration for celery. It will not be affected by the changes in your projects until you make changes in celery configuration.
0
1
0
0
2012-03-09T13:26:00.000
2
0.099668
false
9,634,800
0
0
1
1
I'm using several django instances, each in a virtualenv, on the same server. How can I start the celery server and make sure it is always running and updated? I.e. after a server restart or code update? The /etc/init.d script and the config file assume a single Django installation. Do I have to use the ./manage.py celeryd command? Regards Simon
Is that possible to develop a ACM ONLINE JUDGE system using NODE.JS(or PYTHON)?
9,636,911
0
4
1,228
0
javascript,python,node.js,compiler-construction
To accomplish the sandbox, it would be fairly easy to do this by simply running your code inside of a closure that reassigns all of the worrisome calls to NaN for instance, if the code executes inside a closure where eval=NaN
0
0
1
0
2012-03-09T15:06:00.000
2
0
false
9,636,294
0
0
1
1
I'm a newer and if the question is so easy I apologize for that. Assume I want to dev a classical online judge system, obviously the core part is get users' code to a file compile it on server run it on server (with some sandbox things to prevent damage) the program exit itself, then check the answer. or get the signal of program collapsing. I wonder if it's possible to do all the things using Node.js, how to do the sandbox things. Is there any example for compile-sandbox-run-abort-check thing? additional: is it more convenient to dev a such system using PYTHON? thanks in advance.
Log parser solutions python/perl vs Java
9,642,425
0
0
838
0
java,python,parsing,logging
I recently started writing python scripts, but recently i wrote a java gc log parser to print the timestamp when a gc happened and counts etc, and i found Python real easy in writing it. What kind of fields are you interested while parsing the syslogs? I think if you know what you are looking for in the logs(patterns etc) then it becomes easy to write a script which would do that for you. Ankit.
0
0
0
1
2012-03-09T22:42:00.000
2
1.2
true
9,641,974
0
0
1
2
I know perl and python is tested solution for this kind of log parsing and data mining - Anybody have experience dealing with syslog parsing with Java ? I have to create a Java demon anyway to load the parsed output to DB .. So I was thinking why not going all the way - python might be useful when I will be running it on different environment.
Log parser solutions python/perl vs Java
11,693,757
1
0
838
0
java,python,parsing,logging
I translated some Java GC log parser/analyzer from Perl to Java. In Java the code looked like more lines and the code obviously more verbose but the execution was at least 5 times faster.
0
0
0
1
2012-03-09T22:42:00.000
2
0.099668
false
9,641,974
0
0
1
2
I know perl and python is tested solution for this kind of log parsing and data mining - Anybody have experience dealing with syslog parsing with Java ? I have to create a Java demon anyway to load the parsed output to DB .. So I was thinking why not going all the way - python might be useful when I will be running it on different environment.
How can I run a python script through a webserver and return results to javascript?
9,642,671
0
0
703
0
php,javascript,python,gearman
Put your Python script in your CGI directory and use the cgi and json modules in your script to read AJAX from post/get params. Of course you can do a system call from PHP to run a Python script, but I can't think of a good reason why you would.
0
0
1
1
2012-03-09T23:18:00.000
2
0
false
9,642,259
0
0
1
1
I want to take results from a web page, sent from dom as json through ajax, then send this data to a python script, run it, then return the new results back as json. I was told a php script running gearman would be a good bet, but I'm still not sure how that would work.
Is it secure to host Django Admin media on a public folder on AWS
9,644,524
1
0
176
0
python,django,security,heroku
I don't see any reason why it wouldn't be. After all, when you login to the admin panel, the links to the css and js are always public. Meaning at that point they are just like any other static resource and they don't require to be logged in order to view them. So you can store them whenever you want and as long as they will remain read-only to the public (which it is in AWS), there should not be any security risk.
0
0
0
0
2012-03-10T04:39:00.000
1
1.2
true
9,643,975
0
0
1
1
I have a Django app hosted in the cloud (Heroku if that makes a difference though I can't see how) and am looking to move all static content to AWS (images, CSS etc). Is it secure to have Django's Admin media (ie the media/ css/ and js/ folders) hosted on a publicly accessible site?
Why does altering STATIC_URL in Django disrupt ADMIN_MEDIA_PREFIX
9,645,186
1
1
565
0
python,django
Which version of Django do you use? Before Django 1.4, the STATIC_URL and ADMIN_MEDIA_PREFIX are indeed different parts. In Django 1.4, ADMIN_MEDIA_PREFIX is deprecated and STATIC_URL is used solely. The way you're using to serve corresponding files is important also. You could check the URLs of media files in the admin page: if they are generated correctly but cannot get loaded, it might be caused by mis-configured web server instead of Django itself.
0
0
0
0
2012-03-10T05:15:00.000
1
0.197375
false
9,644,121
0
0
1
1
Trying to gain some high level clarity on how Django serves (admin) static files. When altering the STATIC_URL setting in Django's settings.py to a new location (I'm serving images from a 3rd party server) it seems to disrupt ADMIN_MEDIA_PREFIX and thus stop the Admin media (css, images, js) from being served. Why does this happen? I though STATIC_URL and ADMIN_MEDIA_PREFIX should pertain to different parts of the application and not influence eachother.
Python get data from secured website
9,647,462
3
2
2,748
0
python,post,cookies,get,urllib2
This is a part of Web-Scraping : Web-scraping is a standard task that can serve various needs. Scraping data out of secure-website means https Handling https is not a problem with mechanize and BeautifulSoup Although urllib2 with HTTPCookieJar also works fine If managing the cookies is the problem, then I would recommend mechanize Considering the case of your BANK-Site : I would recommend not to play with your account. If you must then, its not as easy as any normal secure/non-secure site. These sites are designed to with-stand such scripts. Problems that you would face with this: BANK sites will surely have Captcha that is almost impossible to by-pass with a script unless you employee a lot of rocket-science and effort. Other problem that you will definitely face is javascript, standard scripting solutions are focused to manage cookies, HTML parsing, etc. For processing javascript on links you will have to process js in your python script. That again needs a lot of effort. Then, AJAX that again comes from javascript fetches data from server after page-load. So, it will require you to take a lot of effort to do this task. Also, if you try doing this you risk of blocking access to your account since banking sites are quick to block account access on 3-4 unsuccessful attempt on login or captcha, etc. So, think before you do.
0
0
1
0
2012-03-10T14:53:00.000
1
0.53705
false
9,647,381
0
0
1
1
Id like to know if there is a way to get information from my banking website with Python, Id like to retrieve my card history and display it, and possibly save it into a text document each month. I have found the urls ext to login and get the information from the website, which works from a browser, but I have been using liburl2 to "open" the webpages from Python and I have a feeling its not working because of some cookie or session things. I can get any information I want from a website that does not require a login with urllib2, and then save the actual HTML and go through it later, but I cant on my banks website, Any help would be appreciated
Generate admin panel automatically
9,654,945
0
0
93
0
python
I dont hear about of these libraries, but you can try SqlAlchemy and WTForms.
0
0
0
0
2012-03-11T11:30:00.000
1
0
false
9,654,527
0
0
1
1
I'm looking for python-libraries which can make autogenerated panel for administer site (like django) using models (ORM) or descriptions of tables from database.
What are the extra capabilities Python gives when used with Java?
9,663,378
2
3
124
0
java,python,jython
I know how to use python with java through jython, but backwards ... try to ask your question to jython community.
0
0
0
0
2012-03-12T07:44:00.000
3
0.132549
false
9,663,321
1
0
1
3
I am a Java developer. I would like to know what capabilities and/or positives I can add to a Java application, by including Python as a development language. I am posting this here as I am not getting a good answer from google. I would request that you don't vote down, marking it to be a descriptive question, so that a future Java developer can understand how he can make an application better with Python.
What are the extra capabilities Python gives when used with Java?
9,663,439
1
3
124
0
java,python,jython
1st: jython is many times slower than java. 2nd: as I recall integration in direction jython -> java is not very seemless. 3rd: you get python syntax, maybe some batteries (i don't really know this). This is a plus. 4th: you get good heavy multithreading support in python instead of green thread and GIL. That can be a plus.
0
0
0
0
2012-03-12T07:44:00.000
3
0.066568
false
9,663,321
1
0
1
3
I am a Java developer. I would like to know what capabilities and/or positives I can add to a Java application, by including Python as a development language. I am posting this here as I am not getting a good answer from google. I would request that you don't vote down, marking it to be a descriptive question, so that a future Java developer can understand how he can make an application better with Python.
What are the extra capabilities Python gives when used with Java?
9,663,494
8
3
124
0
java,python,jython
In general, there are no (overall) benefits for doing this. You're simply adding in another language with its own set of runtime features, that, for the most part does the same things that you can do in Java. Unless you have specific reason to add Python integration into your Java application, it would be a very poor idea to do so. However, in some cases there are reasons why you might want to do this: To add scripting capabilities to your application. If you want the end users of your application (or perhaps authors of add-ons, or system administrators) to be able to script parts of your application, then Python is a reasonable choice to offer them. There are other good choices too, but Python is fairly well known, quite mature, has decent Java integration and a good set of features, so it's not a bad choice. To accommodate Python developers in your team If your team has Python developers who (for whatever reason) aren't willing/able to write in Java, then you can provide facilities to support including their code in your Java application. If you believe that writing in Python is more productive If you/your team believe that writing Python code is sufficiently more productive than writing Java code to justify the cost of integrating the Jython runtime into your Java application, then you might take that path. Personally, I'd question that decision in all by the most niche of use cases, but that's up to each team to decide. To integrate with existing Python code There may be libraries or tools that are written in Python that you want to integrate with in your application. Rather than re-writing them in Java, or trying to run them via the command-line, it might be a good idea to run them in the Jython environment in the JVM. Unless you have a specific reason like one of those listed above, then simply integrating Jython into your application isn't going to give you any benefits, it will simply be extra effort to write and support. If you have one of those reasons, then it might make sense, it will depend on your circumstances.
0
0
0
0
2012-03-12T07:44:00.000
3
1
false
9,663,321
1
0
1
3
I am a Java developer. I would like to know what capabilities and/or positives I can add to a Java application, by including Python as a development language. I am posting this here as I am not getting a good answer from google. I would request that you don't vote down, marking it to be a descriptive question, so that a future Java developer can understand how he can make an application better with Python.
How to disable a button after clicking it in OpenERP
9,667,268
0
4
2,267
0
python,openerp
If we talking about web interface then you could disable it by javascript.
0
0
1
0
2012-03-12T11:46:00.000
3
0
false
9,666,425
0
0
1
1
This might be a simple question.but,does any one know how to disable a button after clicking it in OpenERP? Please help!!!!! Thanks for all your help....