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
What user should own my Python scripts and application directories?
13,730,842
1
1
112
0
python,linux,web-applications,chown
The proper way is to compile to bytecode on install so that .pyc files never need to be created on the fly. The rest is basic stuff, like "never use 0777/0666".
0
0
0
0
2012-12-05T19:18:00.000
1
1.2
true
13,730,790
0
0
1
1
I've been using chown www-data:www-data -R /path/to/my/django-app/ and simply letting my virtualenv's dirs / files be owned by root (since sudo pip install foo implies that by default). This just doesn't feel right though. Is this pretty typical, or, should www-data only own directories that it can upload files to? If I allow root to own everything, my server won't even be able to write .pyc files, or will it? I'm clearly quite new to Unix permissions. What is the secure, proper way to handle this?
Invalidate an old session in Flask
21,083,908
12
27
25,119
0
python,flask
If you have security concerns (and everyone should have) There is the answer: This is not REALLY possible Flask uses cookie-based sessions. When you edit or delete session, you send a REQUEST to CLIENT to remove the cookie, normal clients (browsers) will do. But if session hijacked by an attacker, the attacker's session remains valid.
0
0
0
0
2012-12-06T00:30:00.000
4
1
false
13,735,024
0
0
1
1
How do I create a new clean session and invalidate the current one in Flask? Do I use make_null_session() or open_session()?
How do you specify the html5 doctype with Python Chameleon?
15,097,605
2
3
367
0
python,chameleon,template-metal
Figured it out. You need to wrap the entire master template in a metal tag like so: <metal:macro metal:define-macro="layout"> <!DOCTYPE html> ... </html></metal:macro>
0
0
0
0
2012-12-06T15:25:00.000
1
1.2
true
13,746,872
0
0
1
1
I've thoroughly RTFMed and Googled for this, and I can't seem to find the answer. I am new to Chameleon, so maybe it's just so obvious that it's no where to be found, but when I put <!DOCTYPE html> in my master template, the rendered page has it stripped out resulting in the dreaded quirksmode. Is there a trick that I'm missing?
Django session race condition?
13,924,932
7
8
1,895
0
python,django,multithreading,session,race-condition
Yes, it is possible for a request to start before another has finished. You can check this by printing something at the start and end of a view and launch a bunch of request at the same time. Indeed the session is loaded before the view and saved after the view. You can reload the session using request.session = engine.SessionStore(session_key) and save it using request.session.save(). Reloading the session however does discard any data added to the session before that (in the view or before it). Saving before reloading would destroy the point of loading late. A better way would be to save the files to the database as a new model. The essence of the answer is in the discussion of Thomas' answer, which was incomplete so I've posted the complete answer.
0
0
0
0
2012-12-06T16:33:00.000
3
1.2
true
13,748,166
0
0
1
1
Summary: is there a race condition in Django sessions, and how do I prevent it? I have an interesting problem with Django sessions which I think involves a race condition due to simultaneous requests by the same user. It has occured in a script for uploading several files at the same time, being tested on localhost. I think this makes simultaneous requests from the same user quite likely (low response times due to localhost, long requests due to file uploads). It's still possible for normal requests outside localhost though, just less likely. I am sending several (file post) requests that I think do this: Django automatically retrieves the user's session* Unrelated code that takes some time Get request.session['files'] (a dictionary) Append data about the current file to the dictionary Store the dictionary in request.session['files'] again Check that it has indeed been stored More unrelated code that takes time Django automatically stores the user's session Here the check at 6. will indicate that the information has indeed been stored in the session. However, future requests indicate that sometimes it has, sometimes it has not. What I think is happening is that two of these requests (A and B) happen simultaneously. Request A retrieves request.session['files'] first, then B does the same, changes it and stores it. When A finally finishes, it overwrites the session changes by B. Two questions: Is this indeed what is happening? Is the django development server multithreaded? On Google I'm finding pages about making it multithreaded, suggesting that by default it is not? Otherwise, what could be the problem? If this race condition is the problem, what would be the best way to solve it? It's an inconvenience but not a security concern, so I'd already be happy if the chance can be decreased significantly. Retrieving the session data right before the changes and saving it right after should decrease the chance significantly I think. However I have not found a way to do this for the request.session, only working around it using django.contrib.sessions.backends.db.SessionStore. However I figure that if I change it that way, Django will just overwrite it with request.session at the end of the request. So I need a request.session.reload() and request.session.commit(), basically.
Continuous integration with python 2.7 / flask / mongoDB / git
13,767,025
1
4
1,085
0
python,git,continuous-integration,flask,gunicorn
buildbot, jenkins/hudson but these give you continuous integration in the sense you can run a "make" equivalent with every code base change through a commit hook. You could also look at vagrant if there is something there for you for creating repeatable vm's wrt to config/setup. Could tie it with a commit hook.
0
0
0
1
2012-12-06T18:48:00.000
1
0.197375
false
13,750,417
0
0
1
1
How should I implement continuous integration on my new application? Currently, this is how we're pushing to production - please bear with me, I know this is far from sane: From local, git push origin production (the production codebase is kept on the production branch, modifications are either written directly there and committed, or files are checked out individually from another branch. Origin is the remote production server) On the remote box, sudo stop gunicorn (application is running as a process) cp ~/flaskgit/application.py ~/flask/applicaion.py (the git push origin from local pushes to an init -bare repo with a post-update hook that populates the files in ~/flaskgit. ~/flask is where the gunicorn service runs the application under a virtualenv) sudo start gunicorn we do our testing with the ~/flaskgit code running on a different port. once it looks good we do the CP I would love to have something more fluid. I have used jenkins in the past, and loved the experience - but didn't set it up. What resources / utilities should I look up in order to do this well? Thank you!
Can I install Selenium2Library for RobotFramework without installing Python?
13,769,988
2
0
1,914
0
python,jython,robotframework
So after some reading and trial and error, it IS possible to use Selenium2Library with only Jython AS LONG AS you use jython 2.7+ ... jython 2.5.x is NOT compatible with Selenium2Library. So you can get away with not using Python at all: Install jython 2.7+ Install ez_setup.py Install robot framework Install Selenium2Library.
0
0
0
0
2012-12-06T23:48:00.000
1
0.379949
false
13,754,725
1
0
1
1
Can I use Selenium2Library if I only have Jython? That is, I haven't installed Python, and was hoping to get away with not needing it. I've read conflicting information however that jybot CANNOT use selenium2library, and I'll need pybot to use it. If jybot can't use selenium2Library, is there a way to have jybot call pybot somehow? Thanks
How to make almost static site in Pyramid?
14,030,455
0
3
720
0
python,pyramid
This is somewhat a different answer than ohters but here is a completely different flow. Write all your pages in html. Everything!!! and then use something like angularjs or knockoutjs to add dynamic content. Pyramid will serve dynamic content requested using ajax. You can then map everything to you html templates... edit those templates wherever you want since they are simply html files. The downside is that making it work altogether isn't that simple at first.
0
0
0
1
2012-12-07T02:32:00.000
3
0
false
13,756,090
0
0
1
1
I'm switching to Pyramid from Apache/PHP/Smarty/Dreamweaver scheme. I mean the situation of having static site in Apache with menu realized via Dreamweaver template or other static tools. And then if I wanted to put some dynamic content in html I could make the following: Put smarty templates in html. Create php behind html with same name. Php takes html as template. Change links from html to php. And that was all. This scheme is convenient because the site is viewable in browser and editable in Dreamweaver. How can I reproduce this scheme in Pyramid? There are separate dirs for templates and static content. Plus all this myapp:static modifiers in hrefs. Where to look up? Thank you for your advices.
Does a smaller application footprint mean cheaper PaaS costs? which language?
13,756,326
0
4
216
0
python,ruby,node.js,grails,cloud
Memory footprint will certainly reflect on your PaaS expenses. But to tell you what to use is hard without knowing more about the project. Node.js per se is great, but it's not perfect for every case. Python is very friendly for development, and has ok memory usage, but again - it all depends on what you're doing.
0
0
0
0
2012-12-07T02:57:00.000
2
0
false
13,756,269
0
0
1
1
So, I have built and deployed a Grails app onto cloudfoundry. And as I play around with examining instances & memory I start to wonder; If my app's footprint is larger because of the technology I chose to develop it in, will it start costing me money sooner rather than later? Surely it must? If that is the case, am I better off developing in an alternative language? if so which has the smaller footprint (python, ruby, node.js)? Of course, costs should not determine which language I use, I should select language/framework on merits and personal preference. But it is still a question I'd would really like to know the answer to.
Session managment, SSL, WSGI and Cookies
13,762,690
3
1
690
0
python,session,cookies,ssl,wsgi
What's wrong with your protocol You might want to consider the following: Alice contacts your server and obtains an SSL session ID S. A cookie containing H(S) is sent to Alice. Bob is listening in on the exchange. The SSL session ID is not encrypted, so he can read S. Bob contacts your server with the session cookie set to H(S). His Session ID is not recognized, but your system will let him in Alice's session anyway (and probably kick Alice out, too!). The solution would then be to use HMAC so sign the Session ID. But then you might as well just use an HMAC'ed session id in the first place. A few details: To know the name of the Cookie he should send, Bob can just contact your server. Bob can do the same to get an idea of the hashing algorithm you are using What's great with HMAC Session Cookies + HMAC has been proved to be cryptographically secure. HMAC was designed for the purpose of authenticating data. The logic behing HMAC is sound, and there is, as of today, no attack that exist on the protocol. Even better, it was proved than an attack on the underlying Hash algorithm doesn't mean an attack on HMAC exists (That doesn't mean you should use MD5 though!). There is no reason why you wouldn't want to use HMAC. SSL Session IDs are, at best, useful for load balancers. Never implement your own cryptography You should never, ever, re-invent cryptography. Cryptographic algorithms have been reviewed by (possibly) thousands of people with lots of experience in the field. Whenever you feel like you have a better idea, you are probably missing something. Maybe you don't though! But then you should write a paper on your algorithm, and let it be peer-reviewed. Stick to the standards.
0
0
0
0
2012-12-07T11:18:00.000
1
0.53705
false
13,762,051
0
0
1
1
I'm reviewing the possibility and advisability of implementing wsgi-app to browser session management, without using any off the shelf middleware. The general approach under consideration is to; Use SSL between the browser and the server. Expose the SSL session ID to the WSGI or OS.environment, to be used as a session ID to enable application level persistence and authentication. As the SSL session ID could change at any time if the server+browser handshake again, the idea is to use a cookie to hold a hashed version of the SSL ID generated. If they handshake and a change in SSL ID is detected (the SSL session ID exposed to the environment does not match the cookie returned by the client), the hashed cookie could be checked to see if it contained the previous known session ID, if it did then we should continue the current session and update the SSL session ID used in the cookie (and stored in a backend db) to be the newly generated-via-handshake SSL session ID. Hence enabling us to continue the session even though SSL session ID's can change under our feet. The idea, as I understand it, is to let SSL be generating session ID's, and to be doing something that is more secure than relying on just cookies+hmac to hold the session ID. I would be interested in anyones thoughts on the above process. In principle it seems sound to me, but I have very little experience with this kind of functionality. I have drawn out the flow of exchanges between client & server & wsgi-app for a few scenarios and it appears to work out fine, but I'm not comfortable I've covered all the bases.
How override default admin static files?
13,770,047
0
0
118
0
python,django,django-admin
The django package is hosted on your server. Have you considered changing the images for icon_error.png and icon_success.png, then resaving them with the same name on your filesystem? The location where you can find the static image files within the django package is: / django / django / contrib / admin / static / admin / img /
0
0
0
0
2012-12-07T19:01:00.000
2
0
false
13,769,381
1
0
1
1
How can I override default admin static files - for example icon_error.png, icon_success.png ?
How can I have django-taggit tags deleted when there are no more objects attached to them?
13,772,887
3
2
728
0
python,django,django-taggit
The only technique I can think of would be to attach a custom pre_delete signal handler to every taggable model that checks if it was the last model with any particular tag. In the event that it is, delete that tag.
0
0
0
0
2012-12-07T23:39:00.000
2
1.2
true
13,772,750
0
0
1
1
I think the title says it. Many tags are created and deleted but they still exist even when no more objects are using them. Is there a way to make it check upon save and delete unused tags?
local GAE datastore does not keep data after computer shuts down
13,779,121
1
4
2,643
0
google-app-engine,python-2.7,google-cloud-datastore
The datastore typically saves to disk when you shut down. If you turned off your computer without shutting down the server, I could see this happening.
0
1
0
0
2012-12-08T10:27:00.000
3
0.066568
false
13,776,610
0
0
1
1
On my local machine (i.e. http://localhost:8080/), I have entered data into my GAE datastore for some entity called Article. After turning off my computer and then restarting next day, I find the datastore empty: no entity. Is there a way to prevent this in the future? How do I make a copy of the data in my local datastore? Also, will I be able to upload said data later into both localhost and production? My model is ndb. I am using Max OS X and Python 2.7, if theses matter.
Django - how to set up asynchronous longtime background data processing task?
13,783,426
0
4
2,371
0
python,django,background-process,backend
Why don't you have a url or python script that triggers whatever sort of calculation you need to have done everytime it's run and then fetch that url or run that script via a cronjob on the server? From what your question was it doesn't seem like you need a whole lot more than that.
0
0
0
0
2012-12-08T18:52:00.000
3
0
false
13,780,732
0
0
1
1
Newb quesion about Django app design: Im building reporting engine for my web-site. And I have a big (and getting bigger with time) amounts of data, and some algorithm which must be applied to it. Calculations promise to be heavy on resources, and it would be stupid if they are performed by requests of users. So, I think to put them into background process, which would be executed continuously and from time to time return results, which could be feed to Django views-routine for producing html output by demand. And my question is - what proper design approach for building such system? Any thoughts?
How To See A Database On Heroku
13,782,284
0
0
61
0
python,database,heroku
You can connect directly to it using something like PGAdmin, look at the output of heroku config for your application to get your database URL which you can breakup to use in GUI tools.
0
0
0
0
2012-12-08T19:54:00.000
1
0
false
13,781,287
0
0
1
1
How do I see the database for my heroku web app? I just want to verify if users are being registered, properly, etc. I am using Flask-SQLAlchemy Python, if that makes a difference.
Capture Visible Webpage Content (or text) as if Copying from Browser
13,787,570
2
0
781
0
python,selenium,screen-scraping,web-scraping,screenshot
Sure. Use Selenium and just loop through all visible, displayable elements.
0
0
1
0
2012-12-09T07:48:00.000
1
0.379949
false
13,785,630
0
0
1
1
Is there a way to capture visible webpage content or text as if copying from a browser display to parse later (maybe using regular expression etc)? I don't mean to clean the html tags, javascript, etc and only show leftover text. I would like to copy all visible text, since some style elements may hide some of the html text while showing others when displayed in the browser. So far I have looked into nltk, lxml Cleaner, and selenium without luck. Maybe I can capture a screenshot in selenium and then extract text using ocr, but that seems computer intensive? Thanks for any help!
XMPP-- openfire,PHP and python web service
13,797,108
0
0
1,049
0
python,web-services,xmpp,openfire,strophe
It seems to me like XMPP is a bit of a heavy-weight solution for what you're doing, given that communication is just one-way and you're just sending notifications (no real-time multi-user chat etc.). I would consider using something like Socket.io (http://socket.io) for the server<=>client channel along with Redis (http://redis.io) for persistence.
0
0
0
1
2012-12-09T12:07:00.000
1
0
false
13,787,244
0
0
1
1
I am planning to integrate real time notifications into a web application that I am currently working on. I have decided to go with XMPP for this and selected openfire server which i thought to be suitable for my needs. The front end uses strophe library to fetch the notifications using BOSH from my openfire server. However the notices are the notifications and other messages are to be posted by my application and hence I think this code needs to reside at the backend. Initially I thougt of going with PHP XMPP libraries like XMPHP and JAXL but then I think that this would cause much overhead as each script will have to do same steps like connection, authentication etc. and I think this would make the PHP end a little slow and unresponsive. Now I am thinking of creating a middle-ware application acting as a web service that the PHP will call and this application will handle the stuff with XMPP service. The benefit with this is that this app(a server if you will) will have to connect just once and the it will sit there listening on a port. also I am planning to build it in a asynchronous way such that It will first take all the requests from my PHp app and then when there are no more requests; go about doing the notification publishing stuff. I am planninng to create this service in Python using SleekXMPP. This is just what I planned. I am new to XMPP and this whole web service stuff ans would like to take your comments on this regarding issues like memory and CPU usage, advantages, disadvantages, scalability issues,security etc. Thanks in advance. PS:-- also if something like this already exists(although I didn't find after a lot of Googling) Please direct me there. EDIT --- The middle-level service should be doing the following(but not limited to): 1. Publishing notifications for different level of groups and community pages. 2. Notification for single user on some event. 3. User registration(can be done using user service plugin though). EDIT --- Also it should like to create pub-sub nodes and subscribe and unsubscribe users from these pub-sub nodes. Also I want to store the notifications and messages in a database(openfire doesn't). Would that be a good choice?
Secure localhost JavaScript ajax requests
13,788,959
1
2
320
0
javascript,python,ajax,localhost
The most direct way to protect against this attack is to just have a long complex secret key being required for every request. Just make your local code authenticate itself before processing the request. This is essentially how web services on the Internet are protected. You might also want to consider having inter process communication in some other form like DBUS or unix sockets. I'm not sure which OS you are on but there are many options for inter process communication that wouldn't make you vulnerable in this way.
0
0
1
0
2012-12-09T14:14:00.000
1
1.2
true
13,788,172
0
0
1
1
I have a written an app, with python acting as a simple web server (I am using bottle framework for this) and an HTML + JS client. The whole thing runs locally. The web page acts as GUI in this case. In my code I have implemented a file browser interface so I can access local file structure from JavaScript. The server accepts only local connections, but what bothers me is that: if for example somebody knows that I am running my app locally, and forges a site with AJAX request to localhost? and I visit his site in some way, will my local files be visible to the attacker? My main question is: is there any way to secure this? I mean that my server will know for sure that the request came from my locally served file?
Django MPTT ordering
14,391,692
0
2
629
0
python,django,recursion,tree,mptt
I have been sitting here for five minutes and I can't think of a way to do this in SQL given the data structure you are describing. To begin with, I would suggest that you separate your data into Posts and Comments, rather than just having one sort of data object. Then you can do a join to gather the comments together with your posts and give different ordering to each. Also, an MPTT seems like overkill for a two layer tree.
0
0
0
0
2012-12-10T02:58:00.000
2
0
false
13,794,399
0
0
1
2
I'm using MPTT tree structure in my Django project to organise comments. I have only 2 level : comment and comment of comment Everything works perfectly except the ordering. I would like to sort all Comment that don't have parents by creation date ascendent ("-creation_date") and all comment that has a parent by creation date descendant ("creation_date"). Basically it's like the comments are working on the Facebook wall. (you alway see the latest comment on top but the comments within a comment are in a reverse order) In my class Comment I have the following MPTTMeta : order_insertion_by=['creation_date'] I hope I'll get some help. Thank you
Django MPTT ordering
14,846,769
-1
2
629
0
python,django,recursion,tree,mptt
I found a solution so I forgot to check back. I played around with the mptt structure and django functions ... Thanks
0
0
0
0
2012-12-10T02:58:00.000
2
-0.099668
false
13,794,399
0
0
1
2
I'm using MPTT tree structure in my Django project to organise comments. I have only 2 level : comment and comment of comment Everything works perfectly except the ordering. I would like to sort all Comment that don't have parents by creation date ascendent ("-creation_date") and all comment that has a parent by creation date descendant ("creation_date"). Basically it's like the comments are working on the Facebook wall. (you alway see the latest comment on top but the comments within a comment are in a reverse order) In my class Comment I have the following MPTTMeta : order_insertion_by=['creation_date'] I hope I'll get some help. Thank you
Saving the stack?
13,810,563
1
6
156
0
python,ruby,jvm,stack
Good question. In Smalltalk, yes. Actually, in Smalltalk, dumping the whole program and restarting is the only way to store and share programs. There are no source files and there is no way of starting a program from square zero. So in Smalltalk you would get your feature for free. The Smalltalk VM offers a hook where each object can register to restore its externals resources after a restart, like reopening files and internet connections. But also, for example integer arrays are registered to that hook to change the endianness of their values on case the dump has been moved to a machine with different endianness. This might give a hunch at how difficult (or not) it might turn our to achieve this in a language which does not support resumable dumps by design. All other languages are, alas, much less live. Except for some Lisp implementation, I would not know of any language which supports resuming from a memory dump. Which is a missed opportunity.
0
0
0
1
2012-12-10T20:51:00.000
3
0.066568
false
13,809,013
1
0
1
1
I'm just curious, is it possible to dump all the variables and current state of the program to a file, and then restore it on a different computer?! Let's say that I have a little program in Python or Ruby, given a certain condition, it would dump all the current variables, and current state to a file. Later, I could load it again, in a different machine, and return to it. Something like VM snapshot function. I've seen here a question like this, but Java related, saving the current JVM and running it again in a different JVM. Most of the people told that there was nothing like that, only Terracotta had something, still, not perfect. Thank you. To clarify what I am trying to achieve: Given 2 or more Raspberry Pi's, I'm trying to run my software at Pi nº1, but then, when I need to do something different with it, I need to move the software to Pi nº2 without dataloss, only a minor break time. And so on, to an unlimited number of machines.
GAE development server keep full text search indexes after restart?
20,389,173
-2
8
1,909
0
python,google-app-engine,google-cloud-datastore,google-search
Look like this is not an issue anymore. according to documentation (and my tests): "The development web server simulates the App Engine datastore using a file on your computer. This file persists between invocations of the web server, so data you store will still be available the next time you run the web server." Please let me know if it is otherwise and I will follow up on that.
0
1
0
0
2012-12-12T16:12:00.000
3
-0.132549
false
13,843,907
0
0
1
2
Is there anyway of forcing the GAE dev server to keep full text search indexes after restart? I am finding that the index is lost whenever the dev server is restarted. I am already using a static datastore path when I launch the dev server (the --datastore_path option).
GAE development server keep full text search indexes after restart?
13,849,805
2
8
1,909
0
python,google-app-engine,google-cloud-datastore,google-search
This functionality was added a few releases ago (in either 1.7.1 or 1.7.2, I think). If you're using an SDK from the last few months it should be working. You can try explicitly setting the --search_indexes_path flag on dev_appserver.py; it's possible that the default location (/tmp/) isn't writable. Could you post the first few lines of the logs from when you start dev_appserver?
0
1
0
0
2012-12-12T16:12:00.000
3
0.132549
false
13,843,907
0
0
1
2
Is there anyway of forcing the GAE dev server to keep full text search indexes after restart? I am finding that the index is lost whenever the dev server is restarted. I am already using a static datastore path when I launch the dev server (the --datastore_path option).
python html parser which doesn't modify actual markup?
18,350,504
0
1
273
0
python,html,parsing
No, to this moment there is no such HTML parser and every parser has it's own limitations.
0
0
1
0
2012-12-13T11:44:00.000
3
1.2
true
13,859,124
0
0
1
1
I want to parse html code in python and tried beautiful soup and pyquery already. The problem is that those parsers modify original code e.g insert some tag or etc. Is there any parser out there that do not change the code? I tried HTMLParser but no success! :( It doesn't modify the code and just tells me where tags are placed. But it fails in parsing web pages like mail.live.com Any idea how to parse a web page just like a browser?
Django Signal vs Python Threading
13,892,073
1
2
769
0
python,django,django-signals
I would suggest you to use django-celery with RabbitMQ. You can add the notifications thing in the tasks of celery and have your view start the task queque. Have a look....I hope it will be helpful to you.
0
0
0
0
2012-12-14T00:25:00.000
1
1.2
true
13,870,894
0
0
1
1
Its hard to explain what I am trying to achieve. Please have the patience to go through this. And let me know if you have any questions. Say I have a Django project with two applications which I would like to have them coupled loosely. One of the application is 'Jobs' and other is 'Notifications'. Now I want to create notifications when the Job instance is updated. So, I was thinking of using Django Signals. But some of the reservations I have are: If I use the build-in signals like post_save. I could validate the conditions on job instance and generate notification(which is good). But the problem comes when, in the same view logic I call the save method on job instance multiple times. This would generate notifications multiple times. Else, I use the home made signals I would be required to call it manually which is not good for loose coupling. Moreover, the signals are not asynchronous so, I would have to wait for the notification generation to complete before I can proceed. Can anyone please suggest a good implementation strategy using Signals. One solution I was looking into was Python Threading which seems to take care of the asynchronous problem. But are there any other consequences of using Threading.
How can I track s3 bucket folder usage with python?
13,892,252
0
0
818
1
python,django,amazon-s3
No its not possible to create a bucket for each user as Amazon allows only 100 buckets per account. So unless you are sure not to have more than 100 users, it will be a very bad idea. The ideal solution will be to remember each user's storage in you Django app itself in database. I guess you would be using S3 boto library for storing the files, than it returns the byte size after each upload. You can use that to store that. There is also another way out, you could create many folders inside a bucket with each folder specific to an user. But still the best way to remember the storage usage in your app
0
0
1
0
2012-12-14T05:20:00.000
2
0
false
13,873,119
0
0
1
1
I'm building a file hosting app that will store all client files within a folder on an S3 bucket. I then want to track the amount of usage on S3 recursively per top folder to charge back the cost of storage and bandwidth to each corresponding client. Front-end is django but the solution can be python for obvious reasons. Is it better to create a bucket per client programmatically? If I do go with the approach of creating a bucket per client, is it then possible to get the cost of cloudfront exposure of the bucket if enabled?
Navigation utility without browser, light weight and fail-proof
13,873,743
5
3
811
0
python,selenium,scrapy,selenium-webdriver,phantomjs
Use Htmlunitdriver.For making it fail proof You would have to make some changes accordingly.But It will work without browser.
0
0
1
0
2012-12-14T06:23:00.000
2
0.462117
false
13,873,719
0
0
1
1
I have a use case where I need to fill the form in a website but don't have access to API. Currently we are using webdriver along with browser but it gets very heavy and not fool proof as the process is asynchronous. Is there any way I can do it without browser and also make the process synchronous by closely monitoring the pending requests? Casperjs and htmlunitdriver seems to be some of the best options I have. Can someone explain advantages or disadvantages in terms of maintenance, fail-proof, light weight. I would need to navigate complex and many different types of webpages. Some of the webpages I would like to navigate are heavily JS driven. Can Scrapy be used for this purpose?
Django absolute url works but relative url does not for static files
13,873,805
1
1
1,375
0
python,django,web,static
django requires STATIC_DIR to be absolute path. set a variable like PROJECT_DIR to os.path.dirname(os.path.realpath(__file__)). then set STATIC_DIR to os.path.join(PROJECT_DIR, 'static')
0
0
0
0
2012-12-14T06:26:00.000
1
1.2
true
13,873,755
0
0
1
1
I have searched around and apologize if this is a basic question. I am trying to get my django app to serve static files. If the STATIC_URL is set to the absolute path (ie http://localhost/static) then the files work however if STATIC_URL is relative like /static/ it doesn't pull in any static files. I would like it to be able to use /static/ for when I move the application to a production server and have a reverse proxy serving the static files.
Image upload and Manipulation in Django
13,877,675
2
1
955
0
python,django,amazon-web-services,amazon-s3,django-uploads
Uhm, you need to be more specific with your question, but we're doing the same thing and the workflow is as follows: 1) You get the file handle on file upload from request.FILES and store it somewhere on your local filesystem, so you don't work on stream -- which is what i would guess is causing your problems 2) You use PIL (or better yet, Pillow) to manipulate the image on the FS, do resizing, thumbnailing, whatever. 3) You use Boto (http://boto.cloudhackers.com/en/latest/) to upload to S3, because Boto takes the handling of AWS out of your hands. It's quite straightforward and works well
0
0
0
0
2012-12-14T10:58:00.000
3
0.132549
false
13,877,327
0
0
1
2
I am trying upload images and than create an thumbnail of it and than store both in S3. After the file has been uploaded i am first uploading it to S3 and than trying to create thumbnail but it doesn't work as than PIL is not able to recognise the image. And secondly if I create the thumbnail first than while uploading original image I get EOF. I think Django allows just once for the uploaded files to be used only once....Please kindly tell me a way to do so....Thanks in advance
Image upload and Manipulation in Django
13,889,477
0
1
955
0
python,django,amazon-web-services,amazon-s3,django-uploads
I finally figured it out. The problem was that it was a stream that the uploaded file is stored into, so everytime i read the file it would reach the EOF. The only and best way out is to seek(0) everytime we read the file. This is also needed when playing with other files also in django.
0
0
0
0
2012-12-14T10:58:00.000
3
0
false
13,877,327
0
0
1
2
I am trying upload images and than create an thumbnail of it and than store both in S3. After the file has been uploaded i am first uploading it to S3 and than trying to create thumbnail but it doesn't work as than PIL is not able to recognise the image. And secondly if I create the thumbnail first than while uploading original image I get EOF. I think Django allows just once for the uploaded files to be used only once....Please kindly tell me a way to do so....Thanks in advance
Run multiple find and replaces in Python (on every file in the folder and sub-folder)
13,885,541
0
1
139
0
python
Use the glob module to get a list of *.html files.
0
0
0
0
2012-12-14T20:05:00.000
2
0
false
13,885,520
0
0
1
1
I have a folder (courses) with sub-folders and a random number of files. I want to run multiple search and replaces on those random files. Is it possible to do a wild card search for .html and have the replaces run on every html file ? Search and replaces: 1) "</b>" to "</strong>" 2) "</a>" to "</h>" 3) "<p>" to "</p>" Also all these replaces have to be run on every file in the folder and sub-folders. Thank you so much
pip install web2py
14,100,013
2
5
2,902
0
python,pip,web2py
I think I can give my answer to my own question: we don't need to install web2py, just download it and python it.
0
0
0
0
2012-12-16T08:46:00.000
2
1.2
true
13,899,823
0
0
1
1
I tried to install Web2py with pip. The installation is completed successfully. But after that I don't know how to start the server. I know there are three apps which are 'w2p_clone', 'w2p_apps' and 'w2p_run'. I don't know how to use these three apps. And also I did not set up my virtual env for Web2py, however even I do not have virtual env I can start Web2py sever from src code (like python web2py.py) I just want to know how to use pip intall for Web2py. Thank you very much.
openerp reporting syntax
13,906,107
2
2
1,361
0
python,report,openerp,tryton
in the first table cell, this worked: [[((case.excluded == False) or removeParentNode('blockTable')) and '']][[case.name]] although i am still interested in knowing if there's a more logical way instead of destroying the entire created blocktable, especially since i'll be trying to figure out how not to leave an empty line when removing the parent node 'blocktable'.
0
0
0
0
2012-12-16T22:09:00.000
4
1.2
true
13,905,975
0
0
1
2
I've been struggling trying to mimic in openerp a report found in Tryton for the module Health GNU. In their report folder lies a report.odt file very similar to any sxw report found in openerp, with a few exceptions that is. For instance, instead of openERP's: [[repeatIn(objects,'test')]] we have an opening and closing tag of for making the previous exmaple as such: <FOR EACH="TEST IN OBJECTS"> .... </FOR> How can I mimic the following in a traditional sxw report: <for each="case in test.critearea"> <if test="case.excluded==0"> #this is outside the table ...values in table... #table starts here </if> <for> which basically excludes an entire row when matched. using familiar syntax such as [[ case.excluded==False ]] didnt work.
openerp reporting syntax
13,925,567
2
2
1,361
0
python,report,openerp,tryton
You can iterate on a list generated by a function defined on report's related .py file. Just look for examples on the addons, there are plenty of them, like: account/report/account_aged_partner_balance.rml: [[ repeatIn(get_lines(data['form']), 'partner') ]]
0
0
0
0
2012-12-16T22:09:00.000
4
0.099668
false
13,905,975
0
0
1
2
I've been struggling trying to mimic in openerp a report found in Tryton for the module Health GNU. In their report folder lies a report.odt file very similar to any sxw report found in openerp, with a few exceptions that is. For instance, instead of openERP's: [[repeatIn(objects,'test')]] we have an opening and closing tag of for making the previous exmaple as such: <FOR EACH="TEST IN OBJECTS"> .... </FOR> How can I mimic the following in a traditional sxw report: <for each="case in test.critearea"> <if test="case.excluded==0"> #this is outside the table ...values in table... #table starts here </if> <for> which basically excludes an entire row when matched. using familiar syntax such as [[ case.excluded==False ]] didnt work.
Correct latin-1 encoded UTF-8 in Django-ORM
14,781,925
1
2
937
0
python,mysql,django,django-orm
I know that this might be OFF... but maybe prevents some headache before you make any "unicode" related change then please get to know what unicode means, and note that what you wrote "ö" == ö is only right when the unicode is encoded by the method UTF-8
0
0
0
0
2012-12-17T01:47:00.000
2
0.099668
false
13,907,359
0
0
1
1
I'm setting up a django-admin on top of a legacy MySQL database. The database declares that it is latin-1 encoded. Some of the entered data in the database is indeed in latin-1 but some is actually UTF-8. This shows up as corrupt characters like: é € ä ö The legacy application does some black magic to hide these errors and I cannot modify the database. I found a Python library ftfy that can convert latin-1 corrupted UTF-8 to real UTF-8, for example the above chars get translated to "é € ä ö". I want to use it on all django.db.models.CharField and django.db.models.TextField data that is loaded from database. How to do it? I tried to subclass django.db.models.CharField and django.db.models.TextField but couldn't figure out where to intercept the data from database. Optimal solution would be something like FTFYCharField which would always correct data that it gets from database.
How to set Flask blueprints to allow anonymous access?
13,908,497
6
1
344
0
python,authentication,flask
Flask does not require any authentication by default. Usually you have to decorate your view functions if you want such behaviour. So your error is most likely within your web server configuration.
0
0
0
0
2012-12-17T04:54:00.000
1
1
false
13,908,455
0
0
1
1
I'm working on a Flask application and don't see in the documentation how to turn off the requirement for a user to be logged in. We need to do this for some REST services coinciding (possibly) with some pages that do require logins. What's the best way to do this? I've scoured the docs and snippets and don't see how to turn off the requirement for certain blueprints. I'm getting 401 (Unauthorized) pages on all that I try. Thanks!
User registration using django and backbone over a RESTful API
13,910,427
1
1
455
0
javascript,python,django,web-applications,backbone.js
You need a REST backend in your django application in order to communicate with backbone. Django views are built to respond with html but they can also respond with json. I wouldn't recommend trying to build your own json views though, but rather use something like django-tastypie
0
0
0
0
2012-12-17T07:42:00.000
3
0.066568
false
13,910,113
0
0
1
1
I'm building a simple application as part of my learning(to understand REST APIs) using django and backbone. I would like to create a user registration and pass these values to django backend using json. Can someone point me to some examples and source codes to construct good APIs using django and using them with backbone?
Best practice for making a django webapp restart itself
13,922,532
0
1
403
0
python,django,caching
If you are running it on apache with mod_wsgi, just update the timestamp of wsgi config file everytime you make change to a model. Apache automatically restarts the application if the wsgi file gets updated.
0
0
0
0
2012-12-17T20:07:00.000
4
0
false
13,921,373
0
0
1
2
We have certain sysadmin settings that we expose to superusers of our django webapp. Things like the domain name (uses contrib.sites) and single sign-on configuration. Some of these settings are cached by the system, sometimes because we want to avoid an extra DB hit in the middleware on every request if we can help it, sometimes because it's contrib.sites, which has its own caching. So when the settings get changed, the changes don't take effect until the app is reloaded. We want the app to restart itself when these changes are made, so that our clients don't need to pester us to do the restart for them. Our webapp is running on apache via mod_wsgi, so we should be able to do this just by touching the wsgi file for the app whenever one of these settings is changed, but it feels a little weird to do that, and I'm worried there's some more graceful convention we should be following. Is there a right way to apply updates that are cached and require the app to reload? Invalidating the caches for these things will be pretty hairy, so I think I'd avoid that unless the app restart thing has serious drawbacks.
Best practice for making a django webapp restart itself
13,929,058
0
1
403
0
python,django,caching
It depends on your setup: If you are using wsgi on a single server you could touch the wsgi file to let apache restart every instance of the app If you are using gunicorn you probably use supervisord to controll it. Then a supervisorctl restart APPNAME would be the solution If you scale your app on multiple servers you have to ensure that every server restarts their instances. There are several ways to achieve this: use the same filesystem if you are using mod_wsgi then a touch would count for every server log in to the other servers using ssh and make them restart your app I am sure there are more ways to restart your app but it highly depends on your setup and whether or not you have to restart all instances or only one.
0
0
0
0
2012-12-17T20:07:00.000
4
0
false
13,921,373
0
0
1
2
We have certain sysadmin settings that we expose to superusers of our django webapp. Things like the domain name (uses contrib.sites) and single sign-on configuration. Some of these settings are cached by the system, sometimes because we want to avoid an extra DB hit in the middleware on every request if we can help it, sometimes because it's contrib.sites, which has its own caching. So when the settings get changed, the changes don't take effect until the app is reloaded. We want the app to restart itself when these changes are made, so that our clients don't need to pester us to do the restart for them. Our webapp is running on apache via mod_wsgi, so we should be able to do this just by touching the wsgi file for the app whenever one of these settings is changed, but it feels a little weird to do that, and I'm worried there's some more graceful convention we should be following. Is there a right way to apply updates that are cached and require the app to reload? Invalidating the caches for these things will be pretty hairy, so I think I'd avoid that unless the app restart thing has serious drawbacks.
Django: How can i get the sections of pdf file and jump to them?
14,459,121
0
1
119
0
javascript,jquery,python,html,django
I`m not sure, that I understand you correctly, but if you talk about Named Destinations in PDF file you should: get Named Destinations of PDF file with pyPdf library with "getNamedDestinations" method open PDF file with nameddest parameter like "http://example.org/doc.pdf#nameddest=something"
0
0
0
0
2012-12-18T15:10:00.000
1
0
false
13,935,864
0
0
1
1
I develop a simple site in django. in this site the user has to upload a pdf file, and then he can see it with tree of sections in the side. The challenge is: A. How can i read the file sections? it could be in django, python, javascript or each another idea. B. How can i jump to specific section when the user click on it? I display the file with html object tag. Thanks for any reply.
Full text search in appengine, make some fields scores more important than others?
13,942,535
2
0
152
0
python,google-app-engine,full-text-search
Unfortunately yes; we don't yet have a way for you to weight different fields more or less than others. Sorry!
0
1
0
0
2012-12-18T19:06:00.000
1
0.379949
false
13,939,773
0
0
1
1
I have a python appengine app that uses full text search. The document model has something like title: title abstract: short abstract full text: lots and lots of text If someone searches for a string, I want it ordered such that score for matches in title >> abstract >> full text. There doesn't seem to be a way to do this with the exiting scoring options, am I out of luck?
Streaming audio in Python with TideSDK
13,948,150
2
0
401
0
python,html,tidesdk
The current version has very old webkit so because of that the HTML5 support is lacking. Audio and video tags are currently not supported in windows because underlying webkit implementation (wincairo) does not support it. Wa are working on the first part to use the latest webkit. once completed we are also planning to work on the audio/video support on windows.
0
0
0
1
2012-12-18T19:52:00.000
1
0.379949
false
13,940,449
0
0
1
1
Iam trying to stream audio in my TideSDK application, but it seems to be quite difficult. The HTML5 audio does not work for me, neither does video tags. The player simply keeps loading. I've tested and confirmed that my code worked in many other browsers. My next attemp was VLC via Python bindings. But without any confirmation I do believe you need to have VLC installed for the vlc.py file to work? Basically, what I want to do is play audio in a sophisticated way (probably through Python) and wrap it in my TideSDK application. I want it to work out of the box - nothing for my end users to install. Iam by the way pretty new the the whole python thing, but I learn fast so I'd love to see some examples on how to get started! Perhaps a quite quirky way to do it would be by using flash, but I'd love not to. For those of you who are not familiar with TideSDK, its a way to build desktop applications with HTML, CSS, Python, Ruby and PHP.
How do I upload a file to a subfolder even if it doesn't exist
13,944,967
0
2
206
0
python,google-drive-api
The solution you have presented is the correct one. As you have realized, the Drive file system is not exactly like a hierarchical file system, so you will have to perform these checks. One optimization you could perform is to try to find the grand-child folder (Sub2) first, so you will save a number of calls.
0
0
0
0
2012-12-19T02:45:00.000
1
1.2
true
13,944,798
0
0
1
1
I have a Django app that needs to create a file in google drive: in FolderB/Sub1/Sub2/file.pdf. I have the id for FolderB but I don't know if Sub1 or Sub2 even exist. If not it should be created and the file.pdf should be put in it. I figure I can look at children at each level and create the folder at each level if its not there, but this seems like a lot of checks and api calls just to create one file. Its also a harder task trying to accommodate multiple folder structures (ie, one python function that can accept any path of any depth and upload a file there)
sort_options only applied when query_string is not empty?
13,954,922
-2
8
103
1
python,google-app-engine,gae-search
Could be a bug in the way you build your query, since it's not shown. Could be that you don't have an index for the case that isn't working.
0
0
0
0
2012-12-19T13:02:00.000
2
-0.197375
false
13,953,039
0
0
1
1
trying to figure out whether this is a bug or by design. when no query_string is specified for a query, the SearchResults object is NOT sorted by the requested column. for example, here is some logging to show the problem: Results are returned unsorted on return index.search(query): query_string = '' sort_options string: search.SortOptions(expressions=[search.SortExpression(expression=u'firstname', direction='ASCENDING', default_value=u'')], limit=36) Results are returned sorted on return index.search(query): query_string = 'test' sort_options string: search.SortOptions(expressions=[search.SortExpression(expression=u'firstname', direction='ASCENDING', default_value=u'')], limit=36) This is how I'm constructing my query for both cases (options has limit, offset and sort_options parameters): query = search.Query(query_string=query_string, options=options)
clicking the back button in django admin site
13,956,144
1
1
518
0
python,django-admin
What's happening Chrome is not fetching the page again, just displaying what was there "before" and Chrome stored in its cache. Chrome is not even asking your webserver about the page, and as far as your app knows, you never went back to that page. Don't worry about it However, if you: Refresh the page Try to POST some data, Chrome will have to hit your webserver, and Django will redirect to the login page.
0
0
0
0
2012-12-19T15:49:00.000
1
1.2
true
13,956,049
0
0
1
1
I am new to Django . I am trying out the django admin/auth system. I logged into the admin site first and then I logged out . After logging out and clicking the back button on my browser(Chrome) I am still getting the old admin page . Should it not be redirected to login page instead? If so Is there some configuration issue on my setup?
Does a GAE app keep a log of the emails it sends?
13,957,307
6
4
88
0
python,google-app-engine
you can try one of the following way: Log write a log to datastore while each time you call sent_mail. write log with logging module and check the log in dashboard. mail while send the email, add a debug email address in email's "bcc" field. you can also check the "sent mail" in the email account used as sender.
0
1
0
1
2012-12-19T16:27:00.000
1
1.2
true
13,956,774
0
0
1
1
Wondering if it is possible to see a history of emails that a GAE app has sent? Need to look into the history for debugging purposes. Note that logging when I send the email or bcc'ing a user are not options for this particular question as the period I'm curious about was in the past (since then we are bcc'ing).
Selenium test suite only open browser once
13,957,461
5
1
601
0
python,selenium
You can use class or module level setup and teardown methods instead of test level setup and teardown. Be careful with this though, as if you don't reset your test environment explicitly in each test, you have to handle cleaning everything out (cookies, history, etc) manually, and recovering the browser if it has crashed, before each test.
0
0
1
1
2012-12-19T17:02:00.000
1
0.761594
false
13,957,413
0
0
1
1
We have a suite of selenium tests that on setup and teardown open and close the browser to start a new test. This approach takes a long time for tests to run as the opening and closing is slow. Is there any way to open the browser once in the constructor then reste on setup and cleanup on teardown, then on the deconstructor close the browser? Any example would be really appreciated.
does GAE support django admin form
13,958,619
2
2
67
0
python,html,django,google-app-engine,datastore
If you're using CloudSQL, django models are supported, and you'll be fine. If you're using the HRD, getting the admin pages to work would be more difficult. django models are not supported. The app engine SDK comes with django-style forms that work with the GAE db.Model fields. Alternatively, you can use django-nonrel which includes a translation layer that allows django models to be used with GAE. The translation layer has various limitations, most prominently, many-to-many relations aren't support. This breaks the Django permissions module which is used by the admin. I've seen some attempts documented to get around this, but I'm not sure how successful people have been.
0
0
0
0
2012-12-19T18:10:00.000
1
1.2
true
13,958,475
0
0
1
1
I have been leaning Django so I could use the Django admin form in my GAE application. I have just read that GAE doesn't support the django models so i am thinking that it also does not support the admin form. So the question is does GAE support any other 'forms' or 'reports' environment or do you have to do everything with html
Selenium Webdriver with Java vs. Python
35,039,909
4
6
12,904
0
java,python,selenium,webdriver
"If you're running selenium tests against a Java application, then it makes sense to drive your tests with Java." This is untrue. It makes no difference what the web application is written in. Personally I prefer python because it's equally as powerful as other languages, such as Java, and far less verbose making code maintenance less of a headache. However, if you choose a language, don't write it like you were programming in another language. For example if you're writing in Python, don't write like you were using Java.
0
0
1
0
2012-12-19T20:47:00.000
5
0.158649
false
13,960,897
0
0
1
5
I'm wondering what the pros and cons are of using Selenium Webdriver with the python bindings versus Java. So far, it seems like going the java route has much better documentation. Other than that, it seems down to which language you prefer, but perhaps I'm missing something. Thanks for any input!
Selenium Webdriver with Java vs. Python
13,992,922
0
6
12,904
0
java,python,selenium,webdriver
It really does not matter. Even the Documentation. Selenium lib is not big at all. Moreover, if you are good in development, you'll wrap selenium in your own code, and will never use driver.find(By.whatever(description)). Also you'd use some standards and By.whatever will become By.xpath only. Personally, I prefer python and the reason is that and my other tests for software use other python libs -> this way I can unite my tests.
0
0
1
0
2012-12-19T20:47:00.000
5
0
false
13,960,897
0
0
1
5
I'm wondering what the pros and cons are of using Selenium Webdriver with the python bindings versus Java. So far, it seems like going the java route has much better documentation. Other than that, it seems down to which language you prefer, but perhaps I'm missing something. Thanks for any input!
Selenium Webdriver with Java vs. Python
13,961,695
0
6
12,904
0
java,python,selenium,webdriver
For me it's just a language preference. There are bindings for other languages, but I believe they communicate with Webdriver via some sort of socket interface.
0
0
1
0
2012-12-19T20:47:00.000
5
0
false
13,960,897
0
0
1
5
I'm wondering what the pros and cons are of using Selenium Webdriver with the python bindings versus Java. So far, it seems like going the java route has much better documentation. Other than that, it seems down to which language you prefer, but perhaps I'm missing something. Thanks for any input!
Selenium Webdriver with Java vs. Python
13,961,645
1
6
12,904
0
java,python,selenium,webdriver
You've got it spot on, there are ton load of documents for Java. All the new feature implementations are mostly explained with Java. Even stackoverflow has a pretty strong community for java + selenium.
0
0
1
0
2012-12-19T20:47:00.000
5
0.039979
false
13,960,897
0
0
1
5
I'm wondering what the pros and cons are of using Selenium Webdriver with the python bindings versus Java. So far, it seems like going the java route has much better documentation. Other than that, it seems down to which language you prefer, but perhaps I'm missing something. Thanks for any input!
Selenium Webdriver with Java vs. Python
13,961,711
2
6
12,904
0
java,python,selenium,webdriver
Generally speaking, the Java selenium web driver is better documented. When I'm searching for help with a particular issue, I'm much more likely to find a Java discussion of my problem than a Python discussion. Another thing to consider is, what language does the rest of your code base use? If you're running selenium tests against a Java application, then it makes sense to drive your tests with Java.
0
0
1
0
2012-12-19T20:47:00.000
5
1.2
true
13,960,897
0
0
1
5
I'm wondering what the pros and cons are of using Selenium Webdriver with the python bindings versus Java. So far, it seems like going the java route has much better documentation. Other than that, it seems down to which language you prefer, but perhaps I'm missing something. Thanks for any input!
Web fonts always return 404 from static path
23,329,676
0
1
350
0
python,pyramid
Not sure if it's still relevant to the OP, but I hit the same problem. The reason was that setup.py install simply didn't copy the font files, and the solution was to include all the font extensions in the MANIFEST.in file.
0
0
0
0
2012-12-19T20:51:00.000
2
0
false
13,960,956
0
0
1
1
I'm having trouble with a static view, it is configured to serve files from the 'assets' folder on the server, and works fine for the following '/assets/img/hdr.png','/assets/style/default.css' however when trying to serve a web font it always returns 404 not found (despite the fact I have triple checked the file is in the correct locaiton ('/assets/font.woff') Is there something additional I need to configure to allow non img/css files to be served? config.add_static_view(name='assets', path='assets') Thanks
Django, where to update failed login attempts and why?
13,964,128
1
2
1,638
0
python,django,authentication
What: I would actually implement that logic in an Authentication Backend. How: Use a specific, separate, Model to track login attempts, or, use the solution suggested by miko (fail2ban). Why: You de-couple authentication from users. Bonus: if you want to take advantage of the upcoming pluggable User models in Django, that's a good idea. On a side note, there probably is a way you can achieve an even "neater" solution by wrapping existing authentication backends to provide the required functionality.
0
0
0
0
2012-12-19T21:22:00.000
2
0.099668
false
13,961,409
0
0
1
2
I have a custom user model where I want to track number of failed login attempts and take action based on that. I am wondering what would be a better place to write this logic. Following are two options I have in mind for updating *failed_attempts* field in User model: Autheticate method in the backend. *check_password* method in the User model. I have overridden this method from AbstractBaseUser model. And the basic logic(does not cover all cases) is like this: If authentication fails check the time of previous failed login attempt. If that was recent, increment failed login count. If count reaches maximum attempt lock the account for few minutes (or do something else). My question is what would be a better place for writing this logic and why.
Django, where to update failed login attempts and why?
13,961,497
1
2
1,638
0
python,django,authentication
Using only the details you list, I would say the Authentication method is more appropriate, if only because it would be very confusing if check_password updates fields on the model. Why, though, do you have both an 'Authenticate method in the backed' and a check_password method in the model?
0
0
0
0
2012-12-19T21:22:00.000
2
1.2
true
13,961,409
0
0
1
2
I have a custom user model where I want to track number of failed login attempts and take action based on that. I am wondering what would be a better place to write this logic. Following are two options I have in mind for updating *failed_attempts* field in User model: Autheticate method in the backend. *check_password* method in the User model. I have overridden this method from AbstractBaseUser model. And the basic logic(does not cover all cases) is like this: If authentication fails check the time of previous failed login attempt. If that was recent, increment failed login count. If count reaches maximum attempt lock the account for few minutes (or do something else). My question is what would be a better place for writing this logic and why.
Can I parse xpath using python, selenium and lxml?
40,276,743
0
1
1,853
0
python,parsing,selenium,lxml,xpath
I prefer to use lxml. Because the efficiency of lxml is more higher than selenium for large elements extraction. You can use selenium to get source of webpages and parse the source with lxml's xpath instead of the native find_elements_with_xpath in selenium.
0
0
1
0
2012-12-20T04:37:00.000
2
0
false
13,965,403
0
0
1
1
So I have been trying to figure our how to use BeautifulSoup and did a quick search and found lxml can parse the xpath of an html page. I would LOVE if I could do that but the tutorial isnt that intuitive. I know how to use Firebug to grab the xpath and was curious if anyone has use lxml and can explain how I can use it to parse specific xpath's, and print them.. say 5 per line..or if it's even possible?! Selenium is using Chrome and loads the page properly, just need help moving forward. Thanks!
Getting service unavailable error in scrapy crawling
13,967,095
8
5
14,588
0
python,scrapy
HTTP status code 503, "Service Unavailable", means that (for some reason) the server wasn't able to process your request. It's usually a transient error. I you want to know if you have been blocked, just try again in a little while and see what happens. It could also mean that you're fetching pages too quickly. The fix is not to do this by keeping concurrent requests at 1 (and possibly adding a delay). Be polite. And you will encounter various errors if you are scraping a enough. Just make sure that your crawler can handle them.
0
0
1
0
2012-12-20T05:09:00.000
2
1.2
true
13,965,684
0
0
1
1
I am trying to crawl a forum website with scrapy. The crawler works fine if I have CONCURRENT_REQUESTS = 1 But if I increase that number then I get this error 2012-12-21 05:04:36+0800 [working] DEBUG: Retrying http://www.example.com/profile.php?id=1580> (failed 1 times): 503 Service Unavailable I want to know if the forum is blocking the request or there is some settings problem.
ropemacs on windows with django project is very slow
14,254,108
0
0
158
0
python,django,windows,emacs,ropemacs
As i wrote in the comments and as David said, I resorted to using Jedi.
0
0
0
0
2012-12-20T16:38:00.000
3
1.2
true
13,976,625
0
0
1
1
In a newly created Django project I'm using ropemacs to get semantic completions and refactoring functionality. But it seems that everytime I enter a character that triggers a completion list check, the buffer freezes for about a second, sometimes two. I heard that ropemacs can be slow on big projects, but is a fresh Django project considered big in this respect? I'm using YAS, rope, autocomplete and python-mode (https://launchpad.net/python-mode). In the modes section i have "Py Outl yas Rope AC", not exactly sure where Outl came from or what it does.
Detect change of browser tabs with javascript
13,989,768
2
6
3,555
0
javascript,browser,python-idle
Trap the window.onblur event. It's raised whenever the current window (or tab) loses focus.
0
0
1
0
2012-12-21T11:56:00.000
3
1.2
true
13,989,737
0
0
1
2
is there some way of detecting using javascript that a user has switched to a different tab in the same browser window. Additionally is there a way to detect a user has switched to a different window than the browser? thank you
Detect change of browser tabs with javascript
13,989,766
1
6
3,555
0
javascript,browser,python-idle
Most probably there is no standards javascript for this. Some browsers might support it but normally there is only a window.onblur event to find out the user has gone away from the current window.
0
0
1
0
2012-12-21T11:56:00.000
3
0.066568
false
13,989,737
0
0
1
2
is there some way of detecting using javascript that a user has switched to a different tab in the same browser window. Additionally is there a way to detect a user has switched to a different window than the browser? thank you
What class file to create for a link model used for many to many relasionship in google app engine
13,992,083
3
0
38
0
python,google-app-engine
It makes absolutely no difference. Firstly, however, you should realize that there's no need to have a separate file for each model. It's perfectly normal to have several model classes in one models.py file. The division is between separate apps, each of which group together related models. Secondly, you should also realize that unless you have a specific need to add extra data on the many-to-many relationship, you don't need to create a link table. Django will take care of that for you once you define a ManyToManyField.
0
0
0
0
2012-12-21T14:24:00.000
1
1.2
true
13,991,871
0
0
1
1
I have 2 models: a and b I want to build a many to many relashionship and I will use the link model method, thus I need to create an a_to_b_membership model. The question is: Should I put the model class on the a model file? The b model file? Or create a new model file? If I need to create a new model file, then how should I name it?
PyQt - Automatically refresh a custom view when the model is updated?
14,000,161
0
3
5,032
0
python,qt,user-interface,qt4,pyqt
You need to connect your view to the dataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight ) signal of the model: This signal is emitted whenever the data in an existing item changes. If the items are of the same parent, the affected ones are those between topLeft and bottomRight inclusive. If the items do not have the same parent, the behavior is undefined. When reimplementing the setData() function, this signal must be emitted explicitly.
1
0
0
0
2012-12-22T04:07:00.000
2
1.2
true
13,999,970
0
0
1
1
By default, the built-in views in PyQt can auto-refresh itself when its model has been updated. I wrote my own chart view, but I don't know how to do it, I have to manually update it for many times. Which signal should I use?
Repeatably gzip files in python
14,004,771
2
1
486
0
python,gzip
The compressed data is the same each time. The only thing that differs is likely the modification time in the header. The fifth argument of GzipFile (if that's what you're using) allows you to specify the modification time in the header. The first argument is the file name, which also goes in the header, so you want to keep that the same. If you provide a fourth argument for the source data, then the first argument is used only to populate the file name portion of the header.
0
0
0
0
2012-12-22T11:15:00.000
2
1.2
true
14,002,357
0
0
1
1
I'm writing a script in python for deploying static sites to aws (s3, cloudfront, route53). Because I don't want to upload every file on every deploy, I check which files were modified by comparing their md5 hash with their e-tag (which s3 sets to be the object's md5 hash). This works well for all files except for those that my build script gzips before uploading. Taking a look inside the files, it seems like gzip isn't really a pure function; there are very slight differences in the output file every time gzip is run, even if the source file hasn't changed. My question is this: is there any way to get gzip to reliably and repeatably output the exact same file given the exact same input? Or am I better off just checking if the file is gzipped, unzipping it and computing the md5 hash/manually setting the e-tag value for it instead?
File path encoding in Windows
14,003,444
1
0
1,880
0
python,windows
Use sys.getfilesystemencoding(). That should allow you to convert all paths that look ok. However, there can always be illegally-encoded files or folders, you have to think how to deal with those in the framework of your application. Some apps may ignore such files, others keep name as a binary blob.
0
0
0
0
2012-12-22T13:51:00.000
1
0.197375
false
14,003,386
0
0
1
1
I'm writing a small application which saves file paths to a database (using django). I assumed file paths are utf-8 encoded, but I ran into the following file name: C:\FXG™.nfo which is apparently not encoded in utf-8. When I do filepath.decode('utf-8') I get the following error: UnicodeDecodeError: 'utf8' codec can't decode byte 0x99 in position 30: invalid start byte (I trimmed the file name, so the position is wrong here). How do I know how the file paths are encoded in a way that this will work for every file name?
How to generate sound signal through a GPIO pin on BeagleBone
14,008,119
1
2
4,148
0
python,audio,beagleboard
The GPIO pins of the AM3359 are low-voltage and with insufficient driver strength to directly drive any kind of transducer. You would need to build a small circuit with a op-amp, transistor or FET to do this. Once you've done this, you'd simply set up a timer loop to change the state of the GPIO line at the required frequency. By far the quickest and easiest way of getting audio from this board is with a USB Audio interface.
0
0
0
1
2012-12-23T01:28:00.000
3
0.066568
false
14,007,965
0
0
1
1
I am looking for pointers/tips on how to generate a synthesized sound signal on the BeagleBone akin to watch the tone() function would return on a Arduinos. Ultimately, I'd like to connect a piezo or a speaker on a GPIO pin and hear a sound wave out of it. Any pointers?
Storing MySQL Passwords
14,008,320
1
2
408
1
python,mysql,django,security,encryption
Your question embodies a contradiction in terms. Either you don't want reversibility or you do. You will have to choose. The usual technique is to hash the passwords and to provide a way for the user to reset his own password on sufficient alternative proof of identity. You should never display a password to anybody, for legal non-repudiability reasons. If you don't know what that means, ask a lawyer.
0
0
0
0
2012-12-23T02:46:00.000
2
0.099668
false
14,008,232
0
0
1
2
So, a friend and I are currently writing a panel (in python/django) for managing gameservers. Each client also gets a MySQL server with their game server. What we are stuck on at the moment is how clients will find out their MySQL password and how it will be 'stored'. The passwords would be generated randomly and presented to the user in the panel, however, we obviously don't want them to be stored in plaintext or reversible encryption, so we are unsure what to do if a a client forgets their password. Resetting the password is something we would try to avoid as some clients may reset the password while the gameserver is still trying to use it, which could cause corruption and crashes. What would be a secure (but without sacrificing ease of use for the clients) way to go about this?
Storing MySQL Passwords
14,008,264
4
2
408
1
python,mysql,django,security,encryption
Though this is not the answer you were looking for, you only have three possibilities store the passwords plaintext (ugh!) store with a reversible encryption, e.g. RSA (http://stackoverflow.com/questions/4484246/encrypt-and-decrypt-text-with-rsa-in-php) do not store it; clients can only reset password, not view it The second choice is a secure way, as RSA is also used for TLS encryption within the HTTPS protocol used by your bank of choice ;)
0
0
0
0
2012-12-23T02:46:00.000
2
1.2
true
14,008,232
0
0
1
2
So, a friend and I are currently writing a panel (in python/django) for managing gameservers. Each client also gets a MySQL server with their game server. What we are stuck on at the moment is how clients will find out their MySQL password and how it will be 'stored'. The passwords would be generated randomly and presented to the user in the panel, however, we obviously don't want them to be stored in plaintext or reversible encryption, so we are unsure what to do if a a client forgets their password. Resetting the password is something we would try to avoid as some clients may reset the password while the gameserver is still trying to use it, which could cause corruption and crashes. What would be a secure (but without sacrificing ease of use for the clients) way to go about this?
What is it called, to extract an address from HTML via NLP
14,085,942
1
2
2,336
0
python,nlp,nltk
Strip the text out of the HTML page (unless there is a way from the HTML to identify the address text such as div with a particular class) then build a set of rules that match the address formats used. If there are postal addresses in several countries then the formats may be markedly different but within a country, the format is the same (with some tweaks) or it is not valid. Within the US, for example, addresses are 3 or 4 lines (including the person). There is usually a zip code (5 digits optionally followed by four more). Other countries have postal codes in different formats. Unless your goal is 100% accuracy on all addresses then you probably should aim for extracting as many addresses as you can within the budget for the task. It doesn't seem like a task for NLP unless you want to use Named Entity identification to find cities, countries etc.
0
0
0
0
2012-12-23T10:40:00.000
4
0.049958
false
14,010,297
0
0
1
1
I have 300k+ html documents, which I want to extract postal addresses from. The data is different structures, so regex wont work. I have done a heap of reading on NLP and NLTK for python, however I am still struggling on where to start with this. Is this approach called Part-of-Speech Tagging or Chunking / Partial Parsing? I can't find any document on how to actually TAG a page so I can train a model on it, or even what I should be training. So my questions; What is this approach called? How can I tag some documents to train from
Redirect and requests in flask microframework
14,011,846
1
0
223
0
python,http,redirect,response,flask
If you return redirect('someurl') in your view function it will result in a Location header being sent to the client. So unless the client decides to load the target from cache instead the view function of the target URL will be executed just like if the client accessed it directly.
0
0
0
0
2012-12-23T14:37:00.000
1
0.197375
false
14,011,819
0
0
1
1
Is there any difference in the way redirects and requests are handled in the flask micro-framework? I have a bunch of functions which are to be run before a request is made but apparently they are not being run whenever there is a redirect to another url.
synchronizing file names across servers
14,013,487
0
0
67
0
python,django,linux,deployment
If the names on the development and production server are the same, then record the rename commands in a shell-script. You can run that on both the development and the production server...
0
0
0
0
2012-12-23T17:49:00.000
1
0
false
14,013,214
0
0
1
1
I have a development & production server and some large video files. The large files need to be renamed. I don't know how to automatically change the file names in the production environment when I change their name in the development environment. I think using git is very inefficient for large files. On the development environment I copied only the first 5 seconds of the videos. I'll be using Django with South to synchronize the database and git to synchronize the code.
Web2Py minimal User authentication (username only)
14,202,881
1
1
3,519
0
python,database,authentication,web2py
web2py by default allows blank passwords. So simply hide the password fields in the login and registration forms using CSS. You should be able to use the default auth.
0
0
0
0
2012-12-25T05:40:00.000
3
0.066568
false
14,028,015
0
0
1
1
I did not find anything on the web and so I'm asking here. Is there a way to create a custom auth wich only requires a username? That means to login to a specific subpage one has only to enter a username, no email and no password etc.? Or is there a better way to do this? E.g. a subpage can only be accessed if the username (or similar) exists in a db table?
What is the best way in python/django to let users add files to the database?
14,047,603
0
0
101
0
python,html,django,url-routing
You could simply write static files to disc, and then serve them as static files. That would be easier, but it depends on your other requirements. But, from what I understand in your question you'd need: A form to upload A upload handler itself which inserts into the db A view that renders based on a path Not sure about the urls.py entry. You'll want something in there to separate this content from the rest of your site, and you'll probably also want something to safeguard against the file extensions that you serve there. note: this has security hole written all over it. I would be super careful in how you test this.
0
0
0
0
2012-12-26T23:06:00.000
1
1.2
true
14,047,401
0
0
1
1
I am trying to let users create html pages that they can view on my website. So the homepage would just have a place for file upload, then some script on my site would take the file and convert it into the html page and place it at mysite.com/23klj4d(identifying file name). From my understanding, this would mean that the urls.py file gets updated to route that url to display the html page of the file. Is it possible to let users do this? Where would I put that conversion script?
How to make a standalone app like a website form?
14,051,044
0
0
318
0
python,django,user-interface,django-forms
If I understand your requirement, you want to create UI for a Form. Also, you don't want to use browser. Then you have lots of options. Django is web-framework. You can avoid it. Simply create a UI with WxPython or PyQt (I recommend to use this) or TkInter etc. Do a google search for tutorials.
0
0
0
0
2012-12-27T06:24:00.000
2
1.2
true
14,050,356
0
0
1
1
I would like to create a small app that would be like a form on a website, but just for local files. I'm not really sure where to start (Django or other) or what to use, but I'd like to start with the GUI. What would be the best way to create a program like this? Can I use Django to create a form that would not be used in a browser and without a server?
Is there anyway to view memcache data in google app engine?
14,051,678
0
1
444
0
python,google-app-engine,memcached
What's wrong with the memcache viewer in the admin console?
0
1
0
0
2012-12-27T07:02:00.000
2
0
false
14,050,745
0
0
1
1
Basically what I want to do is see the raw data of memcache so that I can see how my data are being stored.
redis celeryd and apache
14,061,333
2
0
130
0
python,django,redis,celery
Provided you're running Daemon processes of Redis and Celery you do not need to restart them when you restart Apache. Generally, you will need to restart them when you make configuration changes to either Redis or Celery as the applications are dependent on eachother.
0
1
0
0
2012-12-27T21:05:00.000
1
1.2
true
14,061,297
0
0
1
1
I'm a bit new to redis and celery. Do I need to restart celeryd and redis every time I restart apache? I'm using celery and redis with a django project hosted on webfaction. Thanks for the info in advance.
Which python web frameworks incorporate a web sever that is suitable for production use?
14,063,549
1
0
232
0
python,frameworks
I find Django's admin very easy to use for non-technical clients. In fact, that is the major consideration for my using Django as of late. Once set up properly, non-technical people can very easily update information, which can reflected on the front end immediately. The client feels empowered.
0
0
0
0
2012-12-28T01:37:00.000
2
1.2
true
14,063,516
0
0
1
2
I need to write a very light database (sqlite is fine) app that will initially be run locally on a clients windows PC but could, should it ever be necessary, be upgraded to work over the public interwebs without a complete rewrite. My end user is not very technically inclined and I'd like to keep things as simple as posible. To that end I really want to avoid having to install a local webserver, however "easy" that may seem to you or I. Django specifically warns not to use it's inbuilt webserver in production so my two options seem to be... a) Use django's built in server anyway while the app is running locally on windows and, if it ever needs to be upgraded to work over the net just stick it behind apache on a linux box somewhere in the cloud. b) Use a framework that has a more robust built in web server from the start. My understanding is that the only two disadvantages of django's built in server are a lack of security testing (moot if running only locally) and it's single threaded nature (not likely to be a big deal either for a low/zero concurrency single user app running locally). Am I way off base? If so, then can I get some other "full stack" framework recommendations please - I strongly prefer python but I'm open to PHP and ruby based solutions too if there's no clear python winner. I'm probably going to have to support this app for a decade or more so I'd rather not use anything too new or esoteric unless it's from developers with some serious pedigree. Thanks for your advice :) Roger
Which python web frameworks incorporate a web sever that is suitable for production use?
14,069,017
0
0
232
0
python,frameworks
Use Django. It's very simple for you to get started. Also, they have the best documentation. Follow the step by step app creating tutorial. Django supports all the databases that exist. Also, the built in server is very simple to use for the development and production server. I would highly recommend Django.
0
0
0
0
2012-12-28T01:37:00.000
2
0
false
14,063,516
0
0
1
2
I need to write a very light database (sqlite is fine) app that will initially be run locally on a clients windows PC but could, should it ever be necessary, be upgraded to work over the public interwebs without a complete rewrite. My end user is not very technically inclined and I'd like to keep things as simple as posible. To that end I really want to avoid having to install a local webserver, however "easy" that may seem to you or I. Django specifically warns not to use it's inbuilt webserver in production so my two options seem to be... a) Use django's built in server anyway while the app is running locally on windows and, if it ever needs to be upgraded to work over the net just stick it behind apache on a linux box somewhere in the cloud. b) Use a framework that has a more robust built in web server from the start. My understanding is that the only two disadvantages of django's built in server are a lack of security testing (moot if running only locally) and it's single threaded nature (not likely to be a big deal either for a low/zero concurrency single user app running locally). Am I way off base? If so, then can I get some other "full stack" framework recommendations please - I strongly prefer python but I'm open to PHP and ruby based solutions too if there's no clear python winner. I'm probably going to have to support this app for a decade or more so I'd rather not use anything too new or esoteric unless it's from developers with some serious pedigree. Thanks for your advice :) Roger
python: why a File object cannot be pickled?
14,063,752
4
0
465
0
python,django
Python does not allow pickling of some functions either, because of security problems if it were to be allowed. (It depends - there are ways to pickle some functions by reference) Pickling file objects has been requested in the features threads of python many times, and the best reasoning is because it opens up additional hack vectors into the security processes of python, by allowing run-time injections of potentially malicious events. It would be very convenient to have in a number of ways, but it appears to be a security restriction.
0
0
0
0
2012-12-28T02:07:00.000
1
1.2
true
14,063,712
0
0
1
1
I am trying to understand why sending a django InMemoryUploadedFile object cannot be pickled when sending it as an argument of a celery task, Can't pickle <type 'cStringIO.StringO'>: attribute lookup cStringIO.StringO failed. So i tried out the File object, doesn't work as well, but a StringIO would work. Need some dummies' guidance in understanding the difference between the 3. thanks!
Collectstatic command is not available in Django 1.4
14,071,410
12
4
3,442
0
python,django,python-2.7
Check settings.py for django.contrib.staticfiles in INSTALLED_APPS and django.core.context_processors.static in TEMPLATE_CONTEXT_PROCESSORS
0
0
0
0
2012-12-28T14:50:00.000
2
1.2
true
14,071,294
0
0
1
2
So I'm trying to run collectstatic to push some files to AWS, but I keep getting a "unknown command" error. When running manage.py help I get a list of subcommands, and sure enough collectstatic is not there. I have looked also in the installed apps part of settings.py and the staticfiles app is installed. Python is version 2.7 and Django is 1.4 This project was not built by me. I'm just a frontend developer who has been dragged into the world of programming D: Maybe the solution is really easy. Thanks!
Collectstatic command is not available in Django 1.4
18,474,545
4
4
3,442
0
python,django,python-2.7
For those for whom the accepted answer did not work, doing python manage.py collectstatic worked while python django-admin.py collecstatic did not. Maybe that can help some.
0
0
0
0
2012-12-28T14:50:00.000
2
0.379949
false
14,071,294
0
0
1
2
So I'm trying to run collectstatic to push some files to AWS, but I keep getting a "unknown command" error. When running manage.py help I get a list of subcommands, and sure enough collectstatic is not there. I have looked also in the installed apps part of settings.py and the staticfiles app is installed. Python is version 2.7 and Django is 1.4 This project was not built by me. I'm just a frontend developer who has been dragged into the world of programming D: Maybe the solution is really easy. Thanks!
Good way to make a SQL based activity feed faster
14,074,169
1
4
499
1
python,sql,django,redis,feed
You said redis? Everything is better with redis. Caching is one of the best ideas in software development, no mather if you use Materialized Views you should also consider trying to cache those, believe me your users will notice the difference.
0
0
0
0
2012-12-28T17:04:00.000
3
0.066568
false
14,073,030
0
0
1
2
Need a way to improve performance on my website's SQL based Activity Feed. We are using Django on Heroku. Right now we are using actstream, which is a Django App that implements an activity feed using Generic Foreign Keys in the Django ORM. Basically, every action has generic foreign keys to its actor and to any objects that it might be acting on, like this: Action: (Clay - actor) wrote a (comment - action object) on (Andrew's review of Starbucks - target) As we've scaled, its become way too slow, which is understandable because it relies on big, expensive SQL joins. I see at least two options: Put a Redis layer on top of the SQL database and get activity feeds from there. Try to circumvent the Django ORM and do all the queries in raw SQL, which I understand can improve performance. Any one have thoughts on either of these two, or other ideas, I'd love to hear them.
Good way to make a SQL based activity feed faster
14,201,647
1
4
499
1
python,sql,django,redis,feed
Went with an approach that sort of combined the two suggestions. We created a master list of every action in the database, which included all the information we needed about the actions, and stuck it in Redis. Given an action ID, we can now do a Redis look up on it and get a dictionary object that is ready to be returned to the front end. We also created action id lists that correspond to all the different types of activity streams that are available to a user. So given a user id, we have his friends' activity, his own activity, favorite places activity, etc, available for look up. (These I guess correspond somewhat to materialized views, although they are in Redis, not in PSQL.) So we get a user's feed as a list of action ids. Then we get the details of those actions by look ups on the ids in the master action list. Then we return the feed to the front end. Thanks for the suggestions, guys.
0
0
0
0
2012-12-28T17:04:00.000
3
1.2
true
14,073,030
0
0
1
2
Need a way to improve performance on my website's SQL based Activity Feed. We are using Django on Heroku. Right now we are using actstream, which is a Django App that implements an activity feed using Generic Foreign Keys in the Django ORM. Basically, every action has generic foreign keys to its actor and to any objects that it might be acting on, like this: Action: (Clay - actor) wrote a (comment - action object) on (Andrew's review of Starbucks - target) As we've scaled, its become way too slow, which is understandable because it relies on big, expensive SQL joins. I see at least two options: Put a Redis layer on top of the SQL database and get activity feeds from there. Try to circumvent the Django ORM and do all the queries in raw SQL, which I understand can improve performance. Any one have thoughts on either of these two, or other ideas, I'd love to hear them.
Google App Engine - Upgrading from App Engine Helper
14,079,702
1
0
91
0
python,django,google-app-engine
You can use Django 1.4 with CloudSQL. If you're using the HRD, you'd want to use django-nonrel (the successor to App Engine Helper). While django-nonrel works, the documentation is a bit lacking at the moment.
0
1
0
0
2012-12-29T04:15:00.000
1
1.2
true
14,078,640
0
0
1
1
I would like to remove dependencies on the old-style App Engine Helper for Django in my Python-based App-Engine application . At the same time, I would like to upgrade to Python2.7 and Django1.4. I have a few questions about the upgrade process: 1) The new App Engine SDK (Version 1.7.4) states that Django is fully supported. Does this mean that neither the App Engine Helper nor the Django-norel will be required in order for Django to function on the App Engine? 2) Assuming that the answer to my previous question is that no external patches/helpers are required, I am having trouble finding an example App Engine/Django application based on the new SDK. Do you know where I could find a Django/AppEngine example that does not rely on external patches/helpers? (this will give me a known good starting point, which I can then port my existing code into). 3) Currently my database models inherit from BaseModel which was provided in the App Engine Helper. In order to not break my website, what should these models inherit from given the BaseModel will no longer exist?
django import project.app vs import app
14,078,822
1
0
345
0
python,django,import
from catalog.models import Product is fine, and i think it's better than the example. Because if you want to use the app, you have to change every single import statement where you use your project name. Don't do from myproject.myapp.models import MyModel, it's a bad practice, if you're sure that the models you importing is in the same directory, i think this one is the best : from models import Product, else from myapp.models import MyModel
0
0
0
0
2012-12-29T04:41:00.000
2
0.099668
false
14,078,762
0
0
1
1
I am going through another django tutorial and I noticed for the imports the author uses from project.app.file import item but this doesnt work unless I do from app.file import item Example: Authors version: from ecomstore.catalog.models import Product which doesnt work Error: ImportError: No module named catalog.models but this does from catalog.models import Product I am just why the authors version doesnt work for me and why and if there is a setting I can change to fix this so its easier to follow along. I am seeing this as an issue in following along and trying to understand how django works this and where the settings or configurations for this resides where I can change within my project. Thanks
Is it time to use Django 1.5?
14,079,421
3
4
1,665
0
python,django
Django 1.5 is going to be released very soon. You can start using now.
0
0
0
0
2012-12-29T06:33:00.000
2
0.291313
false
14,079,327
0
0
1
1
I'm new to Django (coming from PHP Yii), and I want to learn it by developing some web site. Should I write it on Django 1.4 or 1.5? If you had to develop a new (production) web site now, would you use Django 1.5?
How do I know a page is really fully loaded?
14,094,212
4
6
218
0
javascript,python,webview,webkit,web-crawler
There is no real way to determine if that page is fully loaded. One method is to determine the amount of time since the last request. However, some pages will make repeated requests continually. This is common with tracking scripts and some ad scripts. What I would do is use a set amount of time after the web view has said it finished loading... 5 seconds or so. It isn't perfect, but is the best you got, as there is no way to determine what "fully loaded" is for an arbitrary page.
1
0
0
0
2012-12-30T19:26:00.000
1
1.2
true
14,093,870
0
0
1
1
I am using python webkit.WebView and gtk to crawl a web page. However, the web page is kind of dynamically loaded by javascript. The WebView "load-finished" event is not sufficient to handle this. Is there any indicator/event to let me know that the page is really fully loaded even the content produced by javascript? Thanks,
Compare two rows in a one2many table in OpenERP6.1
14,102,667
0
2
467
0
python,openerp
Why cant you use _constraint? You will only get warning when you are saving the record.
0
0
0
0
2012-12-31T11:09:00.000
2
0
false
14,100,792
0
0
1
1
How can we compare two rows in a oneTomany table in OpenERP6.1? I have a main table, say 'XX' and i have a oneTomany table, say 'YY' corresponding to that table. Now, i have three columns in the 'YY' table.Every time i create records into this table, i want to check if the values in the three columns are identical. i.e if i click the create button and entered the first row with values 'happy','new','year', the next time when you enter the same values, you should be prompted with a message that these values should not be repeated.
How do I run South migrations (Django) on a database server?
14,116,934
1
0
101
0
python,mysql,database,django,django-south
It doesn't matter if the database is running on the same machine as django/South. Wherever your django installation lives has the database configured in its settings. South migrations should work exactly the same.
0
0
0
0
2013-01-02T04:40:00.000
1
1.2
true
14,116,907
0
0
1
1
Originally, I've just had servers that have both Django, South and my database installed (web + database server combined). But now, we're moving to a dedicate database server, and a dedicate web app server. Since the database server doesn't have Django or South installed, how can I run migrations? Or at least, what's the best way to update the database with new schema changes? It's MySQL if that helps.
Where is the value stored for a one2many table initially in OpenERP6.1
14,119,351
2
2
1,493
1
python,openerp
When saving a new record in openerp, a dictionary will be generated with all the fields having data as keys and its data as values. If the field is a one2many and have many lines, then a list of dictionaries will be the value for the one2many field. You can modify it by overriding the create and write functions in openerp.
0
0
0
0
2013-01-02T08:57:00.000
3
0.132549
false
14,119,208
0
0
1
2
I would like to know as to where is the value stored for a one2many table initially in OpenERP6.1? i.e if we create a record for a one2many table,this record will be actually saved to the database table only after saving the record of the main table associated with this, even though we can create many records(rows) for one2many table. Where are these rows stored? Are they stored in any OpenERP memory variable? if so which is that variable or function with which we can access those.. Please help me out on this. Thanks in Advance!!!
Where is the value stored for a one2many table initially in OpenERP6.1
14,120,545
0
2
1,493
1
python,openerp
One2Many field is child parent relation in OpenERP. One2Many is just logical field there is no effect in database for that. If you are creating Sale order then Sale order line is One2Many in Sale order model. But if you will not put Many2One in Sale order line then One2Many in Sale order will not work. Many2One field put foreign key for the related model in the current table.
0
0
0
0
2013-01-02T08:57:00.000
3
0
false
14,119,208
0
0
1
2
I would like to know as to where is the value stored for a one2many table initially in OpenERP6.1? i.e if we create a record for a one2many table,this record will be actually saved to the database table only after saving the record of the main table associated with this, even though we can create many records(rows) for one2many table. Where are these rows stored? Are they stored in any OpenERP memory variable? if so which is that variable or function with which we can access those.. Please help me out on this. Thanks in Advance!!!
bad operand type for abs(): 'str' in django
18,424,335
0
1
15,930
0
django,python-2.7,django-templates
I think your are writing the code from "beginning Django E-commerce" book. The error is in your code you write {{ cart_sutotal|currency }} in place of {{ cart_subtotal }} .
0
0
0
0
2013-01-02T10:43:00.000
5
0
false
14,120,640
0
0
1
3
I am going through the beginning django ecommerce application for shopping cart app. I am getting the error as mentioned above while clicking the add to cart button. I am getting the error at the line {{ cart_sutotal|currency}}
bad operand type for abs(): 'str' in django
14,121,826
1
1
15,930
0
django,python-2.7,django-templates
The currency filter expects its argument to be a numeric value; you're passing a string to your template as cart_sutotal. Before passing it to the template, convert it to a decimal.Decimal, or, better, figure out why you're adding up price values and coming up with a string for the subtotal.
0
0
0
0
2013-01-02T10:43:00.000
5
0.039979
false
14,120,640
0
0
1
3
I am going through the beginning django ecommerce application for shopping cart app. I am getting the error as mentioned above while clicking the add to cart button. I am getting the error at the line {{ cart_sutotal|currency}}
bad operand type for abs(): 'str' in django
14,120,681
0
1
15,930
0
django,python-2.7,django-templates
You are missing a cast somewhere in your code. Wherever in the code you're doing abs(somevar) you need to cast a string to an integer by doing abs(int(somevar)). More info if you post a stacktrace or pieces of code.
0
0
0
0
2013-01-02T10:43:00.000
5
0
false
14,120,640
0
0
1
3
I am going through the beginning django ecommerce application for shopping cart app. I am getting the error as mentioned above while clicking the add to cart button. I am getting the error at the line {{ cart_sutotal|currency}}
How to convert a html page to pdf in Django
14,161,687
0
1
2,954
0
python,html,django,pdf,phantomjs
Okay, after whole lot googling, I couldn't find anything. So I came up with two hackish solutions. On the page which user is viewing, create a form with a hiding text area, the submit button is named 'Generate PDF', after rendering the page, I use JavaScript to get all the html within the divs I want and put them into the text area. When the button is clicked, the html will be passed to the server side, then I use python to create a html file locally and use Phantomjs to create a PDF according to the html file. Create a url render the exact same page user is viewing, but don't need to require user logging in. So one has to configure the Apache or Nginx so that url only can be accessed by the local host. So Phantomjs can access the url without any problem and generate the PDF.
0
0
0
0
2013-01-03T11:12:00.000
4
1.2
true
14,137,778
0
0
1
1
I am using Django to create a report site. The reports are generated dynamically, they also include some SVG charts. I want to create a PDF file which is based on the current report the user is viewing, but with extra header and footer. I came across Phantomjs, two problems though, first is that the page requires user to log on, so if I send the url to the server, phantomjs creates the pdf for the logging page; second the reports are generated using ajax, so even the same url will have different reports. Is there any better way to do this?
How to load custom packages from inside Django apps into views.py?
14,147,669
0
1
1,150
0
django,model-view-controller,python-3.x,django-views,three-tier
If Class1 or parser import from views, then you have a circular dependency. You'll need to move any shared code out into a third file. You might consider though whether you need all those separate files under logic. In Python there's no requirement to have a class in its own file, so maybe you could have a single logic.py instead of a logic directory containing several files.
0
0
0
0
2013-01-03T19:21:00.000
1
0
false
14,145,677
0
0
1
1
I am new to Django and have a little problem with making all the project structure clear and organized and so on.. The MVC stuff in Django is quite easy to use when making a small project. However, when I am trying to get a new layer (application logic, like three-tier architecture) between views.py and models.py I have problem to do so. I have the following structure: mysite/ manage.py app1/ models.py views.py logic/ __init__.py Class1.py parser.py ... and I want to load into views.py stuff from Class1.py and parser.py. How do I do it? Neither of the following works: from app1.logic import * from app1.logic.Class1 import Class1 Also, it would help me if somebody could list me some example of a really huge django project. It looks like either lots of classes and .py files should be in every app folder or everything is in the models.py.. Both look a little disorganised and I'm sure there is a way to make it a little bit clearer (like in Zend or Symfony). And, I'm working with Python3 and Django 1.5b2. Thanks.
HA deploy for Python wsgi application
14,148,902
0
2
2,227
0
python,nginx,wsgi,haproxy
Of the three options, only option number 1 has any chance of working with websockets. Nginx, and most standard webservers will not play nicely with them.
0
1
0
0
2013-01-03T20:34:00.000
2
0
false
14,146,814
0
0
1
1
I consider this scenarios for deploying High Available Python web apps: load balancer -* wsgi servers load balancer -* production HTTP sever - wsgi server production HTTP sever (with load balancing features, like Nginx) -* wsgi servers For load balancer I consider HAProxy For production HTTP sever I consider Nginx For wsgi servers I mean servers which directly handle wsgi app (gevent, waitress, uwsgi...) -* means one to many connection - means one to one connection There is no static content to serve. So I wonder if production HTTP server is needed. What are the pros and cons of each solution? For each scenario (1-3), in place of wsgi server is there any advantage of using wsgi container server (uWSGI, gunicorn) rather then raw wsgi server (gevent, tornado..)? I'm also wondering which solution is the best for websockets or long polling request?
Creating year dropdown in Django template
14,152,733
0
2
10,836
0
python,django,django-templates
I would suggest to use Javascript or jQuery at client side to populate the dropdown according to the current year.
0
0
0
0
2013-01-04T06:41:00.000
5
0
false
14,152,389
0
0
1
1
I want to create a year dropdown in django template. The dropdown would contain start year as 2011, and end year should be 5 years from current year. For ex: If today i see the dropdwon it will show me years ranging from 2011, 2012, 2013,...2017. It can be done by sending a list from views.py and looping it in the template or defining inside forms.py. But i don't want to use any form here. I just have to show it in a template. How can i do it in Django template.
Why should I use `mod_wsgi` instead of launching by python?
14,152,716
4
1
82
0
python,django,apache,mod-wsgi,wsgi
Since I answered your other question regarding Flask, I assume you are referring to using Flask's development server. The problem with that is it is single threaded. Using mod_wsgi, you would be running behind apache, which will do process forking and allow for multiple simultaneous requests to be handled. There are other options as well. Depending on your particular use case I would consider using eventlet's wsgi server.
0
0
0
1
2013-01-04T07:02:00.000
1
0.664037
false
14,152,651
0
0
1
1
I was wondering what is the advantages of mod_wsgi. For most python web framework, I can launch (daemon) the application by python directly and serve it in a port. Then when shall I use mod_wsgi?
What is a main reason that Django webserver is blocking?
14,158,864
5
3
176
0
python,django,webserver,tornado,blocking
I believe It is single threaded and blocking so it is easy to debug. if you put a debugger in it will completely halt the server
0
1
0
0
2013-01-04T14:19:00.000
2
1.2
true
14,158,844
0
0
1
2
Why is the Django webserver blocking, not non-blocking like Tornado? Was there a reason to design the webserver in this way?
What is a main reason that Django webserver is blocking?
14,159,011
5
3
176
0
python,django,webserver,tornado,blocking
If you really need another reason on top of that suggested by dm03514, it I'd probably simply because it was easier to write. Since the dev server I'd for development only, little effort was spent in making it more complex or able to serve multiple requests. In fact, this is an explicit goal: making it any better would encourage people to use it in a production setting, for which it is not tested.
0
1
0
0
2013-01-04T14:19:00.000
2
0.462117
false
14,158,844
0
0
1
2
Why is the Django webserver blocking, not non-blocking like Tornado? Was there a reason to design the webserver in this way?