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
GAE: scheduled import of big gzipped file from a third party site
5,211,520
0
0
87
0
python,google-app-engine
My initial gut reaction (without knowing what's inside the gzipped file) is to do the processing somewhere else (AWS?) and then pushed the processed data to your GAE application in small bits.
0
1
0
0
2011-03-06T14:45:00.000
2
0
false
5,211,129
0
0
1
2
I'm working on a Python web app that needs to import big (in terms of GAE limits) gzipped files from a third party site on regular basis. Think of rdf exports DMOZ project is producing on regular intervals. This means daily fetching of a 500+ MB gzip file, gunzipping, parsing, processing and storing the results in GAE's datastore for later use. What's the proper way to implement this functionality on GAE, having in mind the limits for maximum download, processing time, etc?
GAE: scheduled import of big gzipped file from a third party site
5,226,725
1
0
87
0
python,google-app-engine
The limit on downloaded file size in App Engine is currently 64MB. As a result, you've got two options: Use HTTP Range headers to download and process the file in chunks. Use an external service to do the download, split it into pieces, and send the pieces to your App Engine app.
0
1
0
0
2011-03-06T14:45:00.000
2
1.2
true
5,211,129
0
0
1
2
I'm working on a Python web app that needs to import big (in terms of GAE limits) gzipped files from a third party site on regular basis. Think of rdf exports DMOZ project is producing on regular intervals. This means daily fetching of a 500+ MB gzip file, gunzipping, parsing, processing and storing the results in GAE's datastore for later use. What's the proper way to implement this functionality on GAE, having in mind the limits for maximum download, processing time, etc?
Django 1.2.3 compatible with python 2.5.2 ? Weird django behaviour
5,216,170
0
0
180
0
python,django,rendering
By default mod_python decides when to reload, so you'll get what you get when you get it. Maybe I am mistaken, but I thought there was a directive you could send that would explicitly force the python reload now. That should (in theory) help with achieving consistent but perhaps not ideal, behavior. Off topic, this sounds like a good opportunity to enhance your app's logging so you'll have better breadcrumbs to follow next time things hang.
0
0
0
0
2011-03-06T15:26:00.000
3
0
false
5,211,338
0
0
1
1
Well main question of the day will django work correctly under python 2.5.2 ? So why i am asking this question? First of all i have some test class written , nothing special which renders a page. The problem is that everytime i access this page i get random 3 different responses : 1)exceptions must be classes, instances, or strings (deprecated), not type 2) Http404 3) page renders normally . And generally i can refresh until i get the result i want , well in my case normally rendered page. I am a little bit confused what even to think . Because my written class does pretty much nothing.Just a test class to test some things. I run Django 1.2.3 under python 2.5.2 on Debian . Also what i noticed . I use PyCharm 1.1.1 through remote host with auto upload every time change is made , it uploads but somehow changes are not always applied after initial upload . What i mean is that it feels like files are not compiled ~~ if u can say it this way ... What's teh chance that it has basically nothing to do with python and django O_O and that are some other weird bugz ?
Django manage.py syncdb doing nothing when used with sqlite3
5,211,417
3
4
5,639
1
python,django,sqlite
As always, syncdb does not migrate the existing schema.
0
0
0
0
2011-03-06T15:26:00.000
3
0.197375
false
5,211,340
0
0
1
1
I'm not sure if this is an issue specific to sqlite databases but after adding some properties I executed syncdb successfully but still the the columns were not added to the database and when I try the access the model in admin I get no such column error. Why is this happening and how do I overcome this issue? Details: Django 1.3, Python 2.6, OSX 10.6, PyCharm.
Could Python be compiled to run on the V8 Engine?
5,214,600
3
7
2,419
0
python,v8
There are already three projects that provide a Python to Javascript compiler. The resulting Javascript can then be run on any engine including V8. Look for Pyjamas, Skulpt and Py2JS. This is not the same as compiling Python to V8 bytecodes, but the end result is much the same.
0
0
0
0
2011-03-06T23:26:00.000
7
0.085505
false
5,214,230
1
0
1
3
Presumably Javascript is compiled to some kind of byte-code to run on the V8 Engine? Is Python a similar enough language that we can imagine Python being compiled to the same byte-code and run on the V8? Any projects trying to do this?
Could Python be compiled to run on the V8 Engine?
5,611,008
3
7
2,419
0
python,v8
V8 doesn't actually have a general purpose bytecode. There's a regexp byte code, but support is not usually compiled in. There's a deserialization byte code and a relocation information byte code, but both are implemtation details and you can't use them for anything. So what you are looking for is something that compiles to JS source code.
0
0
0
0
2011-03-06T23:26:00.000
7
1.2
true
5,214,230
1
0
1
3
Presumably Javascript is compiled to some kind of byte-code to run on the V8 Engine? Is Python a similar enough language that we can imagine Python being compiled to the same byte-code and run on the V8? Any projects trying to do this?
Could Python be compiled to run on the V8 Engine?
5,214,247
-5
7
2,419
0
python,v8
Python is already compiled to bytecode and executed. This is what the .pyc files are in CPython. Jython likewise compiles to Java bytecode (dynamically), and so does IronPython for .NET
0
0
0
0
2011-03-06T23:26:00.000
7
-1
false
5,214,230
1
0
1
3
Presumably Javascript is compiled to some kind of byte-code to run on the V8 Engine? Is Python a similar enough language that we can imagine Python being compiled to the same byte-code and run on the V8? Any projects trying to do this?
Django: what is the difference (rel & field)
5,223,598
-18
57
11,436
0
python,django,entity-relationship
If you discovered ManyToManyRel by digging into the source code, you can read the docstrings for the class. It's not documented anywhere - on purpose, because it's not for external use. It is certainly not meant for defining actual field relationships between models.
0
0
0
0
2011-03-07T07:17:00.000
2
1.2
true
5,216,891
0
0
1
1
What is the difference between Django's models.ManyToManyField and models.ManyToManyRel? I'm confused about this stuff.
App Engine Bulkloader
5,220,288
2
1
1,639
0
python,google-app-engine,bulkloader
If you're using App Engine Launcher, simply click the Deploy button; it runs appcfg.py update. appcfg is installed as part of the SDK.
0
1
0
0
2011-03-07T12:55:00.000
4
0.099668
false
5,219,977
0
0
1
1
I am trying to use Bulkloader of google app engine but unfortunately could not understand what to do from documentation. It says add this part to app.yaml builtins: - remote_api: on ok i have added. Then says that i have to execute this command appcfg.py update but i don't have any appcfg.py file. And also what is the command which executes this line? Please somebody tell me what i am missing I use AppEngineLauncher to upload my project to server.. I have naver used a command to update or upload it. Thanks in advance..
Limit amount of writes to database using memcache
5,222,081
6
2
1,124
1
python,google-app-engine,caching,memcached,google-cloud-datastore
This is a recipe for lost data. I have a hard time believing that a guest book is causing enough write activity to be an issue. Also, the bookkeeping involved in this would be tricky, since memcache isn't searchable.
0
1
0
0
2011-03-07T16:12:00.000
3
1.2
true
5,221,977
0
0
1
1
I am trying to modify the guestbook example webapp to reduce the amount of database writes. What I am trying to achieve is to load all the guestbook entries into memcache which I have done. However I want to be able to directly update the memcache with new guestbook entries and then write all changes to the database as a batch put.() every 30 seconds. Has anyone got an example of how I could achieve the above? it would really help me! Thanks :)
Cross Platform App with Localization
5,225,427
0
0
176
0
python,ruby,eclipse,netbeans,monodevelop
Tcl/tk has excellent unicode support, and a very workable message catalog library. It's also highly portable to all major platforms (and several not-so-major platforms). In addition, you have the option of packaging your whole app up as a platform-dependent runtime (tclkit) and platform-independent application file (starkit), or combine the two into platform-specific single-file executables (starpack). In your case I'm guessing you might want a third file that is the audio for a specific language. So, you could have the main application and "language packages" that contain the message catalogs and .mp3 files for each language. Since you mention Python as a tag, another choice would be Python with Tkinter, wxPython or pyGTK. Python's unicode support isn't as clean as Tcl's, though, and requires a little more work to support.
0
0
0
0
2011-03-07T20:56:00.000
1
1.2
true
5,225,155
0
0
1
1
I am interested in developing a simple language learning (French, German, etc) desktop application to assist users in learning vocabulary by seeing and listening (via MP3 files) to words simultaneously. I done some programming when I was younger and see this as a long term project to get back into programming by developing an application to help me with language learning that I can share with others. In addition to helping English speakers learn other languages I would like the application to be localized so that the interface (and audio files) could be switched to assist others in learning English. I am very open minded and have read about Eclipse, MonoDevelop & NetBeans to develop a cross platform GUI. I have also read a lot of good things about Ruby and Python so would be interested on any advice/recommendation on which combination of language and tools I should use.
Implementing Django with ODK Aggregate
7,540,809
1
0
469
0
python,django,google-app-engine
ODK Aggregate is written on Java stack. If you want to use python/Django to make it more user friendly and good looking, it is better to rewrite it completely instead of mixing technologies. Several ODK Build alternatives are available, neither one of those was built on top of others, so it is not mandatory what you are trying to do as long as you follow the XForms specification.
0
1
0
0
2011-03-08T00:59:00.000
1
0.197375
false
5,227,167
0
0
1
1
I'm working on a project where our team is trying to implement Django into the ODK Aggregate platform, we don't quite enjoy their choice of functionality/looks, so we want to create a better template and make it more user-friendly. We've yet to understand how to upload Django onto the Appengine/Appspot, Aggregate was previously installed on the Appengine, and the Django package was >3000 files, and we got errors when trying to upload the full package. Does anyone know of a successful implementation of Django with ODK Aggregate specifically?
Securely storing account balances in a database?
5,236,907
1
3
453
1
python,database,django,web-applications
My language agnostic recommendation would be to make sure that the database that communicates with the web app is read only; at least for the table(s) that deal with these account balances. So, you process payments, and manage the reduction of account balances in a database that is not accessible to anyone other than you (i.e. not connected to the internet, or this web app). You can periodically take snapshots of that database and update the one that interacts with the webapp, so your users have a read copy of their balance. This way, even if a user is able to modify the data to increase their balance by a million bucks, you know that you have their true balance in a separate location. Basically, you'd never have to trust the data on the webapp side - it would be purely informational for your users.
0
0
0
0
2011-03-08T18:45:00.000
2
0.099668
false
5,236,855
0
0
1
2
So I have a Django web application and I need to add a payment module to it. Basically a user will prepay for a certain amount of service and this will slowly reduce over as the user uses the service. I'm wondering what is the best practice to facilitate this? I can process payments using Satchmo, but then just storing the USD value in a database and having my code interacting with that value directly seems kind of risky. Sure I can do that but I am wondering if there is a well tested solution to this problem out there already?
Securely storing account balances in a database?
5,236,901
6
3
453
1
python,database,django,web-applications
I don't know about a "well-tested solution" as you put it, but I would strongly caution against just storing a dollar value in the database and increasing or decreasing that dollar value. Instead, I would advise storing transactions that can be audited if anything goes wrong. Calculate the amount available from the credit and debit transactions in the user account rather than storing it directly. For extra safety, you would want to ensure that your application cannot delete any transaction records. If you cannot deny write permissions on the relevant tables for some reason, try replicating the transactions to a second database (that the application does not touch) as they are created.
0
0
0
0
2011-03-08T18:45:00.000
2
1.2
true
5,236,855
0
0
1
2
So I have a Django web application and I need to add a payment module to it. Basically a user will prepay for a certain amount of service and this will slowly reduce over as the user uses the service. I'm wondering what is the best practice to facilitate this? I can process payments using Satchmo, but then just storing the USD value in a database and having my code interacting with that value directly seems kind of risky. Sure I can do that but I am wondering if there is a well tested solution to this problem out there already?
Can web2py work with svn?
5,240,964
5
1
742
0
python,web2py
Yes, it works fine with svn, hg, whatever source control you need to use. Sometimes people think that you have to code with web2py's admin interface, but that really is not the case, once you realize it can be edited with any of your regular tools, you will see that you don't have to treat it any differently when it comes to source control either. If you use the source version of web2py, you'll have a single folder on disk that contains an entire web2py application server (that in turn contains your 'application' folders). Just check that whole folder into source control. Now, on the machine that is running web2py, you can make changes either with web2py's web interface, or by just editing the python files directly with another editor (I use WingIDE for example). You'll have the normal svn update/modify/commit cycle at this point. If multiple people are editing code using web2py's admin interface, all of their changes will be made on the machine running web2py... just periodically do a commit from that system and you are all set. Using the admin interface to modify the source code is convenient, but for for bigger changes, each member of your team should have their own local copy of the svn branch. They make changes to their local files and commit them. Then from the server running web2py, just do an 'svn up' to get modifications from the rest of the team.
0
0
1
0
2011-03-09T02:27:00.000
1
1.2
true
5,240,646
0
0
1
1
I just start to learn python and web2py. Because of web2py's web interface development, I am wondering how can web2py work with svn? If a team wants to build a website,how do they work together? How to control the iteration of source code?
Detect if a model has changed before calling save in Django
5,246,846
34
21
16,703
0
python,django,django-models
If you save your instance through a form, you can check form.has_changed().
0
0
0
0
2011-03-09T02:31:00.000
5
1
false
5,240,670
0
0
1
2
I have a database model that is being updated based on changes in remote data (via an HTML scraper). I want to maintain a field called changed - a timestamp denoting when the last time that model's values changed from what they were previously (note that this is different from auto_now as these fields are updated every time a model's save method is called). Here is my question: In a model's save method, is there a straightforward way to detect if a model instance's current values are different from the values in the database? Or, are there any alternative methods to easily maintain a changed timestamp?
Detect if a model has changed before calling save in Django
5,242,167
3
21
16,703
0
python,django,django-models
You might try computing a checksum of the record values when you save them. Then when you read it later, recompute the checksum and see if it has changed. Perhaps the crc32 function in the Python zlib standard module. (I'm not sure what kind of performance this would have. So you may want to investigate that.)
0
0
0
0
2011-03-09T02:31:00.000
5
0.119427
false
5,240,670
0
0
1
2
I have a database model that is being updated based on changes in remote data (via an HTML scraper). I want to maintain a field called changed - a timestamp denoting when the last time that model's values changed from what they were previously (note that this is different from auto_now as these fields are updated every time a model's save method is called). Here is my question: In a model's save method, is there a straightforward way to detect if a model instance's current values are different from the values in the database? Or, are there any alternative methods to easily maintain a changed timestamp?
django - how to get model objects from another process instead of database
5,245,050
0
0
246
0
python,django,web-applications,django-models
i think better to use `memcached (http://memcached.org/) in mem cached server and each server see this server also you can serialize your data and send it like udp and other method
0
0
0
0
2011-03-09T06:37:00.000
2
0
false
5,242,230
0
0
1
2
I have a TCP server, a Python app, that gets the information from the connected devices. This information I am trying to show using Django web app. So, basically my model objects reside within the TCP server process. I can modify the TCP server to put the information into SQLite database and have my Django web app take it from there. But, it is not the most natural way of sharing information in this case because this information is not persistent i.e. not suitable for database. When my TCP server exists, it has to clear this information. How do I model this scenario using Django?
django - how to get model objects from another process instead of database
5,244,998
1
0
246
0
python,django,web-applications,django-models
You may be able to serialise your model and pass the serialised data.
0
0
0
0
2011-03-09T06:37:00.000
2
1.2
true
5,242,230
0
0
1
2
I have a TCP server, a Python app, that gets the information from the connected devices. This information I am trying to show using Django web app. So, basically my model objects reside within the TCP server process. I can modify the TCP server to put the information into SQLite database and have my Django web app take it from there. But, it is not the most natural way of sharing information in this case because this information is not persistent i.e. not suitable for database. When my TCP server exists, it has to clear this information. How do I model this scenario using Django?
AppEngine Analytics Model with Lists of Times
5,251,064
0
1
175
0
python,google-app-engine,model,transactions,google-cloud-datastore
There's no reason to shard a model. There's no limit on the number of entities you can have with a given kind name - they're all stored in the same Bigtable anyway! It's not clear what you're trying to do that requires filtering on a list. Can you clarify? What sort of query do you want to perform?
0
1
0
0
2011-03-09T18:11:00.000
2
0
false
5,250,236
0
0
1
2
I want to log analytics data (when someone loads page X, loads a js plugin, cancels a transaction) for my AppEngine app. I'm going to set it up as follows: 1. Event X occurs. 2. Add to taskqueue to put this event in the datastore. 3. Filter over datastore to graph and analyze usage data. So here's the issue: I'd like create a single Analytics Model and store each event as a timestamp on a corresponding list for that action. I'm going to shard this single Model into several instances in the datastore and write to each one randomly and then combine the results for graphing. BUT, GAE can't filter on lists, so I can't do things like filter for all events TODAY (which is what I'd really like to do). Any help or advice is appreciated.
AppEngine Analytics Model with Lists of Times
5,360,121
0
1
175
0
python,google-app-engine,model,transactions,google-cloud-datastore
Instead of logging this data inside your app, have you considered imbedding a proper analytics software, such as Google Analytics in your app? Your app is not really all that different from a normal website, even if you require logins. Google Analytics will provide you a much better reporting suit than just putting data into datastore. We did similar stuff with Omniture at my previous gig, and it worked wonderfully, for example allowing us to focus on specific browsers to support.
0
1
0
0
2011-03-09T18:11:00.000
2
0
false
5,250,236
0
0
1
2
I want to log analytics data (when someone loads page X, loads a js plugin, cancels a transaction) for my AppEngine app. I'm going to set it up as follows: 1. Event X occurs. 2. Add to taskqueue to put this event in the datastore. 3. Filter over datastore to graph and analyze usage data. So here's the issue: I'd like create a single Analytics Model and store each event as a timestamp on a corresponding list for that action. I'm going to shard this single Model into several instances in the datastore and write to each one randomly and then combine the results for graphing. BUT, GAE can't filter on lists, so I can't do things like filter for all events TODAY (which is what I'd really like to do). Any help or advice is appreciated.
Economically deleting data from app engine
5,252,580
0
8
524
0
python,google-app-engine
You mean you used GQL in the datastore admin? Like, delete from x...? And that was too expensive? Hmmm... Well, you might save some money if you integrate deleting into your runtime code. ie, if a user is logged in, you're already accessing the db, presumably with the same indicies, so why not delete it then? You would end up with fewer overall transactions if you do it right.
0
1
0
0
2011-03-09T21:37:00.000
6
0
false
5,252,477
0
0
1
4
I have a popular social game, for which I was storing every user action as an Event entity in the data store and then once per day exporting these events from GAE for processing. Now I'd like to delete all of these entities from the data store, all 300 million of them. I started using the "datastore admin" for this. In the first few hours I let it run, it managed to delete about 2 million entities and use $10 of CPU to do this. So it seems it will cost $1500 just to run this delete. I'm starting to think I would be better off just deleting the whole application and copy items I don't want to delete over to the new application. Any other options? Update I got advice on #appengine in IRC that simply getting the keys of 2000 entities at a time and spawning tasks to delete them in pieces (can pass keys as strings to tasks) may be cheaper than using the Datastore Admin tool. I am trying this now and will try to remember to report back tomorrow if this seems to be cheaper or not.
Economically deleting data from app engine
5,257,085
0
8
524
0
python,google-app-engine
Questions. - Are your Event entities grouped in entity groups? - How many indexes do you have? Any composite ones? - How many properties that are not indexed=False? Just trying to determine the cost of a delete. You may be able have some of your indexes vacuumed before you start deleting the entities.
0
1
0
0
2011-03-09T21:37:00.000
6
0
false
5,252,477
0
0
1
4
I have a popular social game, for which I was storing every user action as an Event entity in the data store and then once per day exporting these events from GAE for processing. Now I'd like to delete all of these entities from the data store, all 300 million of them. I started using the "datastore admin" for this. In the first few hours I let it run, it managed to delete about 2 million entities and use $10 of CPU to do this. So it seems it will cost $1500 just to run this delete. I'm starting to think I would be better off just deleting the whole application and copy items I don't want to delete over to the new application. Any other options? Update I got advice on #appengine in IRC that simply getting the keys of 2000 entities at a time and spawning tasks to delete them in pieces (can pass keys as strings to tasks) may be cheaper than using the Datastore Admin tool. I am trying this now and will try to remember to report back tomorrow if this seems to be cheaper or not.
Economically deleting data from app engine
5,260,096
3
8
524
0
python,google-app-engine
Presuming your goal is to delete for the cheapest cost, rather than face migration, I would launch a self-scheduling task, that would clean up several hundred/thousand keys in each run, then re-schedules itself. I would purposefully throttle this task on a separate queue so that the task ran only often enough to avoid hitting my daily free quotas if possible. If you have some "acceptable" CPU cost per day that you'd be willing to live with, you could throttle the queue less, either way it would be better if each delete doesn't take too long to complete so it doesn't impact instance latency too heavily. kevpie's comment on vacuuming may also be relevant if you have composite indexes.
0
1
0
0
2011-03-09T21:37:00.000
6
0.099668
false
5,252,477
0
0
1
4
I have a popular social game, for which I was storing every user action as an Event entity in the data store and then once per day exporting these events from GAE for processing. Now I'd like to delete all of these entities from the data store, all 300 million of them. I started using the "datastore admin" for this. In the first few hours I let it run, it managed to delete about 2 million entities and use $10 of CPU to do this. So it seems it will cost $1500 just to run this delete. I'm starting to think I would be better off just deleting the whole application and copy items I don't want to delete over to the new application. Any other options? Update I got advice on #appengine in IRC that simply getting the keys of 2000 entities at a time and spawning tasks to delete them in pieces (can pass keys as strings to tasks) may be cheaper than using the Datastore Admin tool. I am trying this now and will try to remember to report back tomorrow if this seems to be cheaper or not.
Economically deleting data from app engine
5,263,768
3
8
524
0
python,google-app-engine
Removing indexes first will substantially reduce the cost of deleting records. You could also limit your deletion rate to keep under the 6.5 CPU hours per day you're allocated for free, to avoid paying. Regarding doing the deletion yourself, it's unlikely you can do it more efficiently than the datastore admin tool, which already does keys-only queries and uses cursors.
0
1
0
0
2011-03-09T21:37:00.000
6
1.2
true
5,252,477
0
0
1
4
I have a popular social game, for which I was storing every user action as an Event entity in the data store and then once per day exporting these events from GAE for processing. Now I'd like to delete all of these entities from the data store, all 300 million of them. I started using the "datastore admin" for this. In the first few hours I let it run, it managed to delete about 2 million entities and use $10 of CPU to do this. So it seems it will cost $1500 just to run this delete. I'm starting to think I would be better off just deleting the whole application and copy items I don't want to delete over to the new application. Any other options? Update I got advice on #appengine in IRC that simply getting the keys of 2000 entities at a time and spawning tasks to delete them in pieces (can pass keys as strings to tasks) may be cheaper than using the Datastore Admin tool. I am trying this now and will try to remember to report back tomorrow if this seems to be cheaper or not.
Looking for a good book for Google App Engine Python
7,766,177
2
6
3,027
0
python,google-app-engine
I come back to this question after sereval searches. I rode Programming Google App Engine by Dan Sanderson and Using Google App Engine by Charles Severance (both edited O'Reilly and Google Press) and they are pretty good. I recommend it for basic usage.
0
1
0
0
2011-03-10T09:06:00.000
4
0.099668
false
5,257,456
0
0
1
1
Can you recommend me book to Google App Engine in Python? English/French books are both accepted.
How to manage cookies - with JavaScript or with HTTP Set-Cookie?
5,260,708
3
2
618
0
javascript,python,cookies
You should set your cookies wherever it's most convenient. That probably means that some cookies will come from the server and some from the client. Note, however, that, for security reasons, high-risk cookies (such as a login token) should be HTTP-Only so that they cannot be accessed from Javascript. (It goes without saying that they should be SSL-only)
0
0
0
0
2011-03-10T14:01:00.000
3
1.2
true
5,260,657
0
0
1
3
I am creating a web application within GAE environment. It heavily uses AJAX/JSON to send/receive data and all about that. I don't worry much about browsers with JS disabled and obsolete browsers as it's my personal project and I am trying to make it simple and not bloated in code. So, I use JavaScript heavily in the project. Please advise me how to manage cookies and sessions in that case better. I have two variants - use HTTP Set-Cookie where possible and JavaScript where it's not. The second is opposite - use JavaScript where possible. Both variants work fine now but I want to make it right way. With JavaScript scenario when there a cookie needs to be set, I get some data over AJAX with some keys, then with a jQuery plugin set these keys to cookies and vice versa, read cookies with JS and send them over AJAX. What a re pros and cons of both methods? Thanks!
How to manage cookies - with JavaScript or with HTTP Set-Cookie?
5,260,766
1
2
618
0
javascript,python,cookies
Cookies are always bundled with the HTTP header, so there is no 'improvement' in reading via JavaScript and sending them via AJAX to the server. For example, display-related settings such as font-size or website language are usually only relevant for the client-side, so I'd simply use JavaScript to set and retrieve such cookies. Stuff like a session ID requires server-side work anyway, so maintaining the cookie via HTTP Set-Cookie seems to be the most straightforward way to do it.
0
0
0
0
2011-03-10T14:01:00.000
3
0.066568
false
5,260,657
0
0
1
3
I am creating a web application within GAE environment. It heavily uses AJAX/JSON to send/receive data and all about that. I don't worry much about browsers with JS disabled and obsolete browsers as it's my personal project and I am trying to make it simple and not bloated in code. So, I use JavaScript heavily in the project. Please advise me how to manage cookies and sessions in that case better. I have two variants - use HTTP Set-Cookie where possible and JavaScript where it's not. The second is opposite - use JavaScript where possible. Both variants work fine now but I want to make it right way. With JavaScript scenario when there a cookie needs to be set, I get some data over AJAX with some keys, then with a jQuery plugin set these keys to cookies and vice versa, read cookies with JS and send them over AJAX. What a re pros and cons of both methods? Thanks!
How to manage cookies - with JavaScript or with HTTP Set-Cookie?
5,261,401
0
2
618
0
javascript,python,cookies
When you set cookies using headers you have the option of setting the HTTP only (i.e. no javascript access) and SSL - only. Enabling these options avoids a lot of security vulnerabilities in your application (note that setting the http only flag just prevents javascript from reading the cookie - it will still be presented in Ajax requests).
0
0
0
0
2011-03-10T14:01:00.000
3
0
false
5,260,657
0
0
1
3
I am creating a web application within GAE environment. It heavily uses AJAX/JSON to send/receive data and all about that. I don't worry much about browsers with JS disabled and obsolete browsers as it's my personal project and I am trying to make it simple and not bloated in code. So, I use JavaScript heavily in the project. Please advise me how to manage cookies and sessions in that case better. I have two variants - use HTTP Set-Cookie where possible and JavaScript where it's not. The second is opposite - use JavaScript where possible. Both variants work fine now but I want to make it right way. With JavaScript scenario when there a cookie needs to be set, I get some data over AJAX with some keys, then with a jQuery plugin set these keys to cookies and vice versa, read cookies with JS and send them over AJAX. What a re pros and cons of both methods? Thanks!
A list of everything I need for running my app on a web server
5,260,848
1
4
159
0
python,django,web-application-project
You need Python, Django, a WSGI container (e.g. mod_wsgi, uWSGI, Paste Deploy), and a database server. You make the Django project available as a WSGI app, bound to the appropriate interface on the machine.
0
1
0
0
2011-03-10T14:11:00.000
2
0.099668
false
5,260,801
0
0
1
1
What I want to know are actually 2 things. Part 1: I have a developed source code for an application in python that uses Django framework. What I want is to be able to run the code on a developer machine and see the result. What do I need for it? (my guesses): Python development enironment (Eclipse/PyDev/Aptana Studio 3 seem to be the better ones for windows not sure linux yet), I also have a postgre database already setup (I know there's a file where I have to specify connection information) - something installed from django or would this be already included in the code that I have? Part II: I also want to make a dev server accessible through internet. - this is the major part of the question and the most important. How do I publish the app? - I have a linux machine that I would do this on, but unsure of all the things I need. Apache server?
Python ORM for MS-Access
5,262,564
1
1
1,062
1
python,ms-access,orm
Web2py recently updated their DAL making it much easier to add support for new db engines. I don't believe there is currently native Jet (MS Access) support, but the existing SQL Server support could probably be modified without much effort to provide MS Access support. The latest version of the web2py DAL is a single stand-alone .py file, so it's not a "heavy" package. For what it's worth, I've successfully used the web2py DAL as a stand-alone module with SQL Server after initially trying and giving up on SQLAlchemy. In fairness to SQLAlchemy, I had used the web2py DAL as part of the framework and was already comfortable with it.
0
0
0
0
2011-03-10T16:08:00.000
2
1.2
true
5,262,387
0
0
1
1
I need to use a Python ORM with a MS-Access database (in Windows). My first searches are not really succesfull : SQLAlchemy : no MS Access support in the two last versions. DAL from Web2Py : no Access (??) Storm : no MS Access sqlobject: no MS Access dejavu : seems OK for MS Access but is the project alive ? Any ideas or informations are welcome ...
buildbot from start
5,692,993
0
0
1,638
0
python,buildbot
Some additional information about configuring abd running buildslave after it's creation. After installing buildbot package int.d script /etc/init.d/buildbot is added to enable running buildbot as a service (starting automatically after system restart and so on). For this script to run successfully you need to edit conf file for this script. File name is specified inside the script, typically it is /etc/default/buildbot. Options in this file are pretty clear. One interesting thing you can tune here - the user from which buildbot will be running (default is buildbot). Small example of when it is useful: I had to write a buildbot task, one part of which was managing virtual machines running on builslave machine (starting, stopping, managing snapshots). But rights for doing this had only vbox user (I used Virtual Box VMs). So I simply changed the user field in /etc/buildbot/default to accomplish this. I hope this information will be useful to you.
0
0
0
1
2011-03-10T16:49:00.000
4
0
false
5,262,977
0
0
1
1
should be dumb as everybody seems to installed it without trouble. I spent hours within a fresh squeeze and tried different configurations (easy_install, aptitude and from source 0.81p.tar.gz) the best I got is a page from the localhost:9989 without any slave started. Knowing that I made the 2 accounts : buildmaster and buildslave how to clean and reinstall it to have server and 1 slave for git ? thanks in advance Added : You are right some details are missing: I use buildbot from virtualBox with a Debian squeeze 6.0 in 32bits The both accounts : buildmaster and buildslave are running within this same Virtual environment. I just tried the little example (this seems really interesting) : easy_install buildbot buildbot create-master /tmp/experimental_buildmaster buildbot start /tmp/experimental_buildmaster as root the jinja2 was missing whereas from buildmaster there were no complain (??) commented the Git calls that created errors to try to start the simplest demo buildslave create-slave /tmp/experimental_buildslave 127.0.0.1:9989 slave-name mypasswd in the log something appear allways : "No address associated with hostname" it seems I'm closer with this no ?
How to call django template in order to use it through Jquery?
5,266,823
2
1
830
0
jquery,python,django,forms
Create a Django view which renders just the HTML for the form using your preferred template. Then use $.ajax() with dataType: "html" to get the code for the form for use in your overlay.
0
0
0
0
2011-03-10T21:59:00.000
3
1.2
true
5,266,425
0
0
1
1
I've installed the django-newsletter application, and customized the subscribing form. But, right now, I'd like to print it through a Jquery Overlay, instead of a flatpage containing that form. Problem is I don't know how to include this flatpages elements into every page where the link calling the overlay will be present; and I don't know which approach would be the most performant. Please light my way :) Thank you!
What is a good Django workflow?
5,471,733
0
17
3,676
0
python,django
here is something I do in general, configure basic settings configure root url.py configure settings, url.py for static (media) files create model sync db write views (use simple template, if needed) once you are done with back end implementation think about UI prepare styles, scripts start working on template implementation
0
0
0
0
2011-03-11T03:16:00.000
6
0
false
5,268,588
0
0
1
4
I'm a beginner to Python and Django. When starting a new project what do you do first before diving into the code? For example, one could take the following steps: Configure the settings.py file first Configure models.py to lay out data structure Create template files Define the views/pages Syncdb etc So my question is, what is a good workflow to get through the required steps for a Django application? This also serves as a checklist of things to do. In the definitive guide to Django, the author talks about approaching top down or bottom up. Can anyone expand further on this and perhaps share their process? Thanks.
What is a good Django workflow?
5,461,948
0
17
3,676
0
python,django
I find that my process varies depending on a lot of variables, mainly whether I know something will work or if I'm experimenting and also whether I'm developing on my production server or in a development environment. For example, I often do my development directly on the deployment server (most of my work is for intranet projects so there isn't any security risk, etc). But when I do this I really need to make sure the settings and urls are setup first and that gunicorn and nginx are configured. If I know something should work, or am setting up a generic base set of code, sometimes I'll do all that coding for views and models before I even get enough setup to even run the development server. But when experimenting with new code I find it's good to be able to test every step of the way, so in that case you need your servers running. In general I do settings, models, syncdb, views, urls, templates, collectstatic, graphics/aesthetics In general I leave my base.html very plain until the everything else is working, then I add css/js etc. I guess my point here is that there isn't really a wrong answer for how you do it, and there isn't even only one best practice (as far as I'm concerned). When you do more work, you'll find what you are comfortable with and it'll even vary from project to project. Good luck, hopefully you learn to love django!
0
0
0
0
2011-03-11T03:16:00.000
6
0
false
5,268,588
0
0
1
4
I'm a beginner to Python and Django. When starting a new project what do you do first before diving into the code? For example, one could take the following steps: Configure the settings.py file first Configure models.py to lay out data structure Create template files Define the views/pages Syncdb etc So my question is, what is a good workflow to get through the required steps for a Django application? This also serves as a checklist of things to do. In the definitive guide to Django, the author talks about approaching top down or bottom up. Can anyone expand further on this and perhaps share their process? Thanks.
What is a good Django workflow?
5,273,465
2
17
3,676
0
python,django
I personally can't make a template without writing the views (unless it's a photoshop draft) but in general that's the way I go after I have a plan. What's extremely important for me is that I don't dive head-first into the code, and that I spend time mocking up the model structure based on the "screens" or "pages" that the user will see. Once I have a user experience defined, I make sure the backend is robust enough to handle that experience. If I don't visualize the user experience, details get left out that are certainly accomplishable in the shell but not ideal for the website, default django admin, etc. There are always tradeoffs between agile development and a huge spec: I think there's an important balance. Agile is good: there's no point planning every detail before writing your first line of code, as your needs will change by the time you get to the end. You don't know how your users will really use the site. On the other hand, without a plan, you can end up with a messy foundation that affects all future code. An educated guess is a good start. Don't think or assume too much, but definitely have a clear idea how your users will interact with your site for stage 1.
0
0
0
0
2011-03-11T03:16:00.000
6
0.066568
false
5,268,588
0
0
1
4
I'm a beginner to Python and Django. When starting a new project what do you do first before diving into the code? For example, one could take the following steps: Configure the settings.py file first Configure models.py to lay out data structure Create template files Define the views/pages Syncdb etc So my question is, what is a good workflow to get through the required steps for a Django application? This also serves as a checklist of things to do. In the definitive guide to Django, the author talks about approaching top down or bottom up. Can anyone expand further on this and perhaps share their process? Thanks.
What is a good Django workflow?
5,272,219
8
17
3,676
0
python,django
the required steps for a Django application? There are two required steps. Write the settings. Write the urls.py The rest of the steps are optional. This also serves as a checklist of things to do. Bad policy. You don't need a checklist of Django features. You need a collection of use cases or user stories which you must implement. For some reason, you've omitted the two most important and valuable features of Django. Configure the default admin interface and write unit tests. The default admin interface is very high value. Unit testing is absolutely central. You do it like this. Gather use cases. Prioritize the use cases. Define the actors. The classes of actors becomes groups in the security model. Define enough "applications" to satisfy the first release of use cases. Define the url structure. Cool URL's don't change. Build the first use case: models (including security), admin, urls, tests, forms, views and templates. Note that these are the file names (models.py, admin.py, ...) except for templates. Also note that forms and admin should be defined in separate modules even though this isn't required. Also note that templates will be split between a generic templates directory for top-level stuff and application-specific templates. Build the second use case: models (including security), admin, urls, tests, forms, views and templates. ... n. Package for release. Tweak up the settings. Configure database and mod-wsgi
0
0
0
0
2011-03-11T03:16:00.000
6
1
false
5,268,588
0
0
1
4
I'm a beginner to Python and Django. When starting a new project what do you do first before diving into the code? For example, one could take the following steps: Configure the settings.py file first Configure models.py to lay out data structure Create template files Define the views/pages Syncdb etc So my question is, what is a good workflow to get through the required steps for a Django application? This also serves as a checklist of things to do. In the definitive guide to Django, the author talks about approaching top down or bottom up. Can anyone expand further on this and perhaps share their process? Thanks.
Django or web.py, which is better to build a large website with Python?
5,285,462
7
14
15,107
0
python,django,web.py
Django is actually quite fast. Using caches and multiple DB backends is a doodle - you actually can utilize Django's predefined caching framework for one-line view caching or even template fragment caching. And of course - low-level cache API. And - it's fun! In my experience - deployed under nginx and uWSGI, watched over by Supervisord, with the recently hot Celery task queueing package – Django is blazingly fast, easy to scale and configure and very reliable.
0
0
0
0
2011-03-11T16:03:00.000
4
1
false
5,275,296
0
0
1
2
I'd like to use Python to build a website with more than 100,000 PV each day. Now what I concern is to choose which web framework. I know lots of people use Django, and some people use web.py. Django seems powerful, and I also like the simplicity of web.py. Which framework should I use? (Please introduce the performance and the maintenance complexity, thanks!) Can web.py build complicated applications? Are there other frameworks better than these two?
Django or web.py, which is better to build a large website with Python?
5,275,388
8
14
15,107
0
python,django,web.py
Django makes building complicated sites really simple. Before Django, I was messing around with PHP, and I was doing a really terrible job putting it together. Django leads you in the right direction with some good practices which makes your site really easy to maintain and update. I really like the ORM and how you can easily work with data from the database without having to write a single line of SQL. It makes development less of a slog. I don't have any experience with web.py, and I can't compare the performance of the two. But you can't go wrong with Django at least.
0
0
0
0
2011-03-11T16:03:00.000
4
1.2
true
5,275,296
0
0
1
2
I'd like to use Python to build a website with more than 100,000 PV each day. Now what I concern is to choose which web framework. I know lots of people use Django, and some people use web.py. Django seems powerful, and I also like the simplicity of web.py. Which framework should I use? (Please introduce the performance and the maintenance complexity, thanks!) Can web.py build complicated applications? Are there other frameworks better than these two?
Share Session between Play framework and Django
5,289,431
1
4
1,182
0
java,python,django,single-sign-on,playframework
If you use a standard SSO mechanism, it should be managed by the mechanism itself... The webserver (Django or Play) should redirect the user to the authentication page of the SSO server. The SSO server generates a token and sent it back to the client (in a cookie for example) and redirects the client to the webserver (Django or Play) which can itself validate the authentication with the SSO server using the given token. This token is then used between the client and the web servers until the end of authentication session. So as arjan explained, you should share this token in a cookie for example and both web servers (django and play) should be able to manage it.
0
0
0
0
2011-03-12T13:28:00.000
3
0.066568
false
5,282,764
0
0
1
2
How can I create a single sign on application that will let me move from one section of my site to another. One section of my site uses play framework and the other is on django. My SSO know-how is very limited so be nice to me :)
Share Session between Play framework and Django
5,282,901
1
4
1,182
0
java,python,django,single-sign-on,playframework
A very simple solution would be to use a cookie on your domain that can be read by both Play! and Django. The cookie could hold a temporary token that both apps can check at e.g. a shared DB in case the user is not already logged-in for that app.
0
0
0
0
2011-03-12T13:28:00.000
3
0.066568
false
5,282,764
0
0
1
2
How can I create a single sign on application that will let me move from one section of my site to another. One section of my site uses play framework and the other is on django. My SSO know-how is very limited so be nice to me :)
how to set the admin user with GAE dev app server?
5,283,536
0
3
924
0
python,google-app-engine
When you log in (the blue box where you enter the email) there is a checkbox to apply the administrator flag to your session.
0
1
0
0
2011-03-12T15:44:00.000
3
0
false
5,283,506
0
0
1
1
I want to create an Admin-only page for my GAE application. But I found there's no way to set a Admin user, so I cannot log on the page I created and test the function. I tried the local Admin console, but no luck. How can I do this?
Does anyone have experience using Backbone.js and Pylons/Pyramid ? any sample to look at?
6,868,297
0
7
1,358
0
javascript,python,backbone.js,pylons,pyramid
Could you elaborate on your question a little bit? What are you looking to do? I have worked with backbone and pylons/pyramid, but they interface with each other and are not integrated. Backbone talks to the API which was built using pyramid.
0
0
0
0
2011-03-13T01:07:00.000
3
0
false
5,286,738
0
0
1
1
Does anyone have experience using Backbone.js and Pylons/Pyramid ? any sample to look at ?
Get the GET query in a Python CGI script (Apache, mod_cgi)
5,287,233
1
0
669
0
python,apache,cgi
I think I figured it out. I need to use the environ variable passed to the application function by mod_wsgi. Thanks!
0
0
0
1
2011-03-13T03:02:00.000
1
0.197375
false
5,287,113
0
0
1
1
I am trying to get the query string in a CGI python script because for some reason the .FieldStorage and .getvalue functions are returning "None". The query is being generated correctly. I checked it in Wireshark and it is correctly produced. Any ideas on how I can just get the string itself correctly? I was trying to use os.environ('QUERY_STRING') but that didn't work either. Josh
Role of semi-colon in sql injection and xss attacks
5,294,235
1
0
1,373
0
python,escaping,sql-injection,xss
Semicolons are sometimes an issue when putting values into SQL, but are not an issue when putting values into HTML. cgi.escape() is designed for escaping things that are being put into HTML, and thus only escapes things that are an issue in HTML.
0
0
0
0
2011-03-14T02:39:00.000
2
0.099668
false
5,294,185
0
0
1
2
I've been told to use (python's) cgi.escape() function to avoid sql injections and xss attacks, although I'm sure that django automatically escapes variables. Reading about such attacks, it seems to me that the role of the semi-colon is crucial to both injecting sql and javascript. Yet, cgi.escape doesn't seem to encode the semi-colon, leaving it bare. Whilst other less ominous characters get converted into html entities. Why is this? Wouldn't encoding ; into something like ≻ conveniently prevent these two common and major forms of attack? Interestingly, I've been unable to find a html entity for semi-colons.
Role of semi-colon in sql injection and xss attacks
5,294,230
3
0
1,373
0
python,escaping,sql-injection,xss
cgi.escape is used to convert text that might contain &, <, and > characters, which generally aren't visible in HTML documents, into HTML entities that will be displayed. It has nothing whatsoever to do with preventing SQL injection, although it might help prevent XSS attacks by displaying HTML codes as text rather than inserting actual HTML tags into the displayed page. You should use parameterized queries to avoid SQL injection anyway; escaping input and then building SQL out of it is ugly.
0
0
0
0
2011-03-14T02:39:00.000
2
0.291313
false
5,294,185
0
0
1
2
I've been told to use (python's) cgi.escape() function to avoid sql injections and xss attacks, although I'm sure that django automatically escapes variables. Reading about such attacks, it seems to me that the role of the semi-colon is crucial to both injecting sql and javascript. Yet, cgi.escape doesn't seem to encode the semi-colon, leaving it bare. Whilst other less ominous characters get converted into html entities. Why is this? Wouldn't encoding ; into something like ≻ conveniently prevent these two common and major forms of attack? Interestingly, I've been unable to find a html entity for semi-colons.
Python - Importing a global/site-packages module rather than the file of the same name in the local directory
46,303,381
1
2
3,449
0
python,django,import,python-module
I was able to force python to import the global one with from __future__ import absolute_import at the beginning of the file (this is the default in python 3.0)
0
0
0
1
2011-03-14T13:28:00.000
6
0.033321
false
5,299,199
1
0
1
2
I'm using python and virtualenv/pip. I have a module installed via pip called test_utils (it's django-test-utils). Inside one of my django apps, I want to import that module. However I also have another file test_utils.py in the same directory. If I go import test_utils, then it will import this local file. Is it possible to make python use a non-local / non-relative / global import? I suppose I can just rename my test_utils.py, but I'm curious.
Python - Importing a global/site-packages module rather than the file of the same name in the local directory
5,351,006
0
2
3,449
0
python,django,import,python-module
Since my test_utils was in a django project, I was able to go from ..test_utils import ... to import the global one.
0
0
0
1
2011-03-14T13:28:00.000
6
1.2
true
5,299,199
1
0
1
2
I'm using python and virtualenv/pip. I have a module installed via pip called test_utils (it's django-test-utils). Inside one of my django apps, I want to import that module. However I also have another file test_utils.py in the same directory. If I go import test_utils, then it will import this local file. Is it possible to make python use a non-local / non-relative / global import? I suppose I can just rename my test_utils.py, but I'm curious.
amqp queue_delete catch errors in async way
5,787,202
0
1
307
0
python,rabbitmq,amqp,tornado
Try to avoid the error. If you declare a connection to the queue, and it doesn't exist, it will be created. Then immediately delete it. Or, if you will use that queue again in the next week or so, i.e. it is not single-use, then just leave it around and handle deletion as a system admin activity that cleans up long term idle queues. Or just declare your queues with the auto-delete attribute and they will go away when you disconnect.
0
1
0
0
2011-03-14T18:23:00.000
2
0
false
5,302,695
0
0
1
1
I've just got started using pika(v 0.9.4) with Tornado (through the use of pika.adapters.tornado_connection.TornadoConnection) and I was wondering what's the appropriate way of catching errors when using, say: queue_delete for when the queue you're trying to delete doesn't exist. RabbitMQ raises AMQPError, but I am not sure how this can be handled in an async way. Anyone has any insights on this ?
WSGI with .pyc files
5,306,151
0
1
806
0
python,wsgi
You might need to put all the python files on that machine, then convert them to .pyc or .pyo then delete the .py's I'm suspecting maybe the .pys were generated on a different version of python maybe. Also paste the import errors .. that might help in diagnoses.
0
0
0
0
2011-03-14T22:02:00.000
1
0
false
5,305,119
0
0
1
1
I'm trying to migrate to wsgi but I'm getting ImportError exceptions all the time. I have my modules installed only with .pyc files, I don't have the .py files in the server (I can't change that, sorry). When I add some .py files the ImportError moves away to some other import line. Is there a way to make WSGI use the .pyc files and work without the .py? The script with the application entry point is a .py file but it imports some modules which are .pyc Thanks for your help
Kickstarter clone in Drupal?
5,307,082
1
0
1,290
0
python,ruby-on-rails,ruby,django,drupal
Drupal would likely handle the basic concept of listings rather adeptly, but you'd need to write plenty of glue code to make it match the exact functionality you want. It would, in fact, be easier to write it from scratch than to force a tool to do a different job. Go for a full-fledged web app framework.
0
0
0
0
2011-03-15T02:59:00.000
1
1.2
true
5,307,039
0
0
1
1
I would like to create a Kickstarter type clone in terms of functionality. Can Drupal produce a crude prototype? Or suck it up, hit the books and learn python/django or ruby/rails. I appreciate any and all input.
Is there any python implement of edonkey/emule
5,313,852
1
1
2,485
0
python,p2p
After 20 minutes of googling all combinations of python and edonkey/emule/ed2k and visiting all sites of all clients listed under the "eDonkey network" Wikipedia page I can say with near certainty that the answer is "No."
0
1
0
0
2011-03-15T14:51:00.000
2
0.099668
false
5,313,513
0
0
1
1
I want deploy a project in google appengine to search edonkey/emule, Is there any python implement of edonkey/emule or ed2k protocol library ?
Datetime string with timezone in Python?
5,314,445
0
2
883
0
python,timezone
using strftime is encouraged, but make sure that your localtime is correct. This should be a setting in your app/site assuming you're using django, or you may have to do this manually
0
0
0
0
2011-03-15T15:47:00.000
2
0
false
5,314,267
1
0
1
1
I'm working on Google app engine with Python. I have stored a datetime object in database and fetched it and applied timezone, and I saved it using template. The result is "2011-03-15 16:54:24.398503+09:00", but what I want is: "2011-03-16 01:54:24" (timezone applied string without millisecond - note that day is changed). How can I do that?
Naming variable, best convention
5,315,446
1
14
19,912
0
python,django,naming-conventions
I use lower_case_with_underscore for variables, methods and functions. I think it really improves readability of the code. For classes, I tend to use upper case the first letter: class NewsForm (forms.Form):
0
0
0
0
2011-03-15T15:58:00.000
6
0.033321
false
5,314,421
1
0
1
3
What is the most used convention for naming variables in Python / Django? ex: pub_date or pubdate What about for classes and methods?
Naming variable, best convention
5,314,880
1
14
19,912
0
python,django,naming-conventions
The important thing is being consistent with your naming style. Choose one with your project mates and use it. Don't mix them. I personally use camelCase: Sample class name: MyClass (capital letter at the beginning) Sample method name: myMethod Sample variable name: myVariable Sample constant/enum name: MY_CONST Class name should start with capital letter to make clear what it is in your code. Same about constants/enums. Values that don't change throughout your program should consist of capital letters.
0
0
0
0
2011-03-15T15:58:00.000
6
0.033321
false
5,314,421
1
0
1
3
What is the most used convention for naming variables in Python / Django? ex: pub_date or pubdate What about for classes and methods?
Naming variable, best convention
5,314,547
2
14
19,912
0
python,django,naming-conventions
Code Complete (http://www.cc2e.com/) has some great chapters about function/variable naming, not for Python explicitly, but perhaps still interesting...
0
0
0
0
2011-03-15T15:58:00.000
6
0.066568
false
5,314,421
1
0
1
3
What is the most used convention for naming variables in Python / Django? ex: pub_date or pubdate What about for classes and methods?
python webservice execution problem
5,319,171
0
1
93
0
python,web-services
This is from my experience of using Django with Apache, but have you tried restarting your web server? Sometimes the web server will hold a copy of the code in memory to speed up execution, but restarting your web server will make it reload all *.py files. Providing more information about the technology stack you are using would help us help you :-)
0
1
0
0
2011-03-15T22:59:00.000
2
0
false
5,319,088
0
0
1
2
I have a python web service. My problem is when I changed my web service classes. I can't see the changes on the browser and I see last version of web service on the browser all the time. I used Bottle framework and cgi.
python webservice execution problem
7,275,232
0
1
93
0
python,web-services
You need to restart the Bottle app after each change. Doing this manually during development is a pain in the neck. Fortunately Bottle provides a way to automate via a "reloader" option to the Run method: run(reloader=True) When you edit & save a module file, the reloader will restart the server process for you. Try it and let us know if it solves your problem!
0
1
0
0
2011-03-15T22:59:00.000
2
0
false
5,319,088
0
0
1
2
I have a python web service. My problem is when I changed my web service classes. I can't see the changes on the browser and I see last version of web service on the browser all the time. I used Bottle framework and cgi.
Choosing between Django-Apache and Java-Tomcat for a web application
5,781,961
8
7
16,444
0
java,python,django,tomcat
Here are my experiences: Django-Apache fits in 16MBs of memory, whereas Java-Tomcat requires much more than that. Coding in Python is much faster, that is true. In Java, on the other hand, you have compile-time checks, profilers and debuggers that help you increase the stability of your application. If you are planning to do heavy computations or need complex data structures, Java's compilation technologies will provide the speed you need. It is easier to maintain a large project in a strictly object-oriented environment with advanced refactoring tools, such as Java. Then again, coding in Python is much faster.
0
0
0
0
2011-03-16T02:40:00.000
3
1
false
5,320,457
0
0
1
1
In order to develop a web application that can easily scale, provide production stability, is easily deploy-able, and allows for fast development cycles, what points would you recommend I look at before choosing one or the other framework - using Java and Tomcat, or Django and Apache/Mod_WSGI? Some pros and cons I could see immediately, Tomcat apps are simple to deploy - drop a WAR file and you're done. Django apps seem to need more wrangling (Not sure if creating .egg files and dropping them in would work as well?) Django's ORM seems much nicer than Hibernate - generates models directly compared to Hibernate's manual configuration files Python as a language is faster to develop in, and much more concise than Java can be. (Of course, this is a relatively higher level discussion). I've looked at Disqus's slides about scaling Django and am under no doubts it can be done. But would scaling a Django app be any harder than scaling a Java/Tomcat one? I'm familiar with both Java and Python and the frameworks mentioned above, and it boils down to getting feedback those who've worked with either (or both) on scale. Thanks!
Can I use google app engine to run the python program in the background for chrome extension?
5,322,597
3
0
136
0
python,google-app-engine,google-chrome
What kind of program is to be executed? You could very well send a request from Chrome extension to your appengine server, process and return the response.
0
1
0
0
2011-03-16T04:33:00.000
1
1.2
true
5,321,079
0
0
1
1
I have a python program which has to execute when i click on the chrome extension.Can I use the Google app engine to do the same??
Speed comparisons between Chameleon and Jinja2
5,324,691
19
12
6,518
0
python,performance,jinja2,pyramid,chameleon
Template engines are rarely the cause of performance problems, even if chameleon is slightly faster than Jinja2 I doubt the effort of learning a new template language etc. is worth it. Optimization of database queries and caching will probably result in more performance than you could gain by switching the template engine and take little effort.
0
0
0
1
2011-03-16T06:28:00.000
3
1
false
5,321,789
0
0
1
1
Has anyone here done any benchmarking of Chameleon versus Jinja2, in respect to performance? I'm more used to the Jinja syntax, since I come from Django, but as Pyramid suggests to use Chameleon, I'm thinking if it would be nice to give it a try - despite having an awkward syntax, IMO.
How can I execute a Python script from Javascript?
25,336,537
2
4
17,271
0
javascript,python,google-chrome
Probably a late reply but a possible solution is to make your python script act as a server and let the browser plugin interact with it.
0
0
1
0
2011-03-16T15:21:00.000
3
0.132549
false
5,327,485
1
0
1
2
I have written a module in python which performs some function. I then created a Google Chrome extension which makes use of JSON and javascript. Now when I click on the extension I want it to execute the python program which is stored on my hard disk and display the output on the browser again. Is there a way in which I can do this??
How can I execute a Python script from Javascript?
5,328,172
1
4
17,271
0
javascript,python,google-chrome
forgive me if i'm incorrect on infinite proportions. I believe that JavaScript is executed in a sandboxed/ isolated environment. Therefore you cannot invoke a python interpreter* or any other executable residing on the system. *unless the interpreter itself were written in javascript.
0
0
1
0
2011-03-16T15:21:00.000
3
0.066568
false
5,327,485
1
0
1
2
I have written a module in python which performs some function. I then created a Google Chrome extension which makes use of JSON and javascript. Now when I click on the extension I want it to execute the python program which is stored on my hard disk and display the output on the browser again. Is there a way in which I can do this??
Need Pattern for lookup tables in Google App Engine
5,331,814
2
2
319
1
python,google-app-engine,google-cloud-datastore
If it's really created once and never changes within the lifetime of a deployment, and it's relatively small (a few megs or less), store it with your app as data files. Have the app load the data into memory initially, and cache it there.
0
0
0
0
2011-03-16T16:05:00.000
2
1.2
true
5,328,112
0
0
1
1
I'm using the Python version of Google App Engine and Datastore. What is a good way to load a table that will contain lookup data? By look up data I mean that after the initial load no rows will need to be inserted, deleted, or updated Blowing away all rows and reloading the table is not acceptable if it destroys referential integrity with other rows referring to it. Here is an example of a couple kinds that I am using that I want to load lookup data into class Badge(db.Model): name = db.StringProperty() level = db.IntegerProperty() class Achievement(db.Model): name = db.StringProperty() level = db.IntegerProperty() badge = db.ReferenceProperty(reference_class=Badge) Here is an example of a kind not holding look up data but referring to it class CamperAchievement(db.Model): camper = db.ReferenceProperty(reference_class=Camper) achievement = db.ReferenceProperty(reference_class=Achievement) session = db.ReferenceProperty(reference_class=Session) passed = db.BooleanProperty(default=True) I'm looking to find out two things: What should the code to load the data look like? What should trigger the loading code to execute?
Is there a good way to do version control when developing pylons applications with dependencies?
5,329,651
0
0
96
0
python,controls,version
The only reasonable way to do what you want is to have application B work against formal releases of application A, even if those releases are labled beta or release candidate. IOW, do not treat application A as source code, but as an imported module installed with setup.py or other means. Doing it this way will let you move application B from one well known stage of A to the other, plus you'll be able to report bugs or incompatibilities against specific releases, and go back to previous releases when a new A breaks B.
0
0
0
0
2011-03-16T16:47:00.000
1
1.2
true
5,328,691
0
0
1
1
I'm developing two pylons applications at the same time. Application B uses a lot of the controllers, etc. in application A. Both applications are under active development, but for administrative reasons, they have to be kept separate. Is there a convenient way to do version control so that changes to A are easy to pull into B? It'd be great if there were a way to do this with svn, since it already plays nice with pylons and paster.
What is the best, efficient approach to do a quick forms based web project?
5,328,917
3
0
142
0
python,django,model-view-controller,cakephp,symfony1
Use django to two years, and I had an experience of a project using cakephp and hated it. Django was able to show better in all aspects, much of it takes the python and transparent way how the framework works. I strongly recommend Django.
0
0
0
0
2011-03-16T16:55:00.000
4
1.2
true
5,328,789
0
0
1
2
I am a database guy and its been few years since I did anything with PHP (no MVC experience). I now have to work on a Data Entry project - a form that a user will fill and submit data to the database. I figured this is much more efficient than a spreadsheet approach. All I need is : 1) Authentication 2) Validation of data 3) Submit data to the database. How would you suggest I proceed? I have 2 weeks time for this project. Should I dabble with MVC and do it the industry standard way or go with good 'ol procedural PHP way? Some things I looked at : 1) Symfony 2) CakePHP 3) Django Any ideas, suggestions are really appreciated. Thank you!
What is the best, efficient approach to do a quick forms based web project?
5,329,526
2
0
142
0
python,django,model-view-controller,cakephp,symfony1
If you're just doing some one off data gathering, you could save yourself the work and use Google Spreadsheets ( Create New -> Form). I know you mentioned spreadsheets, but once you've got the data you can export it and do what you want with it. It's a simple solution and might not fit, but if it does it'll cut your time down to a couple of hours instead of a couple of weeks.
0
0
0
0
2011-03-16T16:55:00.000
4
0.099668
false
5,328,789
0
0
1
2
I am a database guy and its been few years since I did anything with PHP (no MVC experience). I now have to work on a Data Entry project - a form that a user will fill and submit data to the database. I figured this is much more efficient than a spreadsheet approach. All I need is : 1) Authentication 2) Validation of data 3) Submit data to the database. How would you suggest I proceed? I have 2 weeks time for this project. Should I dabble with MVC and do it the industry standard way or go with good 'ol procedural PHP way? Some things I looked at : 1) Symfony 2) CakePHP 3) Django Any ideas, suggestions are really appreciated. Thank you!
How to parse unicode strings with minidom?
5,333,621
3
12
16,977
0
python,unicode,minidom
Minidom doesn't directly support parsing Unicode strings; it's something that has historically had poor support and standardisation. Many XML tools recognise only byte streams as something an XML parser can consume. If you have plain files, you should either read them in as byte strings (not Unicode!) and pass that to parseString(), or just use parse() which will read a file directly.
0
0
1
0
2011-03-16T18:02:00.000
5
0.119427
false
5,329,668
0
0
1
1
I'm trying to parse a bunch of xml files with the library xml.dom.minidom, to extract some data and put it in a text file. Most of the XMLs go well, but for some of them I get the following error when calling minidom.parsestring(): UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 5189: ordinal not in range(128) It happens for some other non-ascii characters too. My question is: what are my options here? Am I supposed to somehow strip/replace all those non-English characters before being able to parse the XML files?
Is it possible to send a URL from javascript running on the browser to the python program running on the client machine?
5,330,014
0
0
73
0
javascript,python
You can if you're running a server with Python. Create a simple server with python and return json. The only requirement is that the python server must be started in order to except requests.
0
0
1
0
2011-03-16T18:25:00.000
2
0
false
5,329,942
0
0
1
1
Can I send the url of the page from the javascript to the python program running on the client machine ?? Also can I redirect the output of the python program to the javascript to be displayed on the browser?
Python - Easiest way to scrape text from list of URLs using BeautifulSoup
5,331,407
1
6
6,124
0
python,screen-scraping,beautifulsoup,web-scraping
It is perfectly possible. Easiest way is to iterate through list of URLs, load the content, find the URLs, add them to main list. Stop iteration when enough pages are found. Just some tips: urllib2.urlopen for fetching content BeautifulSoup: findAll('a') for finding URLs
0
0
1
0
2011-03-16T20:20:00.000
3
0.066568
false
5,331,266
0
0
1
1
What's the easiest way to scrape just the text from a handful of webpages (using a list of URLs) using BeautifulSoup? Is it even possible? Best, Georgina
django autoconverting datetime property
5,336,126
0
0
699
0
python,mysql,django
I have a feeling your database schema knows this is a date, right? In that case it's not being stored in the format you describe, but as some representation such as seconds since the era. This means that when you retreave it your code has to do something with it to make it look right. If you don't tell it how to look it'll default to the format you see, but if you use strftime in your python code and a filter in your templates you can make it look however you like, including the original format how you saw it. Of course the easy way out is to store it in the db as text...
0
0
0
0
2011-03-17T06:57:00.000
2
0
false
5,335,845
0
0
1
1
my datetime property is saving in mysql in this format 2011-03-17 00:00:00 but after fetchind the data with filter function it is giving March 17,2011 midnight but i have not say to do any this type of task. My question is how can i insist django to stic to show same value what is saved in MYSQL.
Use Django User-Model or create a own Model?
5,337,521
0
4
2,331
0
python,django,design-decisions,django-users
Currently, you have some requirements, but over time they may change. Django's user system is quite straightforward, and using it allows to adapt more easily to some of the most common use cases. Another aspect to think about, is that there are several applications already available that you can use, and that may require Django's users. Using your own model, may make usage of such modules much more difficult. On the other hand, hacking the Django's user system in order to comply with your current requirements may be tricky. Moreover, migrating a 'Custom-User' to a 'Django-User' is always possible, so you are not really closing that door. Overall, I think it really depends on what you mean with 'user'. If you mean just a registration, and no real interaction with the core Django features, then I think a separate model is enough, especially because you can migrate at any time, with relatively little effort. However, if for your application a 'user' maps to something very similar to the what Django is for, then I would use the Django User-Model.
0
0
0
0
2011-03-17T09:45:00.000
4
0
false
5,337,351
0
0
1
2
I'm currently designing a Django based site. For simplicity lets assume that it is a simple community site where users can log in and write messages to other users. My current choice is wether to use the buildin User-Model or to build something my own. I don't need much from the buildin User: there will be no username (you e-mail address is you username), but you an set an internal Name of your choice which can be used by multiple users (like Facebook). Additionally, I don't need the permission system, since access to others will not be based on groups. So I would end up using only the email, firstname, lastname and password fields from the buildin User and everything else would be placed in a UserProfile. On the other hand, the buildin User system will come handy on the backend of the site, since there is the chance I will need a group based permission system there. All in all, it looks to me, that I rather build my one User Model and use the buildin only for access to the admin backend. Is there anything wrong with my reflections?
Use Django User-Model or create a own Model?
5,593,711
2
4
2,331
0
python,django,design-decisions,django-users
As the author of django-primate I would like to add some comments. Django-primate which easily lets ju modify the built in User model is meant for just that. You might need just something a little extra, then use django-primate. But there are problems, although I do not think modifying the django User model per se is a problem at all. One problem is that the "users" are quite different, the admin user and some other user are often not related. This can cause problems when for example an admin is logged in and then wants to login to the site as a "normal user", they do not expect those accounts to be related and do not expect to be logged in automatically as the admin user. This causes headaches for no reason. It also causes a lot of other headaches to implement the recommended related Profile model, you often need to make sure there is a contrib user for every profile and a profile for every contrib user if you for example want to use the authentication decorators. Forms and administration of "users" make this even more cumbersome. In short: usually something will go wrong in this process at some point, it's a curse. I have mostly abandoned the contrib User model for anything else but for admins. Building another user model is really what you want, but you also want the authenicating part for that user, hence the common use of django contrib User (using it for the wrong reasons). The best solution if you are in a situation like this is to build your own authenication for that custom user model. This is actually quite easy and I cannot recommend this approach enough. I think that the official recommendation is wrong and that there should instead be good tools for authenticating custom user models built into django.
0
0
0
0
2011-03-17T09:45:00.000
4
0.099668
false
5,337,351
0
0
1
2
I'm currently designing a Django based site. For simplicity lets assume that it is a simple community site where users can log in and write messages to other users. My current choice is wether to use the buildin User-Model or to build something my own. I don't need much from the buildin User: there will be no username (you e-mail address is you username), but you an set an internal Name of your choice which can be used by multiple users (like Facebook). Additionally, I don't need the permission system, since access to others will not be based on groups. So I would end up using only the email, firstname, lastname and password fields from the buildin User and everything else would be placed in a UserProfile. On the other hand, the buildin User system will come handy on the backend of the site, since there is the chance I will need a group based permission system there. All in all, it looks to me, that I rather build my one User Model and use the buildin only for access to the admin backend. Is there anything wrong with my reflections?
Scraping a web page with java script in Python
5,352,888
1
0
8,915
0
javascript,python,python-3.x,web-scraping
Use Firebug to see exactly what is being called to get the data to display (a POST or GET url?). I suspect there's an AJAX call that's retrieving the data from the server either as XML or JSON. Just call the same AJAX call, and parse the data yourself. Optionally, you can download Selenium for Firefox, start a Selenium server, download the page via Selenium, and get the DOM contents. MozRepl works as well, but doesn't have as much documentation since it's not widely used.
0
0
1
0
2011-03-17T12:26:00.000
3
0.066568
false
5,338,979
0
0
1
2
i'm working in python 3.2 (newb) on windows machine (though i have ubuntu 10.04 on virtual box if needed, but i prefer to work on the windows machine). Basically i'm able to work with the http module and urlib module to scrape web pages, but only those that don't have java script document.write("<div....") and the like that adds data that is not there while i get the actual page (meaning without real ajax scripts). To process those kind of sites as well i'm pretty sure i need a browser java script processor to work on the page and give me an output with the final result, hopefully as a dict or text. I tried to compile python-spider monkey but i understand that it's not for windows and it's not working with python 3.x :-? Any suggestions ? if anyone did something like that before i'll appreciate the help!
Scraping a web page with java script in Python
5,340,415
0
0
8,915
0
javascript,python,python-3.x,web-scraping
document.write is usually used because you are generating the content on the fly, often by fetching data from a server. What you get are web apps that are more about javascript than HTML. "Scraping" is rather more a question of downloading HTML and processing it, but here there isn't any HTML to download. You are essentially trying to scrape a GUI program. Most of these applications have some sort of API, often returning XML or JSON data, that you can use instead. If it doesn't, your should probably try to remote control a real webbrowser instead.
0
0
1
0
2011-03-17T12:26:00.000
3
0
false
5,338,979
0
0
1
2
i'm working in python 3.2 (newb) on windows machine (though i have ubuntu 10.04 on virtual box if needed, but i prefer to work on the windows machine). Basically i'm able to work with the http module and urlib module to scrape web pages, but only those that don't have java script document.write("<div....") and the like that adds data that is not there while i get the actual page (meaning without real ajax scripts). To process those kind of sites as well i'm pretty sure i need a browser java script processor to work on the page and give me an output with the final result, hopefully as a dict or text. I tried to compile python-spider monkey but i understand that it's not for windows and it's not working with python 3.x :-? Any suggestions ? if anyone did something like that before i'll appreciate the help!
How to add a default time (but not date) to a DateTimeField in DJango?
5,345,806
0
2
194
0
python,django,forms,datetime,default
I tend to do these types of defaults in the models save() method or when the pre_save signal is called.
0
0
0
0
2011-03-17T15:43:00.000
2
0
false
5,341,448
0
0
1
2
I have a DateTimeField on a model. In the forms for that model, I use the SplitDateTimeWidget. I want to enable users to enter just a date, and have my code define a default time (like 2 p.m.) if one is not entered. Is there a simple way to do this? Since this is needed for multiple forms, I would like to have a way that can be applied to all of the forms at once, instead of having to be re-implemented for each one.
How to add a default time (but not date) to a DateTimeField in DJango?
5,341,535
1
2
194
0
python,django,forms,datetime,default
You may be able to do this by subclassing DateTimeField and over-riding the clean() method.
0
0
0
0
2011-03-17T15:43:00.000
2
0.099668
false
5,341,448
0
0
1
2
I have a DateTimeField on a model. In the forms for that model, I use the SplitDateTimeWidget. I want to enable users to enter just a date, and have my code define a default time (like 2 p.m.) if one is not entered. Is there a simple way to do this? Since this is needed for multiple forms, I would like to have a way that can be applied to all of the forms at once, instead of having to be re-implemented for each one.
Python Pyramid & Chameleon templating language escapes html
10,369,248
16
4
3,750
0
python,pyramid,chameleon,template-tal
Chameleon also allows ${structure: markup}.
0
0
0
0
2011-03-17T22:55:00.000
2
1
false
5,346,295
0
0
1
1
I can't make sense of chameleon's tags. I'm a django user, but decided to introduce my CompSci course mates and myself to Pyramid, since I though more lightweight = easier to learn. At the moment the ${} tag is escaping any html tags I'm trying to output through it. In django there was some way to specify that a variable is "safe" and doesn't need to be escaped. How can I do the same thing in Pyramid / Chameleon?
How to call view from view.py in /admin url in django
5,349,122
0
0
231
0
python,django
By using a sql query. This is really basic stuff, like the other questions you have asked. Buy a book or use google, there's plenty of info out there on this stuff.
0
0
0
0
2011-03-18T06:57:00.000
1
0
false
5,348,981
0
0
1
1
How we can provide all objects of class which are stored in mysql data when application start with /admin url.
Storing/Retrieving/Editing project specific data with Django
5,350,427
1
1
96
0
python,django,django-models,django-admin
If you look into caching solutions, they will probably do what you need. The general queryset caching solution I use in johnny-cache, but for what you need, you can probably just load it up from the db and store it in the cache.
0
0
0
0
2011-03-18T09:25:00.000
2
0.099668
false
5,350,089
0
0
1
2
I'm new to Django and I'm working on the public website for a small company. I'm facing an issue that I guess has already been encountered by lots a django noobs, but I can't manage to find a good solution. My problem is that there some informations (contact address, office phone number, company description...) that I use in nearly all of my views and are by nature unique (undertand: a database table with only 1 row). I currently store these informations has a model in my databse, but I find it a bit weird issue an additional database request each time (each view) I need to access them. However, I need my client to be able to edit these informations (by the admin interface). So, please, is there a django idiom to handle such an use case ? Thx in advance.
Storing/Retrieving/Editing project specific data with Django
5,350,914
0
1
96
0
python,django,django-models,django-admin
What you want to do is use select_related('contact_profile','office_data') etc when you query the items in your view, and in the admin, instead of registering all the data separately just use the InlineAdmin class for the Admin site and you will be able to edit all the information as if it was a single entity. Check out the django docs for more information.
0
0
0
0
2011-03-18T09:25:00.000
2
0
false
5,350,089
0
0
1
2
I'm new to Django and I'm working on the public website for a small company. I'm facing an issue that I guess has already been encountered by lots a django noobs, but I can't manage to find a good solution. My problem is that there some informations (contact address, office phone number, company description...) that I use in nearly all of my views and are by nature unique (undertand: a database table with only 1 row). I currently store these informations has a model in my databse, but I find it a bit weird issue an additional database request each time (each view) I need to access them. However, I need my client to be able to edit these informations (by the admin interface). So, please, is there a django idiom to handle such an use case ? Thx in advance.
fix soaplib to support chunked requests
5,389,161
0
0
279
0
python,web-services,soap,soaplib
a bit ugly, but looks like it works: if '' != length: body = input.read(int(length)) elif req_env.get("HTTP_TRANSFER_ENCODING").lower() == 'chunked': chunk_size = int(input.readline(), 16) while chunk_size > 0: chunk_read_size = 0 tmp = input.read(chunk_size) chunk_read_size += len(tmp) body += tmp while chunk_read_size
0
0
1
0
2011-03-18T11:23:00.000
1
1.2
true
5,351,250
0
0
1
1
I have soap webservice built with soaplib, but if client sent chunked request it fails on length = req_env.get("CONTENT_LENGTH") body = input.read(int(length)) because length is '' (empty string), any ideas how to fix soaplib?
Is it safe to access ._meta directly in your django app?
5,354,095
2
5
1,686
0
python,django
I use _meta in several projects where I want to have generic access to information that's otherwise not provided by the api. I think you're probably okay most of the time as Django is pretty stable. It's probably a good idea to be covering your usage of _meta in your unit tests.
0
0
0
0
2011-03-18T15:14:00.000
2
0.197375
false
5,353,984
0
0
1
1
Django uses Meta class for lots of additional object information. However, they store this information in an object '_meta' which by naming convention is private. All over the django admin (and other places) I see stuff like opts = model._meta and then they use the various options like app_label and verbose_name. Can I be confident accessing ._meta and be sure that it will not change in the future, or am I better off creating one 'accessor' mixin or something that accesses the ._meta in one spot, so if it ever does change I only have to update one thing?
How to debug django, it spawns a new process to which I'm not attached?
5,367,975
3
3
708
0
python,django
If you are debugging - it is a good idea to have "--noreload" option for the dev-server. AFAIK PyCharm has a checkbox "No reload" in the run options for the project.
0
0
0
0
2011-03-20T09:34:00.000
1
1.2
true
5,367,695
0
0
1
1
I'm trying to debug django using PyCharm, and notice that it spawns a new process to which PyCharm is not attached. My breakpoints aren't hit in this new process. How do I debug it then? (See autoreload.restart_with_reloader())
How can I know if a email is sent correctly with Django/Python?
5,375,529
9
3
7,759
0
python,django
There is no way to check that a mail has actually been received. This is not because of a failing in Django, but a consequence of the way email works. If you need some form of definite delivery confirmation, you need to use something other than email.
0
0
0
1
2011-03-21T07:18:00.000
4
1
false
5,374,818
0
0
1
1
I need know that if a email is sent correctly for to do several operations but the function always return True. Any idea? Thanks you.
Flask/Bottle project organization
5,381,900
2
11
7,590
0
python,flask
I can't see how there could be any way of stopping this from working. Flask and Bottle, like Django, are just Python underneath, and Python allows you to break up files into modules. As long as you importing the relevant functions into the main script, they will just work exactly as if they were defined there.
0
0
0
0
2011-03-21T17:17:00.000
5
0.07983
false
5,381,208
0
0
1
2
I've been looking into microframeworks for Python, and have come across two interesting options, Flask and Bottle. each have some similar features. One thing I noticed is that all the example sites show all the application code located inside a single Python file. Obviously, for even moderately sized sites, this would become difficult to manage quite quickly. Do either (or both) of these frameworks support being broken up among different files, and if so how would that be accomplished? I'm familiar with Django, and like how its a little more structured, but i would rather use something more lightweight, but still powerful.
Flask/Bottle project organization
26,026,153
0
11
7,590
0
python,flask
It really depends what you are trying to achieve, for micro service/applications/websites bottle is very straight forward and light weight. If you plan your application to grow by the time then Flask might be good option for you coz it has lot of extensions. We have about 40 to 50 micro services written in bottle and never faced any issues.
0
0
0
0
2011-03-21T17:17:00.000
5
0
false
5,381,208
0
0
1
2
I've been looking into microframeworks for Python, and have come across two interesting options, Flask and Bottle. each have some similar features. One thing I noticed is that all the example sites show all the application code located inside a single Python file. Obviously, for even moderately sized sites, this would become difficult to manage quite quickly. Do either (or both) of these frameworks support being broken up among different files, and if so how would that be accomplished? I'm familiar with Django, and like how its a little more structured, but i would rather use something more lightweight, but still powerful.
Is there a way to programmatically stop web.py?
5,402,971
5
3
1,314
0
python,web.py
I solved the question I originally raised by looking into web.py source code, and exposed the WSGIServer in web/httpserver.py to web/application.py, so that i can call WSGIServer.stop() in application.stop(), which is added by myself. It's a quick hack and not that neat, but it removed the blocker quickly.
0
0
0
0
2011-03-22T09:28:00.000
1
0.761594
false
5,389,111
0
0
1
1
I'm trying to run web.application in a Windows Service and I cannot find a way to programmatically stop it after application.run(). I tried sys.exit and it didn't work well with Windows Service.
Security measures for controlling access to web-services/API
5,395,647
2
2
334
0
python,objective-c,security,api,rsa
The easiest solution would be IP whitelisting if you expect the API consumer to be requesting from the same IP all the time. If you want to support the ability to 'authenticate' from anywhere, then you're on the right track; it would be a lot easier to share an encryption method and then requesting users send a request with an encrypted api consumer handle / password / request date. Your server decodes the encrypted value, checks the handle / password against a whitelist you control, and then verifies that the request date is within some timeframe that is valid; aka, if the request date wasnt within 1 minute ago, deny the request (that way, someone intercepts the encrypted value, it's only valid for 1 minute). The encrypted value keeps changing because the request time is changing, so the key for authentication keeps changing. That's my take anyways.
0
0
0
1
2011-03-22T17:44:00.000
3
0.132549
false
5,395,588
0
0
1
1
I have a webapp with some functionality that I'd like to be made accessible via an API or webservice. My problem is that I want to control where my API can be accessed from, that is, I only want the apps that I create or approve to have access to my API. The API would be a web-based REST service. My users do not login, so there is no authentication of the user. The most likely use case, and the one to work with now, is that the app will be an iOS app. The API will be coded with django/python. Given that it is not possible to view the source-code of an iOS app (I think, correct me if I'm wrong), my initial thinking is that I could just have some secret key that is passed in as a parameter to the API. However, anyone listening in on the connection would be able to see this key and just use it from anywhere else in the world. My next though is that I could add a prior step. Before the app gets to use API it must pass a challenge. On first request, my API will create a random phrase and encrypt it with some secret key (RSA?). The original, unencrypted phrase will be sent to the app, which must also encrypt the phrase with the same secret key and send back the encrypted text with their request. If the encryptions match up, the app gets access but if not they don't. My question is: Does this sound like a good methodology and, if so, are there any existing libraries out there that can do these types of things? I'll be working in python server-side and objective-c client side for now.
Python/Google app engine data storage performance
5,400,785
1
1
496
0
python,performance,json,google-app-engine,google-cloud-datastore
For superior app performance, as Chris and others pointed out, python dict is the best. But if you are ok with the minimal performance hit caused by datastore queries, I think that is the way to go purely from a design and maintenance perspective. Simplicity takes precedence over performance if you are not approaching the quota limits. I assume yours is a simple app as of today. But it can gradually grow in complexity. As you add more features, having a hard-coded data somewhere will come in the way of design flexibility even in the short term. And you might end up rewriting those areas in future.
0
1
0
0
2011-03-22T18:03:00.000
3
0.066568
false
5,395,782
0
0
1
2
In a python/google app engine app, I've got a choice between storing some static data (couple KB in size) in a local json/xml file or putting it into the datastore and querying it from there. The data is created by me, so there's no issues with badly formed data. In specific terms such as saving quota, less resource usage and app speed, which is the better method for this case? I'd guess using simplyjson to read from a json file would be better since this method doesn't require a datastore query, whilst still being reasonably quick. Taking this further, the app doesn't require a large data store (currently ~400KB), so would it be worthwhile moving all the data to a json file to get around the quota restrictions?
Python/Google app engine data storage performance
5,395,833
5
1
496
0
python,performance,json,google-app-engine,google-cloud-datastore
If your data is small, static and infrequently changed, you'll get the best performance by just writing your data as a dict in it's own module and just import it where you need it. This would take advantage of the fact that Python will cache your modules on import.
0
1
0
0
2011-03-22T18:03:00.000
3
1.2
true
5,395,782
0
0
1
2
In a python/google app engine app, I've got a choice between storing some static data (couple KB in size) in a local json/xml file or putting it into the datastore and querying it from there. The data is created by me, so there's no issues with badly formed data. In specific terms such as saving quota, less resource usage and app speed, which is the better method for this case? I'd guess using simplyjson to read from a json file would be better since this method doesn't require a datastore query, whilst still being reasonably quick. Taking this further, the app doesn't require a large data store (currently ~400KB), so would it be worthwhile moving all the data to a json file to get around the quota restrictions?
How to use Mercurial to deploy Django applications?
5,397,870
0
0
627
1
python,django,mercurial,apache2,mod-python
I thought about this, good idea for development. Use mercurial in common way. And of course you need deploy mercurial server before. If you update your django project, it will be compiled on the fly. My workflow: Set up mercurial server or use bitbucket Init repo locally Push repo to central repo On server pull repo in some target dir Edit smth locally and push to central repo Pull repo on server and everything is fine
0
0
0
0
2011-03-22T20:37:00.000
1
1.2
true
5,397,528
0
0
1
1
I'm creating a server with Apache2 + mod_python + Django for development and would like to know how to use Mercurial to manage application development. My idea is to make the folder where the Mercurial stores the project be the same folder to deploy Django. Thank you for your attention!
Django directory plugin
5,423,598
1
0
930
0
python,django,plugins,web,directory
You will not find something like that, because using django means you can do that with just a few lines of code by yourself. Django is not a CMS, but a framework, which means you are one level deeper. A lot of the things where you would use a plugin in a CMS are common tasks for django programmers, so there really is no need for a plugin to display such stuff as you mentioned.
0
0
0
0
2011-03-23T01:22:00.000
1
0.197375
false
5,399,853
0
0
1
1
Is there any Django plugin or reusable app available that we can use to add online directory feature to our Django based website?
Overcoming 1mb file restriction in GAE Datastore
5,413,209
0
2
349
0
python,google-app-engine,google-cloud-datastore
You could work around this by splitting the blob into multiple pieces and storing them in separate entities. What you should do, though, is use the Blobstore as @Thilo suggests.
0
1
0
0
2011-03-23T05:03:00.000
2
0
false
5,401,070
0
0
1
1
As if for now, we are using datastore blob to store profile images of our site. And there is restriction in Datastore for storing more than 1mb file as a blob in datastore. Is there any work around for this.
Where to put generic Database Tables on Django?
5,403,151
0
0
208
0
python,django
Django doesn't really offer you place where things that are commonly used all over the project can live. I think the most common approach to solve this is to create a 'project'-app, which holds such project-relevant things like models, templatetags or widgets for example...
0
0
0
0
2011-03-23T09:02:00.000
2
1.2
true
5,402,847
0
0
1
2
I'm trying to start with Django. I'm developing an App. This App is called "Directory" and will store info about websites. I must to create a database table called "Genders", but this is a generic database table and could be used in other App. My question... how to deal with this kind of situation in Django? And in wich model I shuld put this database table? Best Regards,
Where to put generic Database Tables on Django?
5,403,490
1
0
208
0
python,django
In django, you don't (generally) create database tables. You create models, and let the django ORM create tables for you. To prevent having two tables in your database called gender, django will prefix the model name with the name of the app. Thus, if your app was called foo, your model class was Gender, you would have foo_gender. But, you don't need to know this. As for the specific case of Gender: I wouldn't bother storing this in the database in a special table. They don't make new genders anymore. If you need to store a field containing a gender, then just use django.db.models.CharField, with a choices=(('M',"Male"),('F',"Female")). Or if you do it lots, then create a new field. If it is something you do need to be able to add dynamically to the database, then either abstract it out into a reusable app, or as someone else mentioned, create a sundry/project/utils app.
0
0
0
0
2011-03-23T09:02:00.000
2
0.099668
false
5,402,847
0
0
1
2
I'm trying to start with Django. I'm developing an App. This App is called "Directory" and will store info about websites. I must to create a database table called "Genders", but this is a generic database table and could be used in other App. My question... how to deal with this kind of situation in Django? And in wich model I shuld put this database table? Best Regards,
Asynchronous URLfetch when we don't care about the result? [Python]
5,412,695
7
6
3,248
0
python,google-app-engine,asynchronous,urlfetch
A task queue task is your best option here. The message you're seeing in the log indicates that the request is waiting for your URLFetch to complete before returning, so this doesn't help. You say a task is 'overkill', but really, they're very lightweight, and definitely the best way to do this. Deferred will even allow you to just defer the fetch call directly, rather than having to write a function to call.
0
1
0
0
2011-03-23T20:34:00.000
2
1.2
true
5,411,291
0
0
1
1
In some code I'm writing for GAE I need to periodically perform a GET on a URL on another system, in essence 'pinging' it and I'm not terribly concerned if the request fails, times out or succeeds. As I basically want to 'fire and forget' and not slow down my own code by waiting for the request, I'm using an asynchronous urlfetch, and not calling get_result(). In my log I get a warning: Found 1 RPC request(s) without matching response (presumably due to timeouts or other errors) Am I missing an obviously better way to do this? A Task Queue or Deferred Task seems (to me) like overkill in this instance. Any input would appreciated.
Optimizing join query performance in google app engine
5,415,555
0
1
372
1
python,google-app-engine
The standard solution to this problem is denormalization. Try storing a copy of price and profit in Entity1 and then you can answer your question with a single, simple query on Entity1.
0
1
0
0
2011-03-24T05:58:00.000
2
0
false
5,415,342
0
0
1
1
Scenario Entity1 (id,itmname) Entity2 (id,itmname,price) Entity3 (id,itmname,profit) profit and price are both IntegerProperty I want to count all the item with price more then 500 and profit more then 10. I know its join operation and is not supported by google. I tried my best to find out the way other then executing queries separately and performing count but I didn't get anything. The reason for not executing queries separately is query execution time. In each query I am getting more then 50000 records as result so it takes nearly 20 seconds in fetching records from first query.
how to open url in new tab from django?
29,631,137
7
13
28,137
0
python,django
Most the time, loading the page in a new tab can be a real pain in the ar** for the user. Nevertheless it can still be necessary sometimes. If you really need to render your POST results in a new tab, use the target="_blank" as an attribute of your <form>.
0
0
0
0
2011-03-24T06:37:00.000
3
1
false
5,415,600
0
0
1
1
i have to open the result page using render_to_response on a new tab
Feedback on different backends for GWT
5,421,810
1
4
1,559
1
java,python,gwt,architecture,web-frameworks
We had the same dilemma in the past. I was involved in designing and building a system that had a GWT frontend and Java (Spring, Hibernate) backend. Some of our other (related) systems were built in Python and Ruby, so the expertise was there, and a question just like yours came up. We decided on Java mainly so we could use a single language for the entire stack. Since the same people worked on both the client and server side, working in a single language reduced the need to context-switch when moving from client to server code (e.g. when debugging). In hindsight I feel that we were proven right and that that was a good decision. We used RPC, which as you mentioned yourself definitely eased the implementation of c/s communication. I can't say that I liked it much though. REST + JSON feels more right, and at the very least creates better decoupling between server and client. I guess you'll have to decide based on whether you expect you might need to re-implement either client or server independently in the future. If that's unlikely, I'd go with the KISS principle and thus with RPC which keeps it simple in this specific case. Regarding the disadvantages for Java that you mention, I tend to agree on the principle (I prefer RoR myself), but not on the details. The multitier and configuration architecture isn't really a problem IMO - Spring and Hibernate are simple enough nowadays. IMO the advantage of using Java across client and server in this project trumps the relative ease of using python, plus you'll be introducing complexities in the interface (i.e. by doing REST vs the native RPC). I can't comment on Numpy/Scipy and any Java alternatives. I've no experience there.
0
1
0
0
2011-03-24T09:56:00.000
1
1.2
true
5,417,372
0
0
1
1
I have to re-design an existing application which uses Pylons (Python) on the backend and GWT on the frontend. In the course of this re-design I can also change the backend system. I tried to read up on the advantages and disadvantages of various backend systems (Java, Python, etc) but I would be thankful for some feedback from the community. Existing application: The existing application was developed with GWT 1.5 (runs now on 2.1) and is a multi-host-page setup. The Pylons MVC framework defines a set of controllers/host pages in which GWT widgets are embedded ("classical website"). Data is stored in a MySQL database and accessed by the backend with SQLAlchemy/Elixir. Server/client communication is done with RequestBuilder (JSON). The application is not a typical business like application with complex CRUD functionality (transactions, locking, etc) or sophisticated permission system (tough a simple ACL is required). The application is used for visualization (charts, tables) of scientific data. The client interface is primarily used to display data in read-only mode. There might be some CRUD functionality but it's not the main aspect of the app. Only a subset of the scientific data is going to be transfered to the client interface but this subset is generated out of large datasets. The existing backend uses numpy/scipy to read data from db/files, create matrices and filter them. The numbers of users accessing or using the app is relatively small, but the burden on the backend for each user/request is pretty high because it has to read and filter large datasets. Requirements for the new system: I want to move away from the multi-host-page setup to the MVP architecture (one single host page). So the backend only serves one host page and acts as data source for AJAX calls. Data will be still stored in a relational database (PostgreSQL instead of MySQL). There will be a simple ACL (defines who can see what kind of data) and maybe some CRUD functionality (but it's not a priority). The size of the datasets is going to increase, so the burden on the backend is probably going to be higher. There won't be many concurrent requests but the few ones have to be handled by the backend quickly. Hardware (RAM and CPU) for the backend server is not an issue. Possible backend solutions: Python (SQLAlchemy, Pylons or Django): Advantages: Rapid prototyping. Re-Use of parts of the existing application Numpy/Scipy for handling large datasets. Disadvantages: Weakly typed language -> debugging can be painful Server/Client communication (JSON parsing or using 3rd party libraries). Python GIL -> scaling with concurrent requests ? Server language (python) <> client language (java) Java (Hibernate/JPA, Spring, etc) Advantages: One language for both client and server (Java) "Easier" to debug. Server/Client communication (RequestFactory, RPC) easer to implement. Performance, multi-threading, etc Object graph can be transfered (RequestFactory). CRUD "easy" to implement Multitear architecture (features) Disadvantages: Multitear architecture (complexity,requires a lot of configuration) Handling of arrays/matrices (not sure if there is a pendant to numpy/scipy in java). Not all features of the Java web application layers/frameworks used (overkill?). I didn't mention any other backend systems (RoR, etc) because I think these two systems are the most viable ones for my use case. To be honest I am not new to Java but relatively new to Java web application frameworks. I know my way around Pylons though in the new setup not much of the Pylons features (MVC, templates) will be used because it probably only serves as AJAX backend. If I go with a Java backend I have to decide whether to do a RESTful service (and clearly separate client from server) or use RequestFactory (tighter coupling). There is no specific requirement for "RESTfulness". In case of a Python backend I would probably go with a RESTful backend (as I have to take care of client/server communication anyways). Although mainly scientific data is going to be displayed (not part of any Domain Object Graph) also related metadata is going to be displayed on the client (this would favor RequestFactory). In case of python I can re-use code which was used for loading and filtering of the scientific data. In case of Java I would have to re-implement this part. Both backend-systems have its advantages and disadvantages. I would be thankful for any further feedback. Maybe somebody has experience with both backend and/or with that use case. thanks in advance