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
Upvote and Downvote buttons with Django forms
14,678,289
0
3
829
0
python,django,django-forms
I would suggest, you use separate view login for up and down voting. Something like this /upvote/{{comment.pk|urlize}} and then write a view that works with this url. With PK find the comment that the user is trying to up/down vote, then write the necessary condition to check if the user is authorized to perform that kind of action, and then finally execute that action. I hope this helps
0
0
0
0
2013-02-03T21:34:00.000
1
1.2
true
14,677,548
0
0
1
1
I want to make upvote and downvote buttons for comments but I want all the form inputs that django.contrib.comments.forms.CommentSecurityForm gives me to make sure the form is secure. Is that necessary? And if so, how do I make a form class that with upvote and downvote buttons? Custom checkbox styles?
Storing subprocess object in memory using global singleton instance
14,691,638
1
1
1,465
0
python,django,subprocess
You can use the same technique in Python as you did in Java, that is store the reference to the process in a module variable or implement a kind of a singleton. The only problem you have as opposed to Java, is that Python does not have that rich analogy to the Servlet specification, and there is no interface to handle the application start or finish. In most cases you should not be worried how many instances of your application are running, because you fetch all data from a persistent storage. But in this case you should understand how your application is deployed. If there is a single long running instance of your application (a FastCGI instance, for example, or a single WSGI application on cherrypy), you can isolate the process handling functionality in a separate module and load it when the module is imported (any module is imported only once within an application). If there are many instances (many FastCGI instances, or plain CGI-scripts), you should better detach child processes and keep their ids in a persistent storage (in a database, or files) and intersect them with the the list of currently running processes on demand.
0
1
0
0
2013-02-04T05:44:00.000
2
0.099668
false
14,681,015
1
0
1
1
So I am using subprocess to spawn a long running process through the web interface using Django. Now if a user wants to come back to the page I would like to give him the option of terminating the subprocess at a later stage. How can do this? I implemented the same thing in Java and made a global singleton ProcessManager dictionary to store the Process Object in Memory. Can I do something similar in Python? EDIT Yes Singletons and a hash of ProcessManager is the way of doing it cleanly. Emmanuel's code works perfectly fine with a few modifications. Thanks
How to export virtualenv?
36,716,554
-2
72
67,525
0
python,django,virtualenv
If it is going to be on the same path you can tar it and extract it on another machine. If all the same dependencies, libraries etc are available on the target machine it will work.
0
0
0
0
2013-02-04T10:39:00.000
3
-0.132549
false
14,684,968
1
0
1
1
I'm new to virtualenv but I'm writting django app and finally I will have to deploy it somehow. So lets assume I have my app working on my local virtualenv where I installed all the required libraries. What I want to do now, is to run some kind of script, that will take my virtualenv, check what's installed inside and produce a script that will install all these libraries on fresh virtualenv on other machine. How this can be done? Please help.
Dynamically Generating Pretty Web Based Charts/Graphs
14,691,588
1
1
262
0
python,graph
I would recommend the awesome d3.js package, you can do just about anything with it and it produces beautiful interactive charts.
0
0
0
0
2013-02-04T15:55:00.000
1
1.2
true
14,690,411
0
0
1
1
I'm using Python to work on a web app that has a data visualization element. Basically, it will gather data about a user's music catalog and allow them to visualize it and take actions based on what the data tells them. I'll pretty much exclusively need bar graphs to achieve the visualization I want. Given the dynamic nature of the app, the package needs to support creating charts on the fly -- essentially responding to a user's commands and their data to quickly render a new chart. The problem is, some of the more lightweight packages like PyCha create charts that aren't visually appealing or suitable for a consumer based web app. I've looked into Fusion Charts, but that seems a bit heavy weight for my purposes, and it uses Flash, which I'd like to avoid. Is there a nice middle ground somewhere that allows me to create reasonably pretty charts based on user input but doesn't bog down my server with Flash baggage and an enterprise level amount of features?
How can I integrate Tornado into my (currently) Apache driven site?
14,700,450
1
0
956
0
php,python,apache,localhost,tornado
Easiest is to run Tornado and Apache on different ports/addresses So you probably have Apache listening to port 80 already. Tornado could listen to port 81 If the server is multihomed, you could have Apache listen to a.b.c.d:80 and Tornado listen to a.b.c.e:80. This means that you'll at least have to have the Apache part and the Tornado part on different subdomains If you need to run them all under the same domain and port, you'll need something lean and fast in front of them to work out which url gets routed to which server.
0
1
0
0
2013-02-05T04:37:00.000
1
1.2
true
14,700,305
0
0
1
1
I have a website built in PHP and currently running on an Apache server (XAMPP locally). I would like to integrate a real-time chat system into the website. PHP and Apache not being geared for this in the slightest, I decided to work with Tornado and Python. What is the easiest way to keep the base of the site in PHP and run it on Apache while delegating all the "chatting" to the Tornado server? I would like to be able to do this locally (...and needless to say, I have successfully installed Tornado and have been working on said script. However, I'm not sure exactly how to integrate it into the already existing site.) Any advice greatly appreciated, thanks!
Modules not found in django
14,702,956
0
0
207
0
python,django
what is the reason for nesting "data" app in "apps"? it is uncommon to nest one app inside of another when there are only two apps (unless you have some great reason to). suggestions: create an apps app, and create a data model for it; create an apps app, and a data app; (link them however through the models) the answer to your problem is probably file structure, but your basic requirements for what you're asking is detailed in your app requirements. Long story short.. what application are you trying to create?
0
0
0
0
2013-02-05T05:45:00.000
1
0
false
14,700,943
0
0
1
1
I want to make an application in django with two apps named apps and data.the "data" apps is placed within "apps".I had entered 'apps.data' in the Installed apps in "settings.py".when I run the devserver i got this error "no modules named apps.data".Any one please help me.
How to monitor google app engine from command line?
14,723,922
1
1
104
0
python,google-app-engine
I assume you are using Linux, Ubuntu/Mint If not that would be a good start Debug as much as you can locally using dev_appserver.py - this will display errors on start up (in the console) Add your own debug logs when needed Run code snippets in the interactive console - this is really useful to test snippets of code: if you are on GAE >= 1.7.6 http://localhost:8000/console if you are on GAE < 1.7.6 http://localhost:8080/_ah/admin/interactive/interactive
0
1
0
0
2013-02-06T02:11:00.000
3
0.066568
false
14,720,476
0
0
1
1
I'm starting to use Google App Engine and being a newcomer to much of the stuff going on here, I broke my webpage (all I see is "server error" in my web browser). I'd like to be able to see a console of some sort which is telling me what's going wrong (python syntax? file not found? something else?). Searching around a bit didn't lead me to a quick solution to this, so I came here. Any advice? Ideally, there would be some sort of tutorial/guide that would show how to do this.
Fastest way to do _simple_ templating with Python
16,305,372
0
0
42
0
python,performance,templating
After lots of trying and reading I found string.Template from the Core Library to be the fastest - I just wrapped in my own simple class to encapsulate the file-access/reads et voilà.
0
0
0
1
2013-02-06T11:12:00.000
1
1.2
true
14,727,628
0
0
1
1
After using cheetah and mako at their functional minimum (only for substitution) for sometime, I started asking myself whether just using string.Template wouldn't be the better and simpler approach for my use case(less deps). In addition I wondered whether it would be reasonable to import these templates as .py files to avoid .open() on each call. This would make handling templates a little more complicated but other than that I'd save a lot of system calls. What do you guys think? I'm well aware that my present templating is speedy enough for 99.9% of the use cases I will go through. Thank you for any Input
Django HTTP 500 Error
14,732,094
1
9
19,790
0
python,django,http,templates
Have you tried with another browser ? Is your custom error page larger than 512 bytes ? It seems some browsers (including Chrome) replace errors page with their own when the server's answer is shorter than 512 bytes.
0
0
0
0
2013-02-06T14:55:00.000
4
0.049958
false
14,731,988
0
0
1
1
I am creating a custom HTTP 500 error template. Why is it Django shows it when i raise an exception and not when I return HttpResponseServerError (I just get the default browser 500 error)? I find this behaviour strange...
Django with Gunicorn different ways to deploy
14,740,868
1
6
472
0
python,django,nginx,gunicorn
Use gunicorn_django [OPTIONS] myproject if you use myproject.settings
0
0
0
0
2013-02-06T17:44:00.000
1
1.2
true
14,735,464
0
0
1
1
I've been reading about deploying Django with gunicorn and I wanted to give it a try. I have found at least 3 ways of running a server with gunicorn and django: gunicorn [OPTIONS] [APP_MODULE] # tested locally and worked fine python managy.py run_gunicorn # also works fine locally gunicorn_django [OPTIONS] [SETTINGS_PATH] # I have an error due to apps/ location I have Apache with nginx (serving static files) in production at the moment, works fine but is a litle slow and want to try Gunicorn. The first 2 options worked fine locally with nginx serving static files. I want to know a couple if things: What is the difference between any option above ? What is the proper instruction to run in PRODUCTION environments ? Thank you guys.
Convert Java Google AppEngine app to Python AppEngine
14,743,018
2
0
201
0
java,python,google-app-engine
It'll be a complete rewrite. However, the server side should be independent of the client. You can have a python client for the Raspberry Pi and your server side code can still be written in Java.
0
1
0
0
2013-02-07T00:14:00.000
1
1.2
true
14,741,395
0
0
1
1
I'm a big noob to GAE, moderate level in Python, and moderate-to-rusty in Java. I am looking to convert an existing and working GAE Java app (in the Google Play store and runs on Android) into GAE Python. The end goal is to get it into the Raspberry Pi Store, so I'm assuming GAE Python would be the most seamless. Has anyone done this, assuming its even possible? Would it require a complete rewrite, or could I just write a wrapper/container?
Web2py vs django for beginner web programmer
14,742,495
6
0
4,734
0
python,django,web2py
I'm a beginner also. I started in about 8 months ago knowing no computer science, programming, powershell, or even html/css, and now I just about have a full django website ready, minus some minor issues because I need video and video is still above my head and hard to find info/learn about. Anyway, if you don't already know html/css, I used codecademy.com to learn that and some javascript, then learnpythonthehardway.org to learn python, followed by djangobook.com for django. All are great resources. They even point you in the direction of other things you need along the way. It won't be easy, but there are great learning resources available, and since I myself began learning, codecademy has also added python. I quit my job to focus on programming full time so that I can learn it while chasing a dream, so I know from personal experience that it can be done with the free resources available online. I still don't know A LOT and it will take time for things to start clicking, but if you want to learn it just start. I know you asked for expert opinions, and trust me I'm no expert, but from my experience django wasn't too bad. Yeah, you will find yourself banging your head against the wall from time to time, but communities like stackoverflow can also help you figure out answers to your questions. I don't however have any experience with web2py so I can't speak about that. Good luck!
0
0
0
0
2013-02-07T01:02:00.000
2
1
false
14,741,824
0
0
1
1
I am very interested in learning web programming.. I want to use something from python but not sure if I want to use web2py or django.. Django seems difficult to set up for a beginner such as myself.. But I do not want to throw it out just yet.. Soo what are some expert opinions on web programming frameworks? Also, if django really isn't as hard as it seems, could someone please explain how I would set it up. Thanks in advance!!
Django Text Formatting, Markup? Markdown?
14,742,935
0
0
1,434
0
python,django
You can have a look at CKEditor.
0
0
0
0
2013-02-07T01:41:00.000
4
0
false
14,742,170
0
0
1
1
I am very interested in using Django for creating a small travel blog for myself. There are a few reasons why I am more interested in using Django instead of something like Wordpress. One is that I am interested in having a grip on all the details and in the end creating something that doesn't look like a wordpress blog, the second, is that I want several blogs, one for each place I visit, which isn't natively handled by wordpress. The problem is that when I'm abroad, I want to be able to type a blog that will automatically create paragraph tags for me at the very least and handle a lot of the small html formatting tyoe things that Wordpress does for you. What is the common workflow for something like this? I don't want something crazy like TinyMCE, but something above having to type every little html tag. Thanks for the help.
Caching in Django
14,743,602
0
1
572
0
python,django,caching
Yes, Memcached is the right answer. Just take time to do it.
0
0
0
0
2013-02-07T04:14:00.000
3
0
false
14,743,431
0
0
1
1
I need to implement some caching mechanism in my Python/Django project. Currently our live site is in Heroku cloud. Which is the best caching mechanism to use i.e 'Local-memory caching' ,'Filesystem caching' or 'Database caching'? I need to easily implement this in our live heroku cloud environment. One of my friend suggested to use 'python Memcached'. But its really difficult to set up. My time is minimal. Can anyone advise me on this, please? Thanks in advance...
How should our devs test python SVN branches with Jenkins?
14,828,819
3
4
601
0
python,svn,jenkins,continuous-integration,release
The question is a bit too big to be answered in a simple post, I will therefore try to give a few hints and references as far as I see from my personal view: A few quick tips: I like the idea of separating the developers into branches, but I would do the testing on the feature-branch and only merge to the beta branch if the feature passes tests, this way nothing enters beta until it is tested! I would put the integration steps into a script outside of Jenkins. Make it part of the source code. This way you can test the script itself quickly outside of Jenkins Use the build-system or scripting language you feel most comfortable with, most of the steps can easily done with any programming language Make the script return success or failure, so Jenkins can flag the build as failed For the merge-issues, you have two possibilities Require the branch to be manually rebased before a developer can submit it for integration, check in the script and fail it if a rebase is necssary. This way merge-errors cannot happen, the build simply fails if the branch is not rebased If you rather allow non-rebased merges, you need to fail the build on merge errors so the developer can manually resolve the problem (by rebasing his/her branch before submitting again) Here some books that I found useful in this area: How Google Tests Software, by James A. Whittaker, Jason Arbon, Jeff Carollo Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation by Jez Humble Let me know via comments what additional content you would like to have.
0
0
0
1
2013-02-07T15:40:00.000
2
1.2
true
14,755,065
0
0
1
1
I am working on a web project with 7 developers. I setup a beta box (debian) so that we can do testing of new code before passing it to staging. On the beta box, I setup Jenkins and would like to automate the merge/testing process. We also have a test suite which I would like to tie-in somehow. How should I test and run python web projects with SVN / Jenkins? I'm trying to formulate a good workflow. Right now each developer works on a feature branch, I run the code in the branch, if it looks good we merge it. I would love to have developers login to the beta jenkins, and tell it to build from their feature branch. Here is my plan for what Jenkins would do: Make sure the feature branch is rebased from trunk Make sure the beta branch is identical to trunk (overwriting any merged-in feature branches) Merge the feature branch into the beta branch Kill the running server Start the server nohup python app.py & Run the test suite python test.py Output the test data to the developer's view in Jenkins If any of the tests fail, revert to the state before the branch was merged I'm not sure how to handle merge conflicts. Also, the above is probably bad and wrong. Any advice would be appreciated!
API to copy music to iPod
14,756,354
5
1
258
0
java,python,ipod
I believe the transfer protocol between iTunes and ipod is a closed one..and hence dont think there is a publicly available protocol.
0
0
0
0
2013-02-07T16:40:00.000
2
0.462117
false
14,756,286
0
0
1
1
Is there an API to copy music (files on disk) to an iPod? Any language will do, but preferably Java or python.
How to connect to a different database in OpenERP?
14,796,657
1
1
1,877
1
python,xml-rpc,openerp
One way to connect to an external application is to create a connector module. There are already several connector modules that you can take a look at: the thunderbird and outlook plugins the joomla and magento modules the 'event moodle' module For example, the joomla connector uses a joomla plugin to handle the communication between OpenERP and joomla. The communication protocol used is XML-RPC but you can choose any protocol you want. You can even choose to connect directly to the external database using the psycopg2 modules (if the external database is using Postgresql) but this is not recommended. But perhaps you don't have the choice if this external application has no connection API. You need to know what are the available ways to connect to this external application and choose one of these. Once you have chosen the right protocol, you can create your OpenERP module. You can map entities stored on the external application using osv.TransientModel objects (formerly known as osv memory). The tables related to these objects will still be created in the OpenERP database but the data is volatile (deleted after some time).
0
0
0
0
2013-02-07T16:45:00.000
1
0.197375
false
14,756,365
0
0
1
1
How would one go about connecting to a different database based on which module is being used? Our scenario is as follows: We have a standalone application with its own database on a certain server and OpenERP running on different server. We want to create a module in OpenERP which can utilise entities on the standalone application server rather than creating its own entities in its own database, is this possible? How can we change the connection parameters that the ORM uses to connect to its own database to point to a different database? Ofcourse, one way is to use the base_synchro module to synchronise the required entities between both database but considering the large amount of data, we don't want duplication. Another way is to use xmlrpc to get data into OpenERP but that still requires entities to be present in OpenERP database. How can we solve this problem without data duplication? How can a module in OpenERP be created based on a different database?
Psycopg missing module in Django
15,337,328
1
2
1,586
1
python,django,pip,psycopg2,psycopg
This was solved by performing a clean reinstall of django. There was apparently some dependecies missing that the recursive pip install did not seem to be able to solve.
0
0
0
0
2013-02-07T18:10:00.000
2
1.2
true
14,758,024
0
0
1
1
I have pip installed psycopg2, but when I try to runserver or syncdb in my Django project, it raises an error saying there is "no module named _psycopg". EDIT: the "syncdb" command now raises: django.core.exceptions.ImproperlyConfigured: ImportError django.contrib.admin: No module named _psycopg Thanks for your help
Django code changes not reflecting on production server
14,770,990
2
11
6,659
0
python,django,apache,caching,memcached
You have to restart your server (WSGI, UWSGI or whatever your use on production environment)
0
0
0
0
2013-02-08T10:55:00.000
3
0.132549
false
14,770,972
0
0
1
1
I changed a .py file and changes reflected on local dev. server for Django after deleting .pyc. The production server does not even have .pyc for this specific file. Tried touching apache wsgi and restarting apache on prod. server but no luck. Even deleting this .py file makes application work the same. There is memcached installed but I don't have much idea how it caches, there is .git as well and 5 servers are hosting - one main, 4 load balancers. Regards !
Keep Secret Keys Out
53,798,521
2
29
26,432
0
python,django,settings
Here's one way to do it that is compatible with deployment on Heroku: Create a gitignored file named .env containing: export DJANGO_SECRET_KEY = 'replace-this-with-the-secret-key' Then edit settings.py to remove the actual SECRET_KEY and add this instead: SECRET_KEY = os.environ['DJANGO_SECRET_KEY'] Then when you want to run the development server locally, use: source .env python manage.py runserver When you finally deploy to Heroku, go to your app Settings tab and add DJANGO_SECRET_KEY to the Config Vars.
0
0
0
1
2013-02-09T07:49:00.000
7
0.057081
false
14,786,072
0
0
1
4
One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS keys, etc.. values into settings files has problem: Secrets often should be just that: secret! Keeping them in version control means that everyone with repository access has access to them. My question is how to keep all keys as secret?
Keep Secret Keys Out
14,786,575
6
29
26,432
0
python,django,settings
Store your local_settings.py data in a file encrypted with GPG - preferably as strictly key=value lines which you parse and assign to a dict (the other attractive approach would be to have it as executable python, but executable code in config files makes me shiver). There's a python gpg module so that's not a problem. Get your keys from your keyring, and use the GPG keyring management tools so you don't have to keep typing in your keychain password. Make sure you are reading the data straight from the encrypted file, and not just creating a decrypted temporary file which you read in. That's a recipe for fail. That's just an outline, you'll have to build it yourself. This way the secret data remains solely in the process memory space, and not in a file or in environment variables.
0
0
0
1
2013-02-09T07:49:00.000
7
1
false
14,786,072
0
0
1
4
One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS keys, etc.. values into settings files has problem: Secrets often should be just that: secret! Keeping them in version control means that everyone with repository access has access to them. My question is how to keep all keys as secret?
Keep Secret Keys Out
14,786,114
5
29
26,432
0
python,django,settings
Ideally, local_settings.py should not be checked in for production/deployed server. You can keep backup copy somewhere else, but not in source control. local_settings.py can be checked in with development configuration just for convenience, so that each developer need to change it. Does that solve your problem?
0
0
0
1
2013-02-09T07:49:00.000
7
0.141893
false
14,786,072
0
0
1
4
One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS keys, etc.. values into settings files has problem: Secrets often should be just that: secret! Keeping them in version control means that everyone with repository access has access to them. My question is how to keep all keys as secret?
Keep Secret Keys Out
46,735,039
0
29
26,432
0
python,django,settings
You may need to use os.environ.get("SOME_SECRET_KEY")
0
0
0
1
2013-02-09T07:49:00.000
7
0
false
14,786,072
0
0
1
4
One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS keys, etc.. values into settings files has problem: Secrets often should be just that: secret! Keeping them in version control means that everyone with repository access has access to them. My question is how to keep all keys as secret?
Can I get the browser width and height in Pyramid?
14,802,581
7
1
118
0
python,pyramid
No, that is not possible to determine with server-side code only. Browsers do not share that information when making HTTP requests to the server. You'll have to do this with JavaScript.
0
0
0
1
2013-02-10T20:21:00.000
1
1.2
true
14,802,197
0
0
1
1
Is it possible to get the user's browser width and height in Pyramid? I've searched through the response object and Googled. If it's not available in Pyramid, I'll just grab it in javascript
Matching contents of an html file with keyword python
14,815,973
1
0
168
0
python,html,compare,match
import urllib and use urllib.urlopen for getting the contents of an html. import re to search for the hash code using regex. You could also use find method on the string instead of regex. If you encounter problems, then you can ask more specific questions. Your question is too general.
0
0
1
0
2013-02-11T15:59:00.000
2
1.2
true
14,815,856
0
0
1
1
I am making a download manager. And I want to make the download manager check the md5 hash of an url after downloading the file. The hash is found on the page. It needs to compute the md5 of the file ( this is done), search for a match on the html page and then compare the WHOLE contents of the html page for a match. my question is how do i make python return the whole contents of the html and find a match for my "md5 string"?
Python with xampp
14,820,176
0
0
89
0
python,apache
you need Choose a web framework. CherryPy. Pylons. Django.
0
0
0
0
2013-02-11T20:15:00.000
1
1.2
true
14,820,071
0
0
1
1
I want to create a .py file and display simple html code, just like I simply open any php file. I've put file.py inside of the c:/xampp/cgi-bin directory, I've enagled .py extension in apache configs, but...am I doing this the right way? What next? How to open this file? localhost/cgi-bin/file.py displays the internal server 500 error with the note "Apache/2.4.2 (Win32) OpenSSL/1.0.1c PHP/5.4.4" at the bottom.
Using Amazon SWF To communicate between servers
14,829,925
1
9
3,687
0
python,linux,amazon-web-services,boto,amazon-swf
You can use SNS, When script A is completed it should trigger SNS, and that will trigger a notification to Server B
0
0
1
0
2013-02-12T09:44:00.000
4
0.049958
false
14,829,562
0
0
1
2
Use Amazon SWF to communicate messages between servers? On server A I want to run a script A When that is finished I want to send a message to server B to run a script B If it completes successfully I want it to clear the job from the workflow queue I’m having a really hard time working out how I can use Boto and SWF in combination to do this. I am not after some complete code but what I am after is if anyone can explain a little more about what is involved. How do I actually tell server B to check for the completion of script A? How do I make sure server A wont pick up the completion of script A and try and run script B (since server B should run this)? How do I actually notify SWF of script A completion? Is thee a flag, or a message, or what? I’m pretty confused about all of this. What design should I use?
Using Amazon SWF To communicate between servers
14,881,688
5
9
3,687
0
python,linux,amazon-web-services,boto,amazon-swf
I don't have any example code to share, but you can definitely use SWF to coordinate the execution of scripts across two servers. The main idea with this is to create three pieces of code that talk to SWF: A component that knows which script to execute first and what to do once that first script is done executing. This is called the "decider" in SWF terms. Two components that each understand how to execute the specific script you want to run on each machine. These are called "activity workers" in SWF terms. The first component, the decider, calls two SWF APIs: PollForDecisionTask and RespondDecisionTaskCompleted. The poll request will give the decider component the current history of an executing workflow, basically the "where am i" state information for your script runner. You write code that looks at these events and figure out which script should execute. These "commands" to execute a script would be in the form of a scheduling of an activity task, which is returned as part of the call to RespondDecisionTaskCompleted. The second components you write, the activity workers, each call two SWF APIs: PollForActivityTask and RespondActivityTaskCompleted. The poll request will give the activity worker an indication that it should execute the script it knows about, what SWF calls an activity task. The information returned from the poll request to SWF can include single execution-specific data that was sent to SWF as part of the scheduling of the activity task. Each of your servers would be independently polling SWF for activity tasks to indicate the execution of the local script on that host. Once the worker is done executing the script, it calls back to SWF through the RespondActivityTaskCompleted API. The callback from your activity worker to SWF results in a new history being handed out to the decider component that I already mentioned. It will look at the history, see that the first script is done, and schedule the second one to execute. Once it sees that the second one is done, it can "close" the workflow using another type of decision. You kick off the whole process of executing the scripts on each host by calling the StartWorkflowExecution API. This creates the record of the overall process in SWF and kicks out the first history to the decider process to schedule the execution of the first script on the first host. Hopefully this gives a bit more context on how to accomplish this type of workflow using SWF. If you haven't already, I would take a look at the dev guide on the SWF page for additional info.
0
0
1
0
2013-02-12T09:44:00.000
4
0.244919
false
14,829,562
0
0
1
2
Use Amazon SWF to communicate messages between servers? On server A I want to run a script A When that is finished I want to send a message to server B to run a script B If it completes successfully I want it to clear the job from the workflow queue I’m having a really hard time working out how I can use Boto and SWF in combination to do this. I am not after some complete code but what I am after is if anyone can explain a little more about what is involved. How do I actually tell server B to check for the completion of script A? How do I make sure server A wont pick up the completion of script A and try and run script B (since server B should run this)? How do I actually notify SWF of script A completion? Is thee a flag, or a message, or what? I’m pretty confused about all of this. What design should I use?
Shopify Python API: How do I add a product to a collection?
56,934,353
0
1
4,023
0
python,django,api,shopify
The documentation is again not promising but one thing to bear in mind is that there should in actual fact be an existing collection already created Find it by using this code collection_id = shopify.CustomCollection.find(handle=<your_handle>)[0].id then consequently add the collection_id, product_id to a Collect object and save, remember to first save your product (or have an existing one which you can find) and then only save your collection, or else the collection won't know what product its posting to (via the api), like so new_product = shopify.Product() new_product.save() add_collection = shopify.Collect('product_id': new_product.id, 'collection_id': collection_id}) add_collection.save() Also important to note that there is a 1 to 1 relationship between Product and Collect
0
0
0
0
2013-02-13T03:30:00.000
3
0
false
14,845,942
0
0
1
1
I am using the Shopify Python API in an django app to interact with my Shopify Store. I have a collection - called - best sellers. I am looking to create a batch update to this collection - that is add/remove products to this collection. However, they python API docs does not seem to say much about how to do so. How do I fetch a collection by name? How do I add a product to it? Thank you for your help. This is what I found x=shopify.CustomCollection.find(handle="best-sellers") y=shopify.Collect() #creates a new collect p = shopify.Product.find(118751076) # gets me the product So the questions is how do I add the product "p" above to the Custom Collection "x" ?
How to include third party Python libraries in Google App Engine?
14,850,874
0
33
23,439
0
python,google-app-engine
Just put Beautifulsoup in the root of your project and upload it all
0
1
0
0
2013-02-13T10:01:00.000
6
0
false
14,850,853
0
0
1
2
How to add third party python libraries in Google App Engine, which are not provided by Google? I am trying to use BeautifulSoup in Google App Engine and unable to do so. But my question is for any library I want to use in Google App Engine.
How to include third party Python libraries in Google App Engine?
35,193,844
0
33
23,439
0
python,google-app-engine
pip install -t lib package_name lib: the location for third party libraries Then you are good to use this package like a normal library you use from ipython or terminal.
0
1
0
0
2013-02-13T10:01:00.000
6
0
false
14,850,853
0
0
1
2
How to add third party python libraries in Google App Engine, which are not provided by Google? I am trying to use BeautifulSoup in Google App Engine and unable to do so. But my question is for any library I want to use in Google App Engine.
Python script handler for Google AppEngine
14,868,496
2
0
100
0
python,google-app-engine,urlfetch,app.yaml
The myScript.py was for the 2.5 runtime, the model for invoking apps with 2.7 runtime normally utilises the myScript.app method. Have a look at the age of the tutorials and also what Python runtime they have configured in their app.yaml.
0
1
0
0
2013-02-14T04:44:00.000
1
0.379949
false
14,867,945
0
0
1
1
I am writing an app engine application to fetch url content using urlfetch available in google app engine. however in the app.yaml file, I have a doubt in script handle I have found that some people use script name as myScript.py while some tutorials use myScript.app what's the difference between the two uses ?
Crawling a page using LazyLoader with Python BeautifulSoup
16,251,642
1
3
1,587
0
python,python-2.7,lazy-loading,beautifulsoup
It turns out that the problem itself wasn't BeautifulSoup, but the dynamics of the page itself. For this specific scenario that is. The page returns part of the page, so headers need to be analysed and sent to the server accordingly. This isn't a BeautifulSoup problem itself. Therefore, it is important to take a look at how the data is loaded on a specific site. It's not always a "Load a whole page, process the whole page" paradigm. In some cases, you need to load part of the page and send a specific parameter to the server in order to keep loading the rest of the page.
0
0
1
0
2013-02-14T04:49:00.000
1
1.2
true
14,868,003
0
0
1
1
I am toying around with BeautifulSoup and I like it so far. The problem is the site I am trying to scrap has a lazyloader... And it only scraps one part of the site. Can I have a hint as to how to proceed? Must I look at how the lazyloader is implemented and parametrize anything else?
postgres : relation there even after dropping the database
14,880,796
1
0
88
1
python,django,postgresql
Most likely somewhere along the line, you created your objects in the template1 database (or in older versions the postgres database) and every time you create a new db i thas all those objects in it. You can either drop the template1 / postgres database and recreate it or connect to it and drop all those objects by hand.
0
0
0
0
2013-02-14T07:23:00.000
2
0.099668
false
14,869,718
0
0
1
2
I dropped my database that I had previously created for django using : dropdb <database> but when I go to the psql prompt and say \d, I still see the relations there : How do I remove everything from postgres so that I can do everything from scratch ?
postgres : relation there even after dropping the database
14,870,374
0
0
88
1
python,django,postgresql
Chances are that you never created the tables in the correct schema in the first place. Either that or your dropdb failed to complete. Try to drop the database again and see what it says. If that appears to work then go in to postgres and type \l, putting the output here.
0
0
0
0
2013-02-14T07:23:00.000
2
0
false
14,869,718
0
0
1
2
I dropped my database that I had previously created for django using : dropdb <database> but when I go to the psql prompt and say \d, I still see the relations there : How do I remove everything from postgres so that I can do everything from scratch ?
decoder zip not available (Windows 7)
24,042,390
2
4
1,765
0
django,python-imaging-library
I was able to solve this cleanly on Windows with pip install --use-wheel Pillow. I'm not sure what changed because the PILLOW installs used to work on my windows setup. I must have some mixed versions or the default behaviors have changed.
0
0
0
0
2013-02-14T09:22:00.000
3
0.132549
false
14,871,454
1
0
1
1
I installed django-photologue. But then when I try to save a photo in django admin it throws this error: 'decoder zip not available' I have already un-installed and re-installed PIL. I hope someone can help me with the complete steps on how to overcome this error.
How should I establish and manage database connections in a multi-module Python app?
14,883,719
4
17
6,022
1
python,mysql
MySQL connections are relatively fast, so this might not be a problem (i.e. you should measure). Most other databases take much more resources to create a connection. Creating a new connection when you need one is always the safest, and is a good first choice. Some db libraries, e.g. SqlAlchemy, have connection pools built in that transparently will re-use connections for you correctly. If you decide you want to keep a connection alive so that you can re-use it, there are a few points to be aware of: Connections that are only used for reading are easier to re-use than connections that that you've used to modify database data. When you start a transaction on a connection, be careful that nothing else can use that connection for something else while you're using it. Connections that sit around for a long time get stale and can be closed from underneath you, so if you're re-using a connection you'll need to check if it is still "alive", e.g. by sending "select 1" and verifying that you get a result. I would personally recommend against implementing your own connection pooling algorithm. It's really hard to debug when things go wrong. Instead choose a db library that does it for you.
0
0
0
0
2013-02-14T20:20:00.000
2
0.379949
false
14,883,346
0
0
1
2
We have a Python application with over twenty modules, most of which are shared by several web and console applications. I've never had a clear understanding of the best practice for establishing and managing database connection in multi module Python apps. Consider this example: I have a module defining an object class for Users. It has many defs for creating/deleting/updating users in the database. The users.py module is imported into a) a console based utility, 2) a web.py based web application and 3) a constantly running daemon process. Each of these three application have different life cycles. The daemon can open a connection and keep it open. The console utility connects, does work, then dies. Of course the http requests are atomic, however the web server is a daemon. I am currently opening, using then closing a connection inside each function in the Users class. This seems the most inefficient, but it works in all examples. An alternative used as a test is to declare and open a global connection for the entire module. Another option would be to create the connection at the top application layer and pass references when instantiating classes, but this seems the worst idea to me. I know every application architecture is different. I'm just wondering if there's a best practice, and what it would be?
How should I establish and manage database connections in a multi-module Python app?
14,883,590
16
17
6,022
1
python,mysql
The best method is to open a connection when you need to do some operations (like getting and/or updating data); manipulate the data; write it back to the database in one query (very important for performance), and then close the connection. Opening a connection is a fairly light process. Some pitfalls for performance include opening the database when you won't definitely interact with it using selectors that take more data than you need (e.g., getting data about all users and filtering it in Python, instead of asking MySQL to filter out the useless data) writing values that haven't changed (e.g. updating all values of a user profile, when just their email has changed) having each field update the server individually (e.g., open the db, update the user email, close the db, open the db, update the user password, close the db, open th... you get the idea) The bottom line is that it doesn't matter how many times you open the database, it's how many queries you run. If you can get your code to join related queries, you've won the battle.
0
0
0
0
2013-02-14T20:20:00.000
2
1.2
true
14,883,346
0
0
1
2
We have a Python application with over twenty modules, most of which are shared by several web and console applications. I've never had a clear understanding of the best practice for establishing and managing database connection in multi module Python apps. Consider this example: I have a module defining an object class for Users. It has many defs for creating/deleting/updating users in the database. The users.py module is imported into a) a console based utility, 2) a web.py based web application and 3) a constantly running daemon process. Each of these three application have different life cycles. The daemon can open a connection and keep it open. The console utility connects, does work, then dies. Of course the http requests are atomic, however the web server is a daemon. I am currently opening, using then closing a connection inside each function in the Users class. This seems the most inefficient, but it works in all examples. An alternative used as a test is to declare and open a global connection for the entire module. Another option would be to create the connection at the top application layer and pass references when instantiating classes, but this seems the worst idea to me. I know every application architecture is different. I'm just wondering if there's a best practice, and what it would be?
Checking if a user disconnects using Flask
14,915,333
2
1
1,304
0
python,flask
Basically you can't tell that the user has left your site on the server-side. The common way to do what you want to achieve is to use a time limit after the last known request as a cutoff between the online/offline states. To make this more accurate you can have a script on the client-side that does regular AJAX polling, if you must consider that a user is online long after their last request while your site is still open in a tab. If you must check that the user has the tab active, make that request conditional on recent mouse or keyboard events.
0
0
1
0
2013-02-15T00:13:00.000
1
1.2
true
14,886,400
0
0
1
1
I am trying to check if a user disconnects from my site, how would I go about doing this? I am doing this in order to check if a user is "online" or not.
socketio in python
14,888,521
0
0
475
0
django,python-2.7,socket.io,gevent,gevent-socketio
I think what you want is from socketio.server import SocketIOServer
0
0
1
0
2013-02-15T04:49:00.000
2
0
false
14,888,428
0
0
1
2
Kindly help me in configuring the socketio in my django module. Am using windows7 OS File wsgi.py Sample Code - from socketio import SocketIOServer Error - Unresolved import:SocketIOServer Am new to python and Django Frameworks.!
socketio in python
53,155,835
1
0
475
0
django,python-2.7,socket.io,gevent,gevent-socketio
Try this: pip install socketIO-server
0
0
1
0
2013-02-15T04:49:00.000
2
0.099668
false
14,888,428
0
0
1
2
Kindly help me in configuring the socketio in my django module. Am using windows7 OS File wsgi.py Sample Code - from socketio import SocketIOServer Error - Unresolved import:SocketIOServer Am new to python and Django Frameworks.!
How can I open two log files in one HTML page in Django?
14,888,883
0
2
282
0
python,linux,django,django-class-based-views
Create a new view in Django in the controller, import os use lastLines = os.popen("tail /path/to/logFile").read() show these listLines in the view
0
0
0
0
2013-02-15T05:33:00.000
2
0
false
14,888,843
0
0
1
1
I have my two log files in my django root dir called apache.error.log and django.log. In my app/static folder I have the HTML file mylog.html. Now I want to view those log files inside that HTML page. Is this possible? I want to view the last 20 lines of both files. basically something like tail -f, but inside the browser so that I can have my one tab always open for debugging.
Search engine from scratch
14,889,522
3
0
643
1
python,mysql,search,search-engine
The best bet for you to do "Search Engine" for the 10,000 Articles is to read "Programming Collective Intelligence" by Toby Segaran. Wonderful read and to save your time go to Chapter 4 of August 2007 issue.
0
0
0
0
2013-02-15T06:10:00.000
2
0.291313
false
14,889,206
0
0
1
1
I have a MySQL database with around 10,000 articles in it, but that number will probably go up with time. I want to be able to search through these articles and pull out the most relevent results based on some keywords. I know there are a number of projects that I can plug into that can essentially do this for me. However, the application for this is very simple, and it would be nice to have direct control and working knowledge of how the whole thing operates. Therefore, I would like to look into building a very simple search engine from scratch in Python. I'm not even sure where to start, really. I could just dump everything from the MySQL DB into a list and try to sort that list based on relevance, however that seems like it would be slow, and get slower as the amount of database items increase. I could use some basic MySQL search to get the top 100 most relevant results from what MySQL thinks, then sort those 100. But that is a two step process which may be less efficient, and I might risk missing an article if it is just out of range. What are the best approaches I can take to this?
Django: how to make STATIC_URL empty?
14,902,498
1
2
294
0
python,django
I believe this is not supported out of the box. Off the top of my head, one way to do it would be with a special 404 handler that, having failed to match against any of the defined URLs, treats the request as a request for a static resource. This would be reasonably easy to do in the development environment but significantly more difficult when nginx, Apache, and/or gunicorn get involved. In other words, don't do this. Nest your statics (or put them on a different sub domain) but don't mix the URL hierarchy in this way.
0
0
0
0
2013-02-15T19:34:00.000
2
0.099668
false
14,902,023
0
0
1
1
Yep, I want it to work like in Flask framework - there I could set parameters like this: static_folder=os.getcwd()+"/static/", static_url_path="" and all the files that lies in ./static/files/blabla.bla would be accessible by mysite.com/files/blabla.bla address. I really don't want to add static after mysite.com. But if I set STATIC_URL = '/' in Django then I could get my static files by this address, but suddenly I could not fetch my pages that described in urls.py.
How large data can memcached handle efficiently?
14,907,596
2
1
2,162
0
python,django,caching,memcached
Memcached is more or less only limited by available (free) memory in the number of servers you run it on. The more memory, the more data fits, and since it uses fairly efficient in-memory indexes, you won't really see performance degrade in any significant way with more objects. Remember though, it's a cache and there is no guarantee that you'll be able to retrieve what you put in. More memory will make memcached try to keep more data in memory, but there is no guarantee that it won't just throw data away even if memory is available if it somehow finds that a better idea.
0
0
0
0
2013-02-16T05:56:00.000
2
0.197375
false
14,907,457
0
0
1
1
How large values can I store and retrieve from memcached without degrading its performance? I am using memcached with python-memcached in a django based web application.
Is there a Python Memcached library with support for AWS ElastiCache's auto-discovery feature?
14,924,764
1
2
2,949
0
python,memcached,amazon-elasticache
As far as I know, ElastiCache cluster is just a bunch of memcached servers, so you need to give your memcached client the list of all of your servers and have the client do the relevant load balancing. For Python, you have a couple of options: pylibmc - which is a wrapper around libmemcached - one of the best and fastest memcached clients there is python-memcached - a native Python client - very basic, but easy to work with, install and use They haven't provided a client yet in python to deal with the new auto-discovery feature unfortunately.
0
1
0
0
2013-02-17T18:35:00.000
3
1.2
true
14,924,586
0
0
1
1
Recently, AWS announced ElastiCache's auto-discovery feature, although they only officially released a client for Java. Does anyone know of a Python Memcached library with support for this feature?
find django/contrib/admin/templates
14,931,827
0
14
15,440
0
python,django,ubuntu,django-templates
Should be here: /usr/lib/python2.7/site-packages/django/contrib/admin/templates
0
0
0
0
2013-02-18T08:04:00.000
6
0
false
14,931,793
0
0
1
3
I have trouble to see django/contrib/admin/templates folder. It seems like it is hidden in /usr/lib/python2.7/dist-packages/ folder, ctrl+h wont help ( appearencely all django files are hidden). "locate django/contrib/admin/templates" in terminal shows bunch of files, but how can i see those files in GUI? I use Ubuntu 12.10 Thanks in advance
find django/contrib/admin/templates
14,931,847
0
14
15,440
0
python,django,ubuntu,django-templates
Since, everyone is posting my comment's suggestion, might as well post it myself. Try looking at: /usr/lib/python2.6/site-packages/django/
0
0
0
0
2013-02-18T08:04:00.000
6
0
false
14,931,793
0
0
1
3
I have trouble to see django/contrib/admin/templates folder. It seems like it is hidden in /usr/lib/python2.7/dist-packages/ folder, ctrl+h wont help ( appearencely all django files are hidden). "locate django/contrib/admin/templates" in terminal shows bunch of files, but how can i see those files in GUI? I use Ubuntu 12.10 Thanks in advance
find django/contrib/admin/templates
53,451,127
0
14
15,440
0
python,django,ubuntu,django-templates
If you are using Python3, Django is located at your venv. In my case templates are located at <project_root>/venv/lib/python3.5/site-packages/django/contrib/admin/templates/.
0
0
0
0
2013-02-18T08:04:00.000
6
0
false
14,931,793
0
0
1
3
I have trouble to see django/contrib/admin/templates folder. It seems like it is hidden in /usr/lib/python2.7/dist-packages/ folder, ctrl+h wont help ( appearencely all django files are hidden). "locate django/contrib/admin/templates" in terminal shows bunch of files, but how can i see those files in GUI? I use Ubuntu 12.10 Thanks in advance
conditional xpath? need xpath if more specific xpath is matched
14,946,219
0
0
153
0
python,xpath
You could do the matching in XPath, and then simply take the resulting nodes parent in Python.
0
0
1
0
2013-02-18T20:39:00.000
3
0
false
14,944,900
0
0
1
1
I'm trying to create a list of dicts with two data items. The page I'm looking at has 37 matches for //div[@id='content']/*[self::p or self::h2]/a[2]; however, it only has 33 matches for //div[@id='content']/*[self::p or self::h2]/a[contains(@href,'game')]/img[@src] The two xpaths have //div[@id='content']/*[self::p or self::h2] in common. I effectively only want to get the element matched for the first xpath if the second xpath is matched, and leave the 4 without the second element behind. I'm hoping that this can be accomplished with xpath but if not, could use some advice on writing a function that achieves this in python.
How to disable Google App Engine python SDK import hook?
14,950,038
0
1
158
0
python,google-app-engine
Easiest thing is to modify google/appengine/tools/dev_appserver_import_hook.py and add the module you want to the whitelist. This will allow you to import whatever you want. Now there's a good reason that the imports are restricted in the development server. The restricted imports match what's available on the production environment. So if you add libraries to the whitelist, your code may run on your local development server, but it will not run on the production environment. And no, you can't import restricted modules on production.
0
1
0
0
2013-02-19T00:35:00.000
1
0
false
14,947,860
0
0
1
1
I am playing around with local deployment of GAE python SDK. The code that I am trying to run contains many external libraries which are not part of GAE import whitelist. I want to disable the import restrictions and let GAE app import any locally installed module. After walking through the code, I figured out that they use custom import hooks for restricting imports. However, I have not been able to figure out how to disable the overridden import hook. Let me know if you have any idea how this can be accomplished.
Django 1.5 custom user model plus admin.autodiscover() breaks app
14,964,876
1
1
1,388
0
python,django,django-admin,django-authentication
I set up a brand new empty project with a custom user model and attempted to recreate the situation, which led to a diagnosis: we had added the django-usertools package to the project, which has not been updated for Django 1.5 and apparently conflicts with custom user models. Removing that package from the installed apps list in settings resolved the issue.
0
0
0
0
2013-02-19T02:28:00.000
2
1.2
true
14,948,810
0
0
1
1
I have a custom user model (it's actually named User as I didn't see any need to name it otherwise) in my Django 1.5c1 project (currently running on the latest from the Django 1.5 branch on github). AUTH_USER_MODEL is defined in my settings properly, so the auth module works correctly and I can log in etc. fine. However, with the custom user module enabled, the admin site doesn't work. When I add admin.autodiscover() to my urls.py, every page on the site (not just admin pages) throws a NotRegistered exception and says The model User is not registered. The traceback shows that admin.autodiscover() is trying to call admin.site.unregister(User), apparently before it has registered that model. I tried renaming my user model to something other than User, but it didn't seem to work. I also tried creating my own admin.py for that app, and then I tried manually registering my custom User model with the custom UserAdmin model specified in admin.py before admin.autodiscover() ran, but that actually caused a separate exception saying that User was already registered. What should I try next in order to get admin.autodiscover() working?
Installing Pyramid without the template systems (Mako and Chameleon)
14,950,809
2
1
314
0
python,pyramid
There is a project to eventually remove those templating dependancies and make them available as separate packages. The work started at last year pycon sprints and can be continued this year, who knows. OTOH having those packages installed in your venv doesn't really affect your app so just avoid using them and only use the JSON renderer or any other renderers. Instead of forking Pyramid and removing those dependancies in setup.py I propose you to join us and work on the removal project so we can all benefit the same features.
0
0
0
1
2013-02-19T03:57:00.000
1
0.379949
false
14,949,586
0
0
1
1
Is there a "good way" to install Pyramid without the templating systems? The templating systems I speak of are Mako and Chameleon. In Single Page Applications (SPA) there is very little need for server-side templating since all of the templates are rendered on the client-side with javascript. I like the power of Pyramid but the template system is unnecessary baggage in some cases. I have a feeling that the only way to accomplish this task is to fork Pyramid and modify the setup.py to remove these dependencies. That may break things,but then again, Pyramid is built in such a way that it may not care as long as nothing tries to call a renderer for one of these templates. Who knows?
need assisstance to set python2.7 as default & Django to install
14,955,895
1
0
143
0
linux,django,python-2.7,centos
Your CentOS relies on python 2.4 so that's not going to work. You should probably create a new system user and install pyton 2.7 in its home directory (or use your root user and install python in /opt for global usage), you can find plenty of tutorials on Google. After succesfully doing so, you can set an alias in your user's bash profile to define which python version to use. It's also common practice to create a virtualenv for each project and/or user.
0
1
0
0
2013-02-19T10:43:00.000
1
1.2
true
14,955,468
0
0
1
1
I am not able to install Django.I am using CentOS 5,not able to set python2.7 environment variable.Priviously in my system python2.4.3 is available,but after installing python 2.7 in the terminal i checked the version avail in system using "python -V"cmd it executed as python 2.4.3.But if i checked using "python2.7 -V"cmd it is showing python2.7.Please help me with this..... 1.I need to set python2.7 as default version. 2.Help me with the installation of Django.
Learning Django unit testing
14,961,957
0
2
311
0
python,django,unit-testing
Did you try core developer Karen Tracy's book Django 1.1 Testing And Debugging? Although the title implies it's out of date, most of the advice is still applicable.
0
0
0
1
2013-02-19T15:29:00.000
3
0
false
14,961,151
0
0
1
1
I'm trying to get caught up on unit testing, and I've looked over a few books - Debugging Django, Web Dev. with Django, and the official docs, but none seem to cover unit testing thoroughly enough for me. I'm also not an expert in Python web development, so maybe that's why. What I'm looking for is something that starts at an intermediate level of python skill/knowledge and covers Django unit testing from scratch, with a few good real-world examples. Any recommendations on such resources? Much appreciated.
Running a script on EC2 start and stop
14,966,165
1
1
1,561
0
python,linux,amazon-web-services,amazon-ec2,amazon-rds
It is possible. You just have to write an init script and setup proper symbolic links in /etc/rc#.d directories. It will be started with a parameter start or stop depending on if machine is starting up or shutting down.
0
1
1
1
2013-02-19T16:26:00.000
1
1.2
true
14,962,414
0
0
1
1
I have an Amazon Ubuntu instance which I stop and start (not terminate). I was wondering if it is possible to run a script on start and stop of the server. Specifically, I am looking at writting a python boto script to take my RDS volume offline when the EC2 server is not running. Can anyone tell me if this is possible please?
Retranslation audio stream with python on Google App Engine
14,964,896
1
1
193
0
python,google-app-engine,audio-streaming
You can't make long running external calls with App Engine. Maximum deadline (task queue and cron job handler) for UrlFetch is 10 minutes. So, I think it is not possible.
0
1
0
0
2013-02-19T18:25:00.000
1
1.2
true
14,964,717
0
0
1
1
I have a URL address to the audio stream, how I can retranslate it in the web with my address (myapp.appspot.com)? Let me explain why I need it: I have a very narrow channel, and will not stand many connections, so I have to do it with GAE Thanks!
Why django and python MySQLdb have one cursor per database?
15,328,753
10
6
1,351
1
python,mysql,django,mysql-python
A shorter answer would be, "MySQL doesn't support that type of cursor", so neither does Python-MySQL, so the reason one connection command is preferred is because that's the way MySQL works. Which is sort of a tautology. However, the longer answer is: A 'cursor', by your definition, would be some type of object accessing tables and indexes within an RDMS, capable of maintaining its state. A 'connection', by your definition, would accept commands, and either allocate or reuse a cursor to perform the action of the command, returning its results to the connection. By your definition, a 'connection' would/could manage multiple cursors. You believe this would be the preferred/performant way to access a database as 'connections' are expensive, and 'cursors' are cheap. However: A cursor in MySQL (and other RDMS) is not a the user-accessible mechanism for performing operations. MySQL (and other's) perform operations in as "set", or rather, they compile your SQL command into an internal list of commands, and do numerous, complex bits depending on the nature of your SQL command and your table structure. A cursor is a specific mechanism, utilized within stored procedures (and there only), giving the developer a way to work with data in a procedural way. A 'connection' in MySQL is what you think of as a 'cursor', sort of. MySQL does not expose it's internals for you as an iterator, or pointer, that is merely moving over tables. It exposes it's internals as a 'connection' which accepts SQL and other commands, translates those commands into an internal action, performs that action, and returns it's result to you. This is the difference between a 'set' and a 'procedural' execution style (which is really about the granularity of control you, the user, is given access to, or at least, the granularity inherent in how the RDMS abstracts away its internals when it exposes them via an API).
0
0
0
0
2013-02-20T17:27:00.000
3
1.2
true
14,986,129
0
0
1
3
Example scenario: MySQL running a single server -> HOSTNAME Two MySQL databases on that server -> USERS , GAMES . Task -> Fetch 10 newest games from GAMES.my_games_table , and fetch users playing those games from USERS.my_users_table ( assume no joins ) In Django as well as Python MySQLdb , why is having one cursor for each database more preferable ? What is the disadvantage of an extended cursor which is single per MySQL server and can switch databases ( eg by querying "use USERS;" ), and then work on corresponding database MySQL connections are cheap, but isn't single connection better than many , if there is a linear flow and no complex tranasactions which might need two cursors ?
Why django and python MySQLdb have one cursor per database?
15,302,237
2
6
1,351
1
python,mysql,django,mysql-python
As you say, MySQL connections are cheap, so for your case, I'm not sure there is a technical advantage either way, outside of code organization and flow. It might be easier to manage two cursors than to keep track of which database a single cursor is currently talking to by painstakingly tracking SQL 'USE' statements. Mileage with other databases may vary -- remember that Django strives to be database-agnostic. Also, consider the case where two different databases, even on the same server, require different access credentials. In such a case, two connections will be necessary, so that each connection can successfully authenticate.
0
0
0
0
2013-02-20T17:27:00.000
3
0.132549
false
14,986,129
0
0
1
3
Example scenario: MySQL running a single server -> HOSTNAME Two MySQL databases on that server -> USERS , GAMES . Task -> Fetch 10 newest games from GAMES.my_games_table , and fetch users playing those games from USERS.my_users_table ( assume no joins ) In Django as well as Python MySQLdb , why is having one cursor for each database more preferable ? What is the disadvantage of an extended cursor which is single per MySQL server and can switch databases ( eg by querying "use USERS;" ), and then work on corresponding database MySQL connections are cheap, but isn't single connection better than many , if there is a linear flow and no complex tranasactions which might need two cursors ?
Why django and python MySQLdb have one cursor per database?
15,421,235
0
6
1,351
1
python,mysql,django,mysql-python
One cursor per database is not necessarily preferable, it's just the default behavior. The rationale is that different databases are more often than not on different servers, use different engines, and/or need different initialization options. (Otherwise, why should you be using different "databases" in the first place?) In your case, if your two databases are just namespaces of tables (what should be called "schemas" in SQL jargon) but reside on the same MySQL instance, then by all means use a single connection. (How to configure Django to do so is actually an altogether different question.) You are also right that a single connection is better than two, if you only have a single thread and don't actually need two database workers at the same time.
0
0
0
0
2013-02-20T17:27:00.000
3
0
false
14,986,129
0
0
1
3
Example scenario: MySQL running a single server -> HOSTNAME Two MySQL databases on that server -> USERS , GAMES . Task -> Fetch 10 newest games from GAMES.my_games_table , and fetch users playing those games from USERS.my_users_table ( assume no joins ) In Django as well as Python MySQLdb , why is having one cursor for each database more preferable ? What is the disadvantage of an extended cursor which is single per MySQL server and can switch databases ( eg by querying "use USERS;" ), and then work on corresponding database MySQL connections are cheap, but isn't single connection better than many , if there is a linear flow and no complex tranasactions which might need two cursors ?
JavaBean equivalent in Python
14,989,253
1
23
15,017
0
java,python,javabeans
Implements serializable. Pick your favorite format, and write a function that will serialize it for you. JSON, Pickle, YAML, any work. Just decide! Has getters and setters -> private properties We don't do that here, those are attributes of bondage languages, we are all adults in this language. dummy constructor Again not something we really worry about as our constructors are a little bit smarter than other languages. So you can just define one __init__ and it can do all your initialization, if you must then write a factory or subclass it.
0
0
0
0
2013-02-20T20:16:00.000
5
0.039979
false
14,989,100
1
0
1
1
I am fairly new to using Python as a OOP. I am coming from a Java background. How would you write a javabean equivalent in python? Basically, I need a class that: Implements serializable. Has getters and setters -> private properties dummy constructor Any inputs? I am looking for a sample code!
Django forms: get the value of a forms.CharField as a date
14,991,863
1
1
1,270
0
python,django,forms,date,callback
Why not just DateField instead?
0
0
0
0
2013-02-20T22:17:00.000
2
0.099668
false
14,991,002
0
0
1
1
I have a form that has a CharField input for an european date. I need to transform it to a date python object. Is there a way to let the form care about it, in the validation? some callback? I don't want to do it in the view when there's the form processing.
Django as a mysql proxy server?
14,992,070
1
3
377
1
c++,python,mysql,c,django
This is a completely valid concern and a very common problem. You have described creating a RESTful API. I guess it could be considered a proxy to a database but is not usually referred to as a proxy. Django is a great tool to use to use to accomplish this. Django even has a couple packages that will assist in speedy development, Django REST Framework, Tastiepy, and django-piston are the most popular. Of course you could just use plain old Django. Your Django project would be the only thing that interfaces with the database and clients can send authenticated requests to Django; so clients will never connect directly to your database. This will give you fine grained permission control on a per client, per resource basis. The webserver will be under a much larger load by processing all the SQL queries and this could potentially exceed the limit of my host I believe scaling a webservice is going to be a lot easier then scaling direct connections from your clients to your database. There are many tried and true methods for scaling apps that have hundreds of requests per seconds to their databases. Because you have Django between you and the webserver you can implement caching for frequently requested resources. Additionally, I would have to figure out some way of serializing and transmitting the SQL results in Python and then unserializing them in C/C++ on the client side This should be a moot issue. There are lots of extremely popular data interchange formats. I have never used C/C++ but a quick search I saw a couple of c/c++ json serializers. python has JSON built in for free, there shouldn't be any custom code to maintain regarding this if you use a premade C/C++ JSON library. Any other downsides to this approach people can think of? I don't think there are any downsides, It is a tried and true method. It has been proven for a decade and the most popular sites in the world expose themselves through restful apis Does this sound reasonable and if it does, anything that could ease working on it; such as Python or C libraries to help develop the proxy interface? It sounds very reasonable, the Django apps I mentioned at the beginning of the answer should provide some boiler plate to allow you to get started on your API quicker.
0
0
0
0
2013-02-20T23:21:00.000
1
1.2
true
14,991,783
0
0
1
1
I'm in the process of building a Django powered site that is backed by a MySQL server. This MySQL server is going to be accessed from additional sources, other than the website, to read and write table data; such as a program that users run locally which connects to the database. Currently the program running locally is using the MySQL/C Connector library to connect directly to the sql server and execute queries. In a final release to the public this seems insecure, since I would be exposing the connection string to the database in the code or in a configuration file. One alternative I'm considering is having all queries be sent to the Django website (authenticated with a user's login and password) and then the site will sanitize and execute the queries on the user's behalf and return the results to them. This has a number of downsides that I can think of. The webserver will be under a much larger load by processing all the SQL queries and this could potentially exceed the limit of my host. Additionally, I would have to figure out some way of serializing and transmitting the sql results in Python and then unserializing them in C/C++ on the client side. This would be a decent amount of custom code to write and maintain. Any other downsides to this approach people can think of? Does this sound reasonable and if it does, anything that could ease working on it; such as Python or C libraries to help develop the proxy interface? If it sounds like a bad idea, any suggestions for alternative solutions i.e. a Python library that specializes in this type of proxy sql server logic, a method of encrypting sql connection strings so I can securely use my current solution, etc...? Lastly, is this a valid concern? The database currently doesn't hold any terribly sensitive information about users (most sensitive would be their email and their site password which they may have reused from another source) but it could in the future which is my cause for concern if it's not secure.
Automatic Zabbix -> Confluence, creating too many updates
15,069,936
0
0
412
0
python,string-comparison,confluence,zabbix
This might not be the solution you are looking for, but you could have the updates generate an external html page and then use an {html-include} in confluence. So the confluence pages wouldn't be updated, but their displayed content would be correct. The problem with this is that none of the confluence pages would be updated, so if you want a feed to notify people of the changes on confluence it wouldn't get the job done.
0
0
0
1
2013-02-21T08:12:00.000
1
0
false
14,997,400
0
0
1
1
I have a python script that runs once a day, connects to our Zabbix monitoring database and pulls out all the active monitoring checks and documents them into Confluence. My problem is that each hosts' confluence page gets updated every time the script runs, even if the monitoring hasn't changed. A quick hack would be to get a hash of the page content and compare it with a hash of the script-generated content and only replace when the hashes don't match. Obviously the problems with this are that the script still needs to generate whole page content for comparison, and that it replaces the whole page or not at all, loosing confluence's built-in diff checker. I'm hoping to find a more elegant solution, especially one that may allow me to update only the differences...
Sublime Editor Tree View
15,007,333
1
1
1,374
0
javascript,python,json,sublimetext2
I don't know about tree-views but with jsFormat you can get a nice format of the json-object, basically a pretty-print. The if you'd like to get advanced, and your JSON contains a lot of objects you can always use code-folding. Although this doesn't work very well with arrays (it will fold the complete json for me atleast).
0
0
0
0
2013-02-21T13:28:00.000
1
0.197375
false
15,003,487
0
0
1
1
Is it possible to create a tree view for arbitrary data (JSON) as a plugin for Sublime Editor. I like working with javascript, and don't like having to switch to my firefox console to inspect objects. Is there an existing plugin/solution? Is it possible for me to make my own - can a tree view be displayed in Sublime Editor easily?
Even though the Google Sites API creates a site, we cannot still access the site
15,004,843
0
1
103
0
python,google-app-engine,google-sites
I think you can try to reach Google API's developers to tell them about this bug, they might not be aware of it.
0
0
1
0
2013-02-21T14:30:00.000
1
0
false
15,004,797
0
0
1
1
I m using Google Sites API in my python code deployed over Google App Engine. I have came across a problem: Google Sites API allows to create a site, add users to site(access permission),etc.., however we get status:200 form the API that site is being created and same for adding users to the Google Site, but when i go to sites.google.com to access that site it still says 'Creating your site' I can see a site locked in wait state for almost a week. We don't have any specific steps to reproduce it, this has random appearances. Please suggest what is the correct solution or if there is no perfect solution than suggest a workaround for the same.
Why do languages like Java distinguish between string and char while others do not?
15,010,424
4
7
1,089
0
java,python,ruby,string,char
Bottom line is that is just how the language designer decided to make it. It's hard to get too much further than that. However, one point about C, which is generally considered a lower-level language in that the syntax more accurately reflects the nature of the data and tasks being performed. Treating a character as a string would be a level of abstraction that would be uncharacteristic of C. It would make it less clear what the data is like under the covers. And it would almost certainly add overhead when all you needed was a character. Note that C-type languages do support single character strings, and so you really have the best of both worlds in my opinion.
0
0
0
0
2013-02-21T19:10:00.000
5
0.158649
false
15,010,360
1
0
1
2
I've noticed that languages like Java have a char primitive and a string class. Other languages like Python and Ruby just have a string class. Those languages instead use a string of length 1 to represent a character. I was wondering whether that distinction was because of historical reasons. I understand the language that directly influenced Java has a char type, but no strings. Strings are instead formed using char* or char[]. But I wasn't sure if there was an actual purpose for doing it that way. I'm also curious if one way has an advantage over another in certain situations. Why do languages like Java distinguish between the char primitive and the string class, while languages like Ruby and Python do not? Surely there must be some sort of design concern about it, be it convention, efficiency, clarity, ease of implementation, etc. Did the language designer really just pick a character representation out of a hat, so to speak?
Why do languages like Java distinguish between string and char while others do not?
15,010,789
1
7
1,089
0
java,python,ruby,string,char
I wasn't sure whether that distinction was because of historical reasons (C only has chars, strings are formed with char* or char[]) or if there was an actual purpose for doing it that way. I'm also curious if one way has an advantage over another in certain situations. In C the concept of a "string" is a character array/series of characters that is terminated by a ending character \0. Otherwise a "string" is like any other array in C. In e.g. C# and several other languages the string is treated as an abstraction, a string is more like an opaque object. The object contains methods that work on the string but exactly how the string is stored is "hidden" to the programmer. The reason for this is that C is a much older language and more close to hardware than newer languages. How a string is defined in a language (whether single or dobuble quotes are used) is really just an implementation detail that the person(s) designing the langauge thought to be a good thing at the time.
0
0
0
0
2013-02-21T19:10:00.000
5
0.039979
false
15,010,360
1
0
1
2
I've noticed that languages like Java have a char primitive and a string class. Other languages like Python and Ruby just have a string class. Those languages instead use a string of length 1 to represent a character. I was wondering whether that distinction was because of historical reasons. I understand the language that directly influenced Java has a char type, but no strings. Strings are instead formed using char* or char[]. But I wasn't sure if there was an actual purpose for doing it that way. I'm also curious if one way has an advantage over another in certain situations. Why do languages like Java distinguish between the char primitive and the string class, while languages like Ruby and Python do not? Surely there must be some sort of design concern about it, be it convention, efficiency, clarity, ease of implementation, etc. Did the language designer really just pick a character representation out of a hat, so to speak?
How to handle refactor with south (django)?
15,026,416
0
2
118
0
python,database,django,migration,django-south
Make the changes to your models then run python manage.py schemamigration yourapp --auto. This will create the migrations for you (you'll see a new file in your migrations directory every time you do this process). Sometimes you really need to edit a migration manually, but you should try and avoid it. Particularly if you have already run the migration (the south app keeps a record of which migrations have been run so it knows the state of your database). South is designed to support moving between different versions of your code without breaking your database. Each migration file in the migrations directory represents a snapshot of your code (specifically a snapshot of your models.py). You migrate from version to version by running python manage.py migrate yourapp version_no
0
0
0
0
2013-02-22T14:19:00.000
1
1.2
true
15,026,230
0
0
1
1
I have installed south and make some migrations. Now there's a 'migrations' directory in the folder app. My question is: when I am refactoring models, which entries in the migration directory files I must apply the changes? I think some entries are related directly with the database schema, and others with the code itself. I couldn't fina an answer to this in the south docs.
Is there a way to efficiently create Python objects from outside of Python?
15,027,654
8
0
65
0
python
The best answer is to use a standardized format, such as JSON, and write up something to create the objects from that format in Python, and produce the data from Java. For simple things, this will be virtually no effort, but naturally, it'll scale up. Trying to emulate pickle from within Java will be more effort than it's worth, but I guess you could look into Jython if you were really set on the idea.
0
0
0
1
2013-02-22T15:32:00.000
1
1
false
15,027,601
1
0
1
1
I want to create a serialized Python object from outside of Python (in this case, from Java) in such a way that Python can read it and treat it as if it were an object in Python. I'll start with simpler objects (int, float, String, and so on) but I'd love to know if this can be done with classes as well. Functionality is first, but being able to do it quickly is a close second. The idea is that I have some data in Java land, but some business logic in Python land. I want to be able to stream data through the python logic as quickly as possible...right now, this data is being serialized as strings and I think this is fairly wasteful. Thank you in advance
another transaction already in progress
15,033,087
5
2
3,012
0
python,google-app-engine
appcfg.py rollback C:\path\to\my\app is the required command. If you are using Java, the rollback command is same as above, but the path to the application should be to the application's target directory. Otherwise, rollback will fail.
0
1
0
0
2013-02-22T16:54:00.000
1
1.2
true
15,029,252
0
0
1
1
I am using app engine launcher in windows and for some reason the last time i deployed my app, the transaction wouldn't finish, and now every time i try to deploy i get the error another transaction by user is already in progress for app: s~ myapp, version 1 i have tried doing appcfg.py rollback, which brings up a python window, which then closes again almost immediately (i think it says error but it closes so fast i cant tell for sure) i have tried doing appcfg.py rollback C:\ my\apps\directory\path - which leads to the same as above i have tried doing C:\Program Files\Google\google_appengine appcfg.py rollback c:\my\app\path but windows then tells me it cant find C:\ program and now im stuck for things to try?
Converting postgresql timestamp to JavaScript timestamp in Python
15,032,100
3
8
4,296
1
javascript,python,postgresql,flot
You can't send a Python or Javascript "datetime" object over JSON. JSON only accepts more basic data types like Strings, Ints, and Floats. The way I usually do it is send it as text, using Python's datetime.isoformat() then parse it on the Javascript side.
0
0
0
0
2013-02-22T19:33:00.000
2
0.291313
false
15,031,856
0
0
1
1
I have a postgre database with a timestamp column and I have a REST service in Python that executes a query in the database and returns data to a JavaScript front-end to plot a graph using flot. Now the problem I have is that flot can automatically handle the date using JavaScript's TIMESTAMP, but I don't know how to convert the Postgre timestamps to JavaScript TIMESTAMP (YES a timestamp, not a date stop editing if you don't know the answer) in Python. I don't know if this is the best approach (maybe the conversion can be done in JavaScript?). Is there a way to do this?
Python on the AWS Beanstalk. How to snapshot custom logs?
15,183,303
6
15
5,607
0
python,logging,amazon-elastic-beanstalk
If you need have ability to snapshot log files from Beanstalk management console, you should just write you log files to "/opt/python/log/" folder. Elastic beanstalk scripts use this folder for log tailing.
0
1
0
0
2013-02-23T07:12:00.000
2
1.2
true
15,038,135
0
0
1
1
I'm developing python application which works on aws beanstalk environment. For error handling and debugging proposes I write logs to custom lof file on the directory /var/logs/. What should I do in order to have ability snapshot logs from Elastic beanstalk management console?
Model added by south migration doesn't show in production admin site
15,061,466
0
1
165
0
python,django,uwsgi
After some pdb play-around I finally located the problem. It's about permissions. I set the permissions differently on my dev and production databases -- I am a superuser using the dev database, but only a staff on the production database, for whatever reason. The new model I added had its permission set to only visible to superusers, so obviously I can't see it on the admin page. Everything works after I promote myself.
0
0
0
0
2013-02-23T08:06:00.000
1
0
false
15,038,509
0
0
1
1
I'm trying to add a new model to an pre-existed app on my production site with the following steps: Adding a model Add admin.site.register(<ModelName>) in the app's admin.py ./manage.py schemamigration <appname> --auto ./manage.py migrate <appname> The above steps work on my dev machine (with SQLite3), so I continued with Upload the codes (models.py, admin.py and the migration file) to the production machine Repeat step 4. on the production machine (with MySQL) service uwsgi restart The migration works. I can see the new table(s) in the database, and I can use the model correctly (with ./manage.py shell on the production machine). The only problem is that the model is not shown in the admin site. I tried: Dev site + dev database => Works. Production site + production database => Can't see the model in Admin site. Dev site + production database => Can't see the model in Admin site. Is there something I missed? Thanks.
Multiple permissions in view_config decorator?
15,057,901
5
10
1,193
0
python,web-applications,permissions,security,pyramid
Make a readwrite permission. Each view gets one and only one permission but each principal can be mapped to many permissions.
0
0
0
0
2013-02-24T18:27:00.000
1
1.2
true
15,055,029
0
0
1
1
I am configuring access control for a web application based on the Pyramid framework. I am setting up permissions for my view callables using the @view_config decorator. I have two permissions, namely 'read' and 'write'. Now, I want certain views to require both permissions. I was unable to figure out how to do this with view_config - am I missing something, or is there maybe another way to do this?
Python grabbing pages source with PHP in it
15,057,740
0
0
128
0
python,python-3.3
PHP scripts are run server-side and produce a HTML document (among other things). You will never see the PHP source of a HTML document when requesting a website, hence there is no way for Python to grab it either. This isn't even Python-related.
0
0
1
0
2013-02-24T22:52:00.000
2
0
false
15,057,651
0
0
1
1
I know how to grab a sources HTML but not PHP is it possible with the built in functions?
how to do with a request which needs to take a long time to run?
15,059,615
0
1
73
0
python,django
One way to do it is to create a row in a persistent database (or a redis key/value pair) for the task which says if it is running or finished. Have the code set the value to be running when the task starts and done when the task completes. Then have an AJAX call do a GET lookup on a URL that sends the status for the task via a web service. You can put that in a setInterval() to periodically poll the database to see if it is done. You could send an email on completion or just have a landing page / dashboard that shows the status of the tasks being run.
0
0
0
0
2013-02-25T03:16:00.000
2
0
false
15,059,534
0
0
1
1
I'm using Django to develop a classifier service, and user can build a model using api like http://localhost/api/buildmodel, however, because building a model takes a long time, maybe 2 hours, and I'm using web page to show the result of building a model. How to design my Django program to return immediately and do something to show the result after building finish? maybe I can use ajax but I want to implement it in Python, like using a async method and calling a callback function after building, any suggestions will be appreciated.
python webkit webview: Why does the history have dates that equal 0.0, and what needs to be fixed?
16,125,745
0
2
192
0
python,webkit,history,gtk3
The history recording is supposed to be automatic. In this case, there is either no history command, or the appropriate command has not been initialized. You have to set a command to start the clock at a certain point, or else the time will always be 0 from the clock's point of view. I don't know the actual command, but hopefully you will understand the concept.
0
0
0
0
2013-02-26T05:30:00.000
1
0
false
15,082,031
0
0
1
1
I'm using GTK3 with python. While accessing the backforward list the get_last_visited_time returns 0.0 The get_last_visited_time is being called in the notify status signal callback on load_status = FINISHED. All the other values like uri, and title are the correct values.
Google App Engine development server random (?) slowdowns
15,098,634
2
2
237
1
python,google-app-engine
Don't worry about it. It (IIRC) keeps the whole DB (datastore) in memory using a "emulation" of the real thing. There are lots of other issues that you won't see when deployed. I'd suggest that your hard drive is spinning down and the delay you see is it taking a few seconds to wake back up. If this becomes a problem, develop using the deployed version. It's not so different.
0
1
0
0
2013-02-26T19:54:00.000
2
0.197375
false
15,098,051
0
0
1
2
I'm doing a small web application which might need to eventually scale somewhat, and am curious about Google App Engine. However, I am experiencing a problem with the development server (dev_appserver.py): At seemingly random, requests will take 20-30 seconds to complete, even if there is no hard computation or data usage. One request might be really quick, even after changing a script of static file, but the next might be very slow. It seems to occur more systematically if the box has been left for a while without activity, but not always. CPU and disk access is low during the period. There is not allot of data in my application either. Does anyone know what could cause such random slowdowns? I've Google'd and searched here, but need some pointers.. /: I've also tried --clear_datastore and --use_sqlite, but the latter gives an error: DatabaseError('file is encrypted or is not a database',). Looking for the file, it does not seem to exist. I am on Windows 8, python 2.7 and the most recent version of the App Engine SDK.
Google App Engine development server random (?) slowdowns
15,106,246
0
2
237
1
python,google-app-engine
Does this happen in all web browsers? I had issues like this when viewing a local app engine dev site in several browsers at the same time for cross-browser testing. IE would then struggle, with requests taking about as long as you describe. If this is the issue, I found the problems didn't occur with IETester. Sorry if it's not related, but I thought this was worth mentioning just in case.
0
1
0
0
2013-02-26T19:54:00.000
2
0
false
15,098,051
0
0
1
2
I'm doing a small web application which might need to eventually scale somewhat, and am curious about Google App Engine. However, I am experiencing a problem with the development server (dev_appserver.py): At seemingly random, requests will take 20-30 seconds to complete, even if there is no hard computation or data usage. One request might be really quick, even after changing a script of static file, but the next might be very slow. It seems to occur more systematically if the box has been left for a while without activity, but not always. CPU and disk access is low during the period. There is not allot of data in my application either. Does anyone know what could cause such random slowdowns? I've Google'd and searched here, but need some pointers.. /: I've also tried --clear_datastore and --use_sqlite, but the latter gives an error: DatabaseError('file is encrypted or is not a database',). Looking for the file, it does not seem to exist. I am on Windows 8, python 2.7 and the most recent version of the App Engine SDK.
Is it possible to reload (Windows) environment variables?
15,099,480
3
0
7,103
0
python,windows,environment-variables
If you set an environment variable in the registry (or via the System Properties > Advanced > Environment Variables UI), it will be global and persistent for every process launched from the top level context created after the variable was set. Shells and contexts initialized before your change will not pick up those changes unless you explicitly merge the values from the registry with the existing values in that context though. Each context inherits the environment of its parent, but after that point, changes to the parent or child environments do not propagate in either direction. Contexts created at the top level get their environment from the registry.
0
1
0
0
2013-02-26T21:11:00.000
1
1.2
true
15,099,344
0
0
1
1
Exactly what it says. I can set per-user environment variables, either from Windows > type "Path", or using RegEdit, or even from a Python script. But if I run an application (e.g. from Launchy, or launch it from Chrome), it won't pick up the new variables. I've got to start a new cmd or Windows Explorer (I think) to get the new values. Now, obviously I can set them on a per-use basis, but I want to set them globally for my account, and also for whatever process I happen to be using at the time. Is this possible? And is it possible (or easier) to do from a Python script?
How to setup a web app which can handle local data without uploading the data? Use python
15,101,984
0
0
218
0
javascript,python,google-chrome,web-applications,tsv
The whole point of a web application is that the GUI is written in HTML, CSS, and JavaScript, not Python. However, it talks to a web service, which can be written in Python. For a well-written desktop app, the transition should be pretty easy. If you've already got a clean separation between the GUI part and the engine part of your code, the engine part will only need minor changes (and maybe stick it behind, e.g., a WSGI server). You will have to rewrite the GUI part for the web, but in a complex app, that should be the easy part. However, many desktop GUI apps don't have such a clean separation. For example, if you have button handlers that directly do stuff to your model, there's really no way to make that work without duplicating the model on both sides (the Python web service and the JS client app) and synchronizing the two, which is a lot of work and leads to a bad experience. In that case, you have to decide between rewriting most of your app from scratch, or refactoring it to the point where you can web-service-ify it. If you do choose to go the refactoring route, I'd consider adding a second local interface (maybe using the cmd module to build a CLI, or tkinter for an alternate GUI), because that's much easier to do. Once the same backend code can support your PyQt GUI and your cmd GUI, adding a web interface is much easier.
0
0
1
0
2013-02-26T23:55:00.000
3
1.2
true
15,101,770
0
0
1
3
I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website and use Chrome as the GUI. So how do I do this? I spend most of my time developing desktop program and just know some basic web developing knowledges. I have read some framework such as flask and web2py, and know how to use HTML and Javascript to make buttons but no clue to achieve my purpose. Can someone give me a practical way to do this? It'd be better if the user don't have to upload the local data to the server. Maybe just download the python code from server then execute in Chrome. Is this possible? Thanks.
How to setup a web app which can handle local data without uploading the data? Use python
15,101,809
1
0
218
0
javascript,python,google-chrome,web-applications,tsv
No, you cannot run Python code in a web browser.[1] You'd have to port the core of your application to JavaScript to do it all locally. Just do the upload. 20MB isn't all that much data, and if it's stored on the server then they can all look at each others' results, too. [1] There are some tools that try to transpile Python to JavaScript: pyjs compiles directly, and Emscripten is an entire LLVM interpreter in JS that can run CPython itself. I wouldn't really recommend relying on these.
0
0
1
0
2013-02-26T23:55:00.000
3
0.066568
false
15,101,770
0
0
1
3
I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website and use Chrome as the GUI. So how do I do this? I spend most of my time developing desktop program and just know some basic web developing knowledges. I have read some framework such as flask and web2py, and know how to use HTML and Javascript to make buttons but no clue to achieve my purpose. Can someone give me a practical way to do this? It'd be better if the user don't have to upload the local data to the server. Maybe just download the python code from server then execute in Chrome. Is this possible? Thanks.
How to setup a web app which can handle local data without uploading the data? Use python
32,979,390
0
0
218
0
javascript,python,google-chrome,web-applications,tsv
If I get your point correctly, you want Web connection, so your python program updated on server, client get it before using it. Data store on local to avoid upload big file. You can write a python program to check a server location to get your latest program if needed. You need a url / server file for program version / created date/time information to determine if you need to update or not. After get latest python program, then start this python program to run locally. With this said, What you need is to update your program to add below features: Access your server, to get latest version information Check against current version to see if you need to download latest program Download latest version and use that to run locally. Does this solve your problem?
0
0
1
0
2013-02-26T23:55:00.000
3
0
false
15,101,770
0
0
1
3
I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website and use Chrome as the GUI. So how do I do this? I spend most of my time developing desktop program and just know some basic web developing knowledges. I have read some framework such as flask and web2py, and know how to use HTML and Javascript to make buttons but no clue to achieve my purpose. Can someone give me a practical way to do this? It'd be better if the user don't have to upload the local data to the server. Maybe just download the python code from server then execute in Chrome. Is this possible? Thanks.
Django 1.5 : Python 2.7 or Python 3
15,109,041
5
1
292
0
django,python-2.7,python-3.x
The release notes state clearly that Python 3 support in 1.5 is experimental. And yes, third-party apps will be a problem.
0
0
0
0
2013-02-27T09:47:00.000
3
0.321513
false
15,108,880
1
0
1
3
Django just release their 1.5 version. It now supports Python 3, my question is quite simple indeed: With this 1.5 Version, should I still use Python 2.7 or Python 3 ? I assume that with Python 3 there will be some issues with 3rd parties app no ? In your case, what would you do ?
Django 1.5 : Python 2.7 or Python 3
15,109,485
0
1
292
0
django,python-2.7,python-3.x
I would still use python 2.7 because many apps and libraries are not ready for python 3.x PIL is not working correctly with python 3
0
0
0
0
2013-02-27T09:47:00.000
3
0
false
15,108,880
1
0
1
3
Django just release their 1.5 version. It now supports Python 3, my question is quite simple indeed: With this 1.5 Version, should I still use Python 2.7 or Python 3 ? I assume that with Python 3 there will be some issues with 3rd parties app no ? In your case, what would you do ?
Django 1.5 : Python 2.7 or Python 3
15,109,147
0
1
292
0
django,python-2.7,python-3.x
If I was starting a new development which I didn't expect to go live until well after version 1.6 is released (when Python 3 support is supposed to be production ready, and hopefully the 3rd party apps have caught up) , then yes, I would go with Python 3. It is significantly cleaner than Python 2.7. But if you want your site up and running in the near future, stick with 2.7.
0
0
0
0
2013-02-27T09:47:00.000
3
0
false
15,108,880
1
0
1
3
Django just release their 1.5 version. It now supports Python 3, my question is quite simple indeed: With this 1.5 Version, should I still use Python 2.7 or Python 3 ? I assume that with Python 3 there will be some issues with 3rd parties app no ? In your case, what would you do ?
Remove memcached completely from django
21,271,795
0
0
440
0
python,django,caching,memcached
This isn't anything to do with memcache; it sounds like the old compiled python scripts are still being used. Theoretically, restarting apache should do it. If not, deleting all the .pyc files (compiled python files; not .py, which are your source code) and restarting your server should force it to regenerate the .pyc files from the current source.
0
0
0
0
2013-02-27T16:28:00.000
1
0
false
15,117,182
0
0
1
1
Please tell some way to completely remove memcached from Django server. Using apache with mod WSGI and have already deleted all caches lines from settings.py but even that file is being cached. Even removing settings.py doesn't stop site from working. This is ridiculous. There is no .pyc being formed which I could delete. Where are the files being cached. I cannot get code changes in .py files to reflect in any way. They sometimes reflect, sometimes the old code comes back from some cache. How can I delete all caching mechanisms from this server ? Regards !
Differentiate celery, kombu, PyAMQP and RabbitMQ/ironMQ
15,131,010
2
9
7,047
0
python,heroku,rabbitmq,celery,kombu
"One of the biggest differences between IronMQ and RabbitMQ/AMQP is that IronMQ is hosted and managed, so you don't have to host the server yourself and worry about uptime." Currently there are at least two hosted managed RabbitMQ-as-a-service options: Bigwig and CloudAMQP. Celery should work well with both.
0
1
0
0
2013-02-27T20:16:00.000
2
0.197375
false
15,121,519
0
0
1
1
I want to upload images to S3 server, but before uploading I want to generate thumbnails of 3 different sizes, and I want it to be done out of request/response cycle hence I am using celery. I have read the docs, here is what I have understood. Please correct me if I am wrong. Celery helps you manage your task queues outside the request response cycle. Then there is something called carrot/kombu - its a django middleware that packages tasks that get created via celery. Then the third layer PyAMQP that facilitates the communication of carrot to a broker. eg. RabbitMQ, AmazonSQS, ironMQ etc. Broker sits on a different server and does stuff for you. Now my understanding is - if multiple users upload image at the same time, celery will queue the resizing, and the resizing will actually happen at the ironMQ server, since it offers a cool addon on heroku. Now the doubts: But what after the image is resized, will ironMQ push it to the S3 server, or will it notify once the process is completed.. i am not clear about it. What is the difference between celery and kombu/carrot, could you explain vividly.
Python: how to garbage collect strings
15,156,807
2
2
1,633
0
python,string,garbage-collection
You say: I saw that every new string (with sys.getrefcount) have, at least, 2 references But did you carefully read the description of getrefcount() ? : sys.getrefcount() object) Return the reference count of the object. The count returned is generally one higher than you might expect, because it includes the (temporary) reference as an argument to getrefcount(). . You should explain more about your prohgram. What is the size of the HTML strings it holds ? How are they obtained ? Are you sure to close all file's handler , all socket connexions, ....?
0
0
0
0
2013-03-01T11:08:00.000
2
0.197375
false
15,156,264
0
0
1
1
I'm having a problem in a large-runtime script. This script is a multithreaded environment, to perform crawling tasks. In large executions, script's memory consumption become huge, and after profiling memory with guppy hpy, I saw that most of the problem is coming by strings. I'm not storing so many strings: just get content of htmls into memory, to store them in db. After it, string is not used anymore (the variable containing it is assigned to the next string). The problem arised because I saw that every new string (with sys.getrefcount) have, at least, 2 references (1 from my var, and 1 internal). It seems that reassigning another value to my var does not remove the internal reference, so the string stills in memory. What can I do to be sure that strings are garbage collected? Thank you in advance EDIT: 1- I'm using Django ORM 2- I'm obtaining all of that strings from 2 sources: 2.1- Directly from socket (urllib2.urlopen(url).read()) 2.2- Parsing that responses, and extrating new URIs from every html, and feeding system SOLVED Finally, I got the key. The script is part of Django environment, and seems that Django's underground is doing some cache or something similar. I turned off debugging, and all started to work as expected (reused indentifiers seems to delete references to old objects, and that objects become collected by gc). For anyone who uses some kind of framework layer over python, be aware of configuration: seems that some debug configurations with intensive process can lead to memory leaks
Is slicing and dicing of distributed counter data in cassandra using pycassa possible?
15,175,729
0
0
148
0
python,cassandra,pycassa
I'm working with a system that has both the features you are asking for. We are using HBase (not Cassandra) and we write the URL + date in the key for every counter. Then you can easily get the two reports you are looking for. To get all page views for one URL, scan for keys beginning with and then add the counter values you find with that scan. To get pageviews per day for one URL, scan for the key beginning with + date.
0
0
0
0
2013-03-01T11:44:00.000
1
0
false
15,156,945
0
0
1
1
I read and googled a lot but could not find a way to slice n dice a counter data based on a condition. Is there a way in Cassandra to do this? If yes, pl ease help me with it. For example: If I am using a counter to store the total page views, is there any way I can get the count of page views of a particular page url OR get all page views on a particular date? Thanks in advance!
Django: Automatically executing statements in `manage.py shell`
15,164,238
-1
2
158
0
python,django,shell
I ended up monkeypatching IPython.frontend.terminal.embed.InteractiveShellEmbed.__call__ to add the definitions I wanted. (I know many people are opposed to monkeypatching but I find it to be a good solution in this case.)
0
1
0
0
2013-03-01T15:19:00.000
2
1.2
true
15,161,051
0
0
1
1
Every time I start a shell using python manage.py shell, I want a few lines to be executed automatically. (In my case it would be a few import lines in the style of import django, my_app.) How do I do this?
Turning off model validation on Django dev-server
15,172,677
1
1
827
0
python,django,django-dev-server
This is not possible without modifying the source code of Django (which is not recommended). The only validation Django does on start-up is to check if the syntax of your model code is okay or not. It should not take more than 2-3 seconds. So, there are few other initialization are being done during startup which are also taking time. During development, you do not need to restart the server every time you modify the code- especially if you are not touching the definition of the models at all. The Django dev server automatically reloads itself if it detects any change in your code. So, leave it running while you develop and hopefully your experience will improve.
0
0
0
0
2013-03-02T02:28:00.000
1
1.2
true
15,170,013
0
0
1
1
Stage of models validation is most longest in Django dev-server startup. And in my case it mostly waste of time, since my models сhanging infrequently. Is there way to turn off this?
Heroku Python App - CSS Not Loading On IPhone Only
15,181,474
0
0
381
0
python,css,heroku,responsive-design,flask
Bug found. It was a very, very obscure rendering issue with the text-indent css attribute that only seemed to affect the iPhone 5. Additionally, if you ever need to debug Google Chrome for iPhone, clearing the cache won't do anything if you don't delete the app from the multitasking menu too (the bar that comes up when you double tap the home button). That literally took me half an hour to figure out.
0
0
0
0
2013-03-02T09:21:00.000
1
0
false
15,172,826
0
0
1
1
First question posted to Stack Overflow but have spent many hours reading answers here :). I'm creating a Heroku Python app and am using responsive design media queries in my css. I deploy my app to Heroku and visit myherokuapp.herokuapp.com. Website looks fine on laptop browser...responsive design elements working as well. Visiting the same url on my iPhone, however, seems to show a page where one of my css files (the media queries) is loading but the other (the main css file) is not. Does Heroku cache css files? I read somewhere that you have to host static files elsewhere if you have a Django app, but not sure if that's applicable to me. I'm also using the Flask function <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">. Does that have anything to do with it? Edit: Does anyone know how to run the equivalent of the Firefox/Google Inspector on mobile? That would really help me figure out what files are there and what aren't.
How do I inform a user if an event has been created by the admin in Django?
15,181,386
0
0
542
0
python,django
So, I can really only give you some general direction, as I don't know the particulars, but basically you could do something like this: First, I would add an override to the save_model() method of your admin class. This is where you can check to see if your object has a primary key yet. If not, you can set a flag to create the event (not sure if you need to also associate your event to the notification via a foreign key. If you don't need to have an association between your Event and the notification, you could skip setting a flag and just create the notification object whenever you want. Second, create a view that returns JSON for your events. I'm not sure how you would need to filter these objects. Is it only for logged in users, etc, but you would only want to return ones that have not been previously viewed. Third, call the view via ajax on an interval, passing in whatever criteria you need to filter the results and record the notification has been viewed. Hope that gets you going.
0
0
0
0
2013-03-02T16:55:00.000
2
0
false
15,177,002
0
0
1
1
We're currently developing a system for a certain organization. One of the requirement is to inform users whenever the admin creates an event. All the site users should be notified not through e-mail but something similar to Facebook notification. How do I implement such feature in Django without using Django-notifications, Django-activity streams, etc. We're newbies to Django and we wanted to implement such feature as simple as it can be. I hope you can help us with this matter. Thank you all!
Django Tastypie - serving emoji that are stored in db
15,184,591
0
0
579
0
python,django,emoji,tastypie
What if you save the JSON dump to a text file and open it with a UTF8 text editor? Will the emoji re-appear? I suspect that, when displaying the JSON in the browser, the browser falls back to Latin-1 encoding, thus ending up with question marks. There might be a setting in your browser to set the encoding. Check the "Content-Type" header that comes from your server. Does it say application/json; encoding=utf-8?
0
0
0
0
2013-03-02T19:35:00.000
2
0
false
15,178,533
0
0
1
1
I'm using django and tastypie for my api. the db is MySQL. After a few days of fiddling around i managed to store emoji icons in the db using utf8mb4 character set. When querying the db directly from the console (on a mac), i see the emoji fine, but when pulling them from the api (for example using the browser), the json shows question marks. This leads me to believe the issue is not with the db but with django/tastypie db connection. How do i go about it?
How to resolve two slightly different names of same product (mobile phone) in program?
15,189,643
3
2
555
0
python,nlp,string-comparison,string-matching,string-parsing
You could use different approaches for this (and for most efficiency mix them): You could ignore everythin that is in parenthesis. Define words you automatically drop like "black", "blue" or "white". Compare the names via their Levenshtein distance and use this distance for clustering. Surface similarity (thanks to mbatchkarov)
0
0
0
0
2013-03-03T18:20:00.000
2
0.291313
false
15,189,056
1
0
1
1
I am working on a web app where I collect data about mobile phones from several websites. The problem is that websites use slightly different naming of mobile phones. For eg the websites use the following variation in names for these two mobiles: HTC One X+ (Black); HTC One X+ Black; HTC One X Plus; HTC One X Plus, black Samsung Galaxy S3 (Pebble Blue, with 16GB); Samsung Galaxy S III (Blue); Samsung Galaxy S3 I9300 16GB Pebble Blue; Samsung I9300 Galaxy S III (16 GB); Samsung Galaxy S3 (I9300), pebble blue Since I read this data off these websites using a crawler I need my program to resolve all these different strings into same product. Any ideas? If it matters, I am using python.
Does initialize in tornado.web.RequestHandler get called every time for a request/
15,202,174
8
3
1,206
0
python,tornado
Yes, tornado calls initialize for each request. If you want to share state between requests(like db connection) - store it in self.application.
0
1
0
0
2013-03-04T10:09:00.000
1
1.2
true
15,199,028
0
0
1
1
There'a an initialize method in tornado.web.RequestHandler class, is it called every time there's a request?
AppEngine NDB property validations
15,202,052
0
0
744
0
python,google-app-engine,app-engine-ndb,wtforms,google-cloud-endpoints
Not this is is always the best solution, but you could roll your own. Just pre-define a bunch of properties with reg-exs/mins and maxs etc. It seems like your properties are straight forward enough that it wouldn't be too difficult.
0
1
0
0
2013-03-04T11:53:00.000
1
0
false
15,200,952
0
0
1
1
I wonder what the best approach is for validating NDB entity properties likes: a date must be in the future a grade (integer property) must be between 1 and 10 a reference to another entity must have certain property values (e.g. book.category.active must be True) I'm also using WTForms to validate submitted requests, but I want to enforce validations also on a lower level like the datastore entities itself. So basically what I'm looking for is to call a validate on a datastore entity to see if it's valid or not. In case it's valid I can put the entity to the datastore, but if it's not valid I want to retrieve the invalid properties including the applies validator that did not validate successfully. Another reason WTForms might not be sufficient is that I'm experiencing with the new Cloud Endpoints. In this model I'm receiving the actial entity and not a http request. How are other AppEngine users solving this?
How can I use MySQL with Python 3.3 and Django 1.5?
15,203,056
0
1
713
1
python,mysql,django
As others have noted, Python 3 support in Django 1.5 is "experimental" and, as such, not everything should be expected to work. That being said, if you absolutely need to get this working, you may be able to run the 2to3 tool on a source version of MySQL-python to translate it to Python 3 (and build against Python 3 headers if required).
0
0
0
0
2013-03-04T13:18:00.000
3
0
false
15,202,503
0
0
1
1
Django needs MySQL-python package to manipulate MySQL, but MySQL-python doesn't support Python 3.3. I have tried MySQL-for-Python-3, but it doesn't work. Please help! Thanks a lot!