Title
stringlengths
11
150
A_Id
int64
518
72.5M
Users Score
int64
-42
283
Q_Score
int64
0
1.39k
ViewCount
int64
17
1.71M
Database and SQL
int64
0
1
Tags
stringlengths
6
105
Answer
stringlengths
14
4.78k
GUI and Desktop Applications
int64
0
1
System Administration and DevOps
int64
0
1
Networking and APIs
int64
0
1
Other
int64
0
1
CreationDate
stringlengths
23
23
AnswerCount
int64
1
55
Score
float64
-1
1.2
is_accepted
bool
2 classes
Q_Id
int64
469
42.4M
Python Basics and Environment
int64
0
1
Data Science and Machine Learning
int64
0
1
Web Development
int64
1
1
Available Count
int64
1
15
Question
stringlengths
17
21k
How to customize the look and feel of django admin
4,287,426
0
1
1,478
0
python,django
1) ModelAdmin, you can customize the Forms for CRUD operations with this. 2) Overload your Admin Templates 3) Admin Tools and Grappelli provide great options to extend and customize the Django Admin sorry, i can't post links but google can help easily with 1) and 2) searchs.
0
0
0
0
2010-11-26T12:46:00.000
4
0
false
4,285,388
0
0
1
1
How to customize the look and feel of django admin?
Add Derived Field to Django Admin Change Form
15,231,605
4
3
2,379
0
python,django,django-admin,modeladmin
If you write a method and add it to ModelAdmin.readonly_fields, it will appear on the change view.
0
0
0
0
2010-11-26T23:09:00.000
2
0.379949
false
4,289,113
0
0
1
1
I'd like to add a derived field to a default ModelAdmin.fieldsets like I would by specifying a method and adding it to the ModelAdmin.list_display property, but there doesn't seem to be an easy way to do that (if there is ANY way to do that). The default Django Admin list view seems to have a lot more options than the change form view does. Let's say I have two fields for a location: latitude and longitude, and instead of displaying them on a change form I want to display a Google Maps Static Map image instead - I already have a method that will return the src url for the image - I just need a way to add that image to the model change form instead of showing those two fields.
Python syntax reasoning (why not fall back for . the way django template syntax does?)
4,296,635
1
1
225
0
python,types,syntax,django-templates
In addition to the points already posted, consider this. Python uses special member variables and functions to provide metadata about the object. Both the interpreter and programmers make heavy use of these. For example, both dicts and lists have a __len__ member function. Now, if a dict's data were accessed by using the . operator, a potential ambiguity arises if the dict has a key called __len__. You could special-case these, but many objects have a __dict__ attribute which is a mapping of member names and values. If that object happened to be a container, which also defined a __len__ attribute, you would end up with an utter mess. Problems like this would end up turning Python into a mishmash of special cases that the programmer would have to constantly be aware of. This would detract from the reason why many people use Python in the first place, i.e., its elegant simplicity. Now, consider that new users often shadow built-ins (if the code in SO questions is any indication) and having something like this starts to look like a really bad idea, since it would exacerbate the problem many-fold.
0
0
0
0
2010-11-28T04:32:00.000
5
0.039979
false
4,295,384
1
0
1
5
My karate instructor is fond of saying, "a block is a lock is a throw is a blow." What he means is this: When we come to a technique in a form, although it might seem to look like a block, a little creativity and examination shows that it can also be seen as some kind of joint lock, or some kind of throw, or some kind of blow. So it is with the way the django template syntax uses the dot (".") character. It perceives it first as a dictionary lookup, but it will also treat it as a class attribute, a method, or list index - in that order. The assumption seems to be that, one way or another, we are looking for a piece of knowledge. Whatever means may be employed to store that knowledge, we'll treat it in such a way as to get it into the template. Why doesn't python do the same? If there's a case where I might have assigned a dictionary term spam['eggs'], but know for sure that spam has an attribute eggs, why not let me just write spam.eggs and sort it out the way django templates do? Otherwise, I have to except an AttributeError and add three additional lines of code. I'm particularly interested in the philosophy that drives this setup. Is it regarded as part of strong typing?
Python syntax reasoning (why not fall back for . the way django template syntax does?)
4,296,043
1
1
225
0
python,types,syntax,django-templates
The different methods of accessing attributes do different things. If you have a function foo the two lines of code a = foo, a = foo() do two very different things. Without distinct syntax to reference and call functions there would be no way for python to know whether the variable should be a reference to foo or the result of running foo. The () syntax removes the ambiguity. Lists and dictionaries are two very different data structures. One of the things that determine which one is appropriate in a given situation is how its contents can be accessed (key Vs index). Having separate syntax for both of them reinforces the notion that these two things are not the same and neither one is always appropriate. It makes sense for these distinctions to be ignored in a template language, the person writing the html doesn't care, the template language doesn't have function pointers so it knows you don't want one. Programmers who write the python that drive the template however do care about these distinctions.
0
0
0
0
2010-11-28T04:32:00.000
5
0.039979
false
4,295,384
1
0
1
5
My karate instructor is fond of saying, "a block is a lock is a throw is a blow." What he means is this: When we come to a technique in a form, although it might seem to look like a block, a little creativity and examination shows that it can also be seen as some kind of joint lock, or some kind of throw, or some kind of blow. So it is with the way the django template syntax uses the dot (".") character. It perceives it first as a dictionary lookup, but it will also treat it as a class attribute, a method, or list index - in that order. The assumption seems to be that, one way or another, we are looking for a piece of knowledge. Whatever means may be employed to store that knowledge, we'll treat it in such a way as to get it into the template. Why doesn't python do the same? If there's a case where I might have assigned a dictionary term spam['eggs'], but know for sure that spam has an attribute eggs, why not let me just write spam.eggs and sort it out the way django templates do? Otherwise, I have to except an AttributeError and add three additional lines of code. I'm particularly interested in the philosophy that drives this setup. Is it regarded as part of strong typing?
Python syntax reasoning (why not fall back for . the way django template syntax does?)
4,297,020
1
1
225
0
python,types,syntax,django-templates
In addition to the responses above, it's not practical to merge dictionary lookup and object lookup in general because of the restrictions on object members. What if your key has whitespace? What if it's an int, or a frozenset, etc.? Dot notation can't account for these discrepancies, so while it's an acceptable tradeoff for a templating language, it's unacceptable for a general-purpose programming language like Python.
0
0
0
0
2010-11-28T04:32:00.000
5
0.039979
false
4,295,384
1
0
1
5
My karate instructor is fond of saying, "a block is a lock is a throw is a blow." What he means is this: When we come to a technique in a form, although it might seem to look like a block, a little creativity and examination shows that it can also be seen as some kind of joint lock, or some kind of throw, or some kind of blow. So it is with the way the django template syntax uses the dot (".") character. It perceives it first as a dictionary lookup, but it will also treat it as a class attribute, a method, or list index - in that order. The assumption seems to be that, one way or another, we are looking for a piece of knowledge. Whatever means may be employed to store that knowledge, we'll treat it in such a way as to get it into the template. Why doesn't python do the same? If there's a case where I might have assigned a dictionary term spam['eggs'], but know for sure that spam has an attribute eggs, why not let me just write spam.eggs and sort it out the way django templates do? Otherwise, I have to except an AttributeError and add three additional lines of code. I'm particularly interested in the philosophy that drives this setup. Is it regarded as part of strong typing?
Python syntax reasoning (why not fall back for . the way django template syntax does?)
4,295,442
6
1
225
0
python,types,syntax,django-templates
JUST MY correct OPINION's opinion is indeed correct. I can't say why Guido did it this way but I can say why I'm glad that he did. I can look at code and know right away if some expression is accessing the 'b' key in a dict-like object a, the 'b' attribute on the object a, a method being called on or the b index into the sequence a. Python doesn't have to try all of the above options every time there is an attribute lookup. Imagine if every time one indexed into a list, Python had to try three other options first. List intensive programs would drag. Python is slow enough! It means that when I'm writing code, I have to know what I'm doing. I can't just toss objects around and hope that I'll get the information somewhere somehow. I have to know that I want to lookup a key, access an attribute, index a list or call a method. I like it that way because it helps me think clearly about the code that I'm writing. I know what the identifiers are referencing and what attributes and methods I'm expecting the object of those references to support. Of course Guido Van Rossum might have just flipped a coin for all I know (He probably didn't) so you would have to ask him yourself if you really want to know. As for your comment about having to surround these things with try blocks, it probably means that you're not writing very robust code. Generally, you want your code to expect to get some piece of information from a dict-like object, list-like object or a regular object. You should know which way it's going to do it and let anything else raise an exception. The exception to this is that it's OK to conflate attribute access and method calls using the property decorator and more general descriptors. This is only good if the method doesn't take arguments.
0
0
0
0
2010-11-28T04:32:00.000
5
1.2
true
4,295,384
1
0
1
5
My karate instructor is fond of saying, "a block is a lock is a throw is a blow." What he means is this: When we come to a technique in a form, although it might seem to look like a block, a little creativity and examination shows that it can also be seen as some kind of joint lock, or some kind of throw, or some kind of blow. So it is with the way the django template syntax uses the dot (".") character. It perceives it first as a dictionary lookup, but it will also treat it as a class attribute, a method, or list index - in that order. The assumption seems to be that, one way or another, we are looking for a piece of knowledge. Whatever means may be employed to store that knowledge, we'll treat it in such a way as to get it into the template. Why doesn't python do the same? If there's a case where I might have assigned a dictionary term spam['eggs'], but know for sure that spam has an attribute eggs, why not let me just write spam.eggs and sort it out the way django templates do? Otherwise, I have to except an AttributeError and add three additional lines of code. I'm particularly interested in the philosophy that drives this setup. Is it regarded as part of strong typing?
Python syntax reasoning (why not fall back for . the way django template syntax does?)
4,295,436
7
1
225
0
python,types,syntax,django-templates
django templates and python are two, unrelated languages. They also have different target audiences. In django templates, the target audience is designers, who proabably don't want to learn 4 different ways of doing roughly the same thing ( a dictionary lookup ). Thus there is a single syntax in django templates that performs the lookup in several possible ways. python has quite a different audience. developers actually make use of the many different ways of doing similar things, and overload each with distinct meaning. When one fails it should fail, because that is what the developer means for it to do.
0
0
0
0
2010-11-28T04:32:00.000
5
1
false
4,295,384
1
0
1
5
My karate instructor is fond of saying, "a block is a lock is a throw is a blow." What he means is this: When we come to a technique in a form, although it might seem to look like a block, a little creativity and examination shows that it can also be seen as some kind of joint lock, or some kind of throw, or some kind of blow. So it is with the way the django template syntax uses the dot (".") character. It perceives it first as a dictionary lookup, but it will also treat it as a class attribute, a method, or list index - in that order. The assumption seems to be that, one way or another, we are looking for a piece of knowledge. Whatever means may be employed to store that knowledge, we'll treat it in such a way as to get it into the template. Why doesn't python do the same? If there's a case where I might have assigned a dictionary term spam['eggs'], but know for sure that spam has an attribute eggs, why not let me just write spam.eggs and sort it out the way django templates do? Otherwise, I have to except an AttributeError and add three additional lines of code. I'm particularly interested in the philosophy that drives this setup. Is it regarded as part of strong typing?
Controlling rate of downloads on a per request and/or per resource basis (and providing a first-come-first-serve waiting system)
4,297,198
0
1
62
0
c#,php,python,apache,nginx
Twisted network engine is about the best answer for you. What you can have is you can have the downloader serving a maximum of 100 x people then when the queue is full you will direct people to a holding loop, in the holding loop they will wait x seconds, check if queue is full, check not expired, see who else is waiting, if this ticket was here first, jump to top of download queue. As a TCP/IP connection comes in on twisted the level of control on your clients is so insane that you can do some might and powerful things in weird and wonderful ways, now imagine building this into a scalable and interactive twisted http server where you keep the level of control but you can actually serve resources. The simplest way to get away with it is probably a pool of tickets, when a download is complete the downloader returns the ticket to the pool for someone else to take, if there are no tickets wait your turn.
0
0
1
0
2010-11-28T07:35:00.000
1
0
false
4,295,823
0
0
1
1
My goal: I want to host a folder of photos, but if at anytime 100 files are being downloaded, I want to redirect a new downloader/request to a 'waiting page' and give them a place in line and an approximate countdown clock until its their turn to download their requested content. Then either redirect them directly to the content, or (ideally) give them a button (token,expiring serial number) they can click that will take them to the content when they are ready. I've seen sites do something similar to this, such as rapidshare, but I have not seen an open-source example of this type of setup. I would think it would be combining several technologies and modifying request headers? Any help/ideas would be greatly appreciated!
GAE - Secure data Connector and Taskqueue/Cron
4,300,033
2
1
236
0
python,google-app-engine
'Offline' requests such as Task Queue tasks and Cron jobs have no 'user' as far as systems like SDC are concerned. If your SDC connection requires a logged in user, you will not be able to access it from a cron/task queue job.
0
1
0
0
2010-11-28T12:56:00.000
1
1.2
true
4,296,830
0
0
1
1
Is it possible to use the Secure Data Connector (SDC) to access internal resources in Tasks/Cron Jobs on the Google AppEngine? The documentation speaks about the currently logged in user but does not further elaborate this scenario.
Full text search engine for Python
4,297,732
4
7
10,456
0
python,sqlite,full-text-search,sqlalchemy,pylons
"Sphinx does not have a Python API" is not true. Download the release and look at sphinx/api/sphinxapi.py I use it myself and I'm pretty happy with it. The documentation is for PHP only but the Python API uses the exact same names for all functions.
0
0
0
0
2010-11-28T16:12:00.000
6
0.132549
false
4,297,672
0
0
1
3
I'm searching for a Python full text search engine. I took a look at PyLucense, but I think that using a Java-based library in a Python project is not good. As I understand, Sphinx does not have a Python API. Any ideas ?
Full text search engine for Python
4,297,754
2
7
10,456
0
python,sqlite,full-text-search,sqlalchemy,pylons
I will recommend whoosh. You can easy install it ie easy_install Whoosh It has a neat API too
0
0
0
0
2010-11-28T16:12:00.000
6
0.066568
false
4,297,672
0
0
1
3
I'm searching for a Python full text search engine. I took a look at PyLucense, but I think that using a Java-based library in a Python project is not good. As I understand, Sphinx does not have a Python API. Any ideas ?
Full text search engine for Python
4,297,894
2
7
10,456
0
python,sqlite,full-text-search,sqlalchemy,pylons
Particularly for full text search, Solr is an excellent choice. You will have a hard time finding a more widely used and more open choice. We use Solr/Lucene at my company with a PHP web application being the client and the HTTP/REST API to let you query the index. It has as much functionality as a native PHP client would have and much more flexibility out of the box. You can perform any query/filter you choose all using the REST API. But, on top of all of that, you get an extremely performant and widely used search system with built-in replication that is constantly being improved. Strongly recommend Solr 1.4.x as your starting point.
0
0
0
0
2010-11-28T16:12:00.000
6
0.066568
false
4,297,672
0
0
1
3
I'm searching for a Python full text search engine. I took a look at PyLucense, but I think that using a Java-based library in a Python project is not good. As I understand, Sphinx does not have a Python API. Any ideas ?
force creating object when using raw_id_fields in Django
4,458,226
0
0
187
0
python,django,django-models
you can overwrite your model's save() by adding codes to create the object directly if it doesn't exist.
0
0
0
0
2010-11-28T17:28:00.000
1
1.2
true
4,298,011
0
0
1
1
I'm using raw_id_fields in my admin.py to change the ForeignKey's select box to an input box. When saving the form, it checks if the object that I wrote in the ForeignKey box exists, if not, it raises an error saying "Select a valid choice. That choice is not one of the available choices." What I want to do is skipping this validation and creating the object directly if it doesn't exist. Any idea to do that? Thank you very much
Faster Development Rails or Django?
4,298,758
1
6
3,565
0
python,ruby-on-rails,ruby,django
This is a question I still am trying to find the answer too, here is what i can tell you so far. Preface When it comes to scripting langauges I always prefer python, not only I feel more strong using python, but also the libraries are better and work faster. Also (and ruby devs will have something to say) I find Python a more understandable and readable code that Ruby. Said this, Rails is an excellent framework! It has a lot more "magic" that Django, and now with Rails 3 you can write your ajax in unobtrusive Javascript which makes it beautiful to read. Also the path and form features are far better that Django's. The big problem is this: As I said Rails does a lot for you (aka magic), the only problems is that if you want to escape those conventions for some reason you find yourself dealing with lots of problems, while with Django you have more control over your application. Django also has the super-hardcore Admin and User application, no need to install any plugin, this is ALL done for you! Setting up users is incredibly easy and the Admin backend gives you CRUD for every model. Overall I prefer Django, I understand it better and it does what I say, although I must say that, as far as things are going nowadays, Rails will have more support in the future. Feel free to ask any question!! Hope it helped Dan
0
0
0
0
2010-11-28T19:35:00.000
5
0.039979
false
4,298,622
0
0
1
2
I have around 2 Weeks of Real development time to churn out a contact database system to replace various spreadsheets and pieces of paper laying around. Also I need to develop two websites (with dynamic content) and a small AJAXian web service. I have no experience of rails or django, but I can learn fast. Both claim to be all about the fast development. What is it that rails has that django doesn't have and vice versa that would accelerate the development of this application? Also the contact database benifit more from the admin panel (dj) or the scaffolding of views (ror)? (there will be a lot of CRUD operations)
Faster Development Rails or Django?
4,298,635
8
6
3,565
0
python,ruby-on-rails,ruby,django
The Django admin will generate a CRUD application that you can customize to suit almost any need, from your model definitions. I've used the admin for the main user interface for several projects and can tell you that it is a real timesaver. You don't have to spend any time whatsoever at writing templates or Javascript. Django also has generic views which can do object detail, list views, update or delete on any model without you worrying about the logic of the app. You just supply the templates, hook into the urls and you're basically done. For deployment I'd say Django and Rails are now equal. Rails has been painful to deploy, but things have changed greatly. For a simple contact database the admin might be the biggest difference between Rails and Django. And the fact that you can run your Django project locally, with a real webserver without any configuration ('python manage.py runserver').
0
0
0
0
2010-11-28T19:35:00.000
5
1
false
4,298,622
0
0
1
2
I have around 2 Weeks of Real development time to churn out a contact database system to replace various spreadsheets and pieces of paper laying around. Also I need to develop two websites (with dynamic content) and a small AJAXian web service. I have no experience of rails or django, but I can learn fast. Both claim to be all about the fast development. What is it that rails has that django doesn't have and vice versa that would accelerate the development of this application? Also the contact database benifit more from the admin panel (dj) or the scaffolding of views (ror)? (there will be a lot of CRUD operations)
How to upload multiple files on cdn?
18,712,080
0
0
1,114
0
python,cdn
I think you are trying to upload the static content of your website (not the user uploaded files) to CDN via FTP client or something similar. To achieve bulk upload you may ZIP all such files on local machine and upload to your webserver. Unzip files on webserver and write a batch script which utlize the CDN API to send files in CDN container. For fulture new or modified files, write another batch script to grab all new/modified files and send to CDN container via CDN API.
0
0
1
0
2010-11-28T21:55:00.000
2
0
false
4,299,324
0
0
1
1
I have to upload a webpage on cdn. Say test.html, test.css, image1.jpg etc. Now I am uploading all these file one by one. I think which is not efficient. So, is it possible to keep all these files in folder and then upload this folder on the cdn? If yes, then what parameters i need to take care about that. Does zipping the folder helpful? I am using python. Thanks in Advance
Which Django/Pinax app should I use? There are so many, and I just want the simplest one
5,870,229
0
2
491
0
python,django,pinax,profiles
I generally like starting with the basic or account, then build up to what I need. I prefer this method to starting with complete/social and stripping out what I don't need. Just fyi.
0
0
0
0
2010-11-28T23:31:00.000
3
0
false
4,299,769
0
0
1
2
I want a "settings" page where the user can submit his hometown/biography/email settings and upload his avatar We will be building a mobile app that uses HTTP Rest API to update the user's profile, so we must be able to do manual override of these apps. That's it! I don't want anything else. I don't care about the friending or blogging or anything. Which Django App should I use? Currently, I am using Pinax's basic_project.
Which Django/Pinax app should I use? There are so many, and I just want the simplest one
4,510,829
1
2
491
0
python,django,pinax,profiles
I actually am approaching the same problem. I find overriding the pinax profile app is enough. The profile section is what allows the upload of avatars and your info and allows you to also edit it. I still haven't found a good way to override the native apps yet. Right now I am copying over the app. Thanks, Ray
0
0
0
0
2010-11-28T23:31:00.000
3
0.066568
false
4,299,769
0
0
1
2
I want a "settings" page where the user can submit his hometown/biography/email settings and upload his avatar We will be building a mobile app that uses HTTP Rest API to update the user's profile, so we must be able to do manual override of these apps. That's it! I don't want anything else. I don't care about the friending or blogging or anything. Which Django App should I use? Currently, I am using Pinax's basic_project.
How can i access the current user outside a request in django
4,303,960
3
6
7,107
0
python,django
There is no sane way to get the user outside of the request. If the current user matters then pass it to any functions that need it.
0
0
0
0
2010-11-29T12:54:00.000
2
0.291313
false
4,303,897
0
0
1
1
I'm working on a medium sized project in django and i want to be able to access the current user from within my query manager. I need to be able to design a custom manager to limit the results and querysets so that the current user only get's information related to him/her. I've received a few suggestions, I've also seen the not so supported example of using threadlocals from a django middleware. However, i'm very confused as this seems to be most promising solution now. I am looking for a better way to do this, so i can gain access to the current user from within a model manager.
Currency Conversion in django
4,304,999
0
1
732
0
python,django,django-models
As the currency rates change, you should either do it via javascript or (I would recommend) doing it in your view function. Storing it in a database would not make much sense, as the conversion rates change from day to day, and every time they changed, you would have to update the values in the database. If data is likely to change regularly, and can be easily generated dynamically, then that is the best option.
0
0
0
0
2010-11-29T14:57:00.000
1
1.2
true
4,304,899
0
0
1
1
I have a quick question, more theory then actual code. I am building a small program that will interact with activeCollab. Anyways, I want to store the value of a quote in canadian dollars but I want to also be able to view it as USD as well. My question is, should I create a field to store the american price or should I use some sort of javascript to show the conversion on the fly (with the use of a button or something). Has anyone come across the same sort of issue before? Thanks everyone. Steve
Is "message" a reserved word in Django or Python?
4,307,510
3
0
1,065
0
python,django
When trying to assign a value to reserved keywords, SyntaxError is raised.
0
0
0
0
2010-11-29T19:49:00.000
6
0.099668
false
4,307,433
0
0
1
3
I seem to get a TypeError ('message' is an invalid keyword argument for this function) every time I try adding something in the DB via the Django admin interface. The object is added but this exception is raised. Could be this linked to the fact that I have a model named "Message"?
Is "message" a reserved word in Django or Python?
4,307,715
1
0
1,065
0
python,django
That means the function you are calling does not accept an argument named "message". I guess that's because the model your are using doesn't have a field named "message"
0
0
0
0
2010-11-29T19:49:00.000
6
0.033321
false
4,307,433
0
0
1
3
I seem to get a TypeError ('message' is an invalid keyword argument for this function) every time I try adding something in the DB via the Django admin interface. The object is added but this exception is raised. Could be this linked to the fact that I have a model named "Message"?
Is "message" a reserved word in Django or Python?
4,307,494
5
0
1,065
0
python,django
No. Python's reserved words do not include message and the TypeError you've described doesn't suggest a namespace collision. Look at the function's keyword arguments and make sure that message is among them. It isn't though, so maybe you meant to type msg.
0
0
0
0
2010-11-29T19:49:00.000
6
1.2
true
4,307,433
0
0
1
3
I seem to get a TypeError ('message' is an invalid keyword argument for this function) every time I try adding something in the DB via the Django admin interface. The object is added but this exception is raised. Could be this linked to the fact that I have a model named "Message"?
Django: translate in a different language than current language
4,313,083
0
0
335
0
python,django
You might find some use in the functions activate(language) and deactivate(language) located in django.utils.translation. I'm not sure about the efficiency of this, I imagine it is slow, but it might do the job :)
0
0
0
0
2010-11-30T11:02:00.000
2
0
false
4,312,995
0
0
1
1
I would like to notify the user in case he's viewing the site in a language that doesn't correspond to his first preference in the ACCEPT_LANGUAGE header. For this reason I would like to present the message to the user in his first prefered language rather than the one he's currently viewing the web-site. Is it possible with django (views and templates) to translate a string in a specific language indipendently than the current language? Thanks Example: Italian user visits for the first time the site, but the english version. I want him to see a message in italian like: "Preferiresti vedere il sito in Italiano?"
App Engine, How to check if all values in a list are in a string list in the datastore
4,319,701
2
0
612
0
python,google-app-engine
This isn't directly possible. You can use multiple equality filters, and the query will only match entities that have at least those items in the list (eg, "WHERE foo = 'a' AND foo = 'b'" will only match if foo is a list containing at least 'a' and 'b'). If you do this without inequality filters or sort orders the datastore will use the built in merge-join strategy to satisfy your query. Denormalization will provide more robust solutions, however. For example, if you serialize your list as a single string, you can simply check for equality with that string.
0
0
0
0
2010-11-30T13:04:00.000
3
0.132549
false
4,314,059
1
0
1
2
If you have a string list in the datastore that has the values: a,b,c How can you compare it against a list so that it only returns true if every value in the string list is present in the list? ['a', 'b'] would return false ['a', 'b', 'c'] would return true ['a', 'b', 'c', 'd', 'e'] would return true Is this possible with GQL alone or would I need to pull put out the string list and loop over it?
App Engine, How to check if all values in a list are in a string list in the datastore
4,315,502
1
0
612
0
python,google-app-engine
You can serialize your list in a sorted fashion as a single StringProperty. Depending on the content of your StringListProperty this may be as trivial as comma separated values. Optionally you can use something like an md5 checksums to reduce the length of the string being stored and filtered against.
0
0
0
0
2010-11-30T13:04:00.000
3
0.066568
false
4,314,059
1
0
1
2
If you have a string list in the datastore that has the values: a,b,c How can you compare it against a list so that it only returns true if every value in the string list is present in the list? ['a', 'b'] would return false ['a', 'b', 'c'] would return true ['a', 'b', 'c', 'd', 'e'] would return true Is this possible with GQL alone or would I need to pull put out the string list and loop over it?
Python JIRA SOAPpy annoying redirect on findIssue
4,350,861
2
3
281
0
python,soap,wsdl,jira
Yes, there's an existing bug on this I've seen. Use the JIRA issue id instead of the key to locate it, as a workaround.
0
0
1
0
2010-12-01T00:25:00.000
1
1.2
true
4,320,135
0
0
1
1
I am trying to do WSDL SOAP connection to our JIRA server using SOAPpy (Python SOAP Library). All seems to be fine except when I try finding specific issues. Through the web browser looking up the bug ID actually redirects to a bug (with a different ID), however it is the bug in question just moved to a different project. Attempts to getIssue via the SOAPpy API results in an exception that the issue does not exist. Any way around this? Thanks
Multi-language website - unique URLs required for different languages (to prevent caching)?
4,321,229
3
1
552
0
python,django,google-app-engine,caching,internationalization
I don't know how this works with django, but looking at it from a general web-development perspective, you could: use a query parameter to determine the language (e.g. /foo/bar/page.py?lang=en) Add the language code to the url path (e.g. /foo/bar/en/page.py), and optionally use mod_rewrite so that that part of the path gets passed to your script as a query parameter.
0
0
0
0
2010-12-01T04:21:00.000
2
0.291313
false
4,321,173
0
0
1
1
I have developed an AppEngine/Python/Django application that currently works in Spanish, and I am in the process of internationalizing with multi-language support. It is basically a dating website, in which people can browse other profiles and send messages. Viewing a profile in different languages will result in some of the text (menus etc) being displayed in whichever language is selected, but user-generated content (ie. user profile or message) will be displayed in the original language in which it was written. My question is: is it necessary (or a good idea) to use unique URLs for the same page being displayed in different languages or is it OK to overload the same URL for a given page being displayed in different languages. In particular, I am worried that if I use the same URL for multiple languages, then some pages might be cached (either by Google, or by some other proxy that I might not be aware of), which could result in an incorrect language being displayed to a user. Does anyone know if this is a legitimate concern, or if I am worrying about something that will not happen?
Is the W3C or any standards body working on a single standard for Entity Attribute ORM definitions?
4,349,392
1
0
226
0
php,.net,python,orm,xforms
To answer the question: no; not that I am aware of. This being said, XForms doesn't much to do with ORM. With XRX, it can be seen as the opposite of ORM, the goal being to avoid mapping, and the complexity it creates. If you use the same data structure (XML in the case of XRX) to hold data all the way, from your UI, to the services you call, to your database, you avoid data transformation and mapping, reducing the complexity of your system.
0
0
0
0
2010-12-02T05:12:00.000
1
0.197375
false
4,331,894
0
0
1
1
There are literally dozens of XML, YAML, JSON, and nested array based (that whole convention over configuration thang) standards for describing : Database tables, Classes, Maps between Tables and Classes, Constraints, User Interface descriptions, Maps between Entities and User Interfaces, Rules for user Interfaces, etc. Every major language has a system and competing standards. [http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software] Some "patterns" like Active-Record are getting implemented in PHP, Python, Ruby, Java etc. But there is no single consensus XML or the nested array thingy de-dur. mean while back in Redmond, Microsoft is crafting XML standards for, well, everything and now with the Entity Framework they have yet another ORM standard. Entity Framework + WPF (Windows Presentation Foundation) + WCF (Windows Communication Foundation) + WF (Windows Workflow Foundation) + LINQ (language-integrated query) = ??? I recall Mozilla's XUL was a nifty thing, but it did not include ORM. Seems like Microsoft is creating a massive set of standards, in XML, that can be used to define entire classes of applications from web, to mobile, to thin client desktop, to traditional heavy desktop app...all, incredibly...with a single set of standards. So ... to conclude ... W3C has XForms ... but (we) need an ORM standard to move things along, something that can be implemented in PHP, Python, Ruby, Java, Objective C, Perl, Javascript, C++, and oh ya C#. If it's active record...ok...fine...but I some how think that the problem is much bigger than Active Record can handle all by itself.
how to show mime data using python cgi in windows+apache
5,335,384
0
0
381
0
python,windows,apache,cgi,mime
Now I know how to solve this problem: For windows+IIS: While adding the application mapping(IIS), write C:\Python20\python.exe -u %s %s. I used to write like this c:\Python26\python.exe %s %s, that will create wrong mime data. And "-u" means unbuffered binary stdout and stderr. For windows+Apache: Add #!E:/program files/Python26/python.exe -u to the first line of the python script. Thank Ignacio Vazquez-Abrams all the same!
0
1
0
1
2010-12-02T06:26:00.000
2
1.2
true
4,332,293
0
0
1
1
I met a problem while using python(2.6) cgi to show a mime data in windows(apache). For example, to show a image, here is my code: image.py #!E:/program files/Python26/python.exe # -*- coding: UTF-8 -*- data = open('logo.png','rb').read() print 'Content-Type:image/png;Content-Disposition:attachment;filename=logo.png\n' print data But it dose not work in windows(xp or 7)+apache or IIS. (I try to write these code in diferent way, and also try other file format, jpg and rar, but no correct output, the output data seems to be disorder in the begining lines.) And I test these code in linux+apache, and it is Ok! #!/usr/bin/env python # -*- coding: UTF-8 -*- data = open('logo.png','rb').read() print 'Content-Type:image/png;Content-Disposition:attachment;filename=logo.png\n' print data I just feel confused why it does not work in windows. Could anybody give me some help and advice?
What is the best practice for registering a new user in my case?
4,333,979
2
1
150
0
python,registration
I've found it useful to put a verification code in the database and use it as you've suggested. The same field can do double duty for e.g. password reset requests. I also use an expiry timeout field, where registrations or password resets need to be dealt with by the user in a timely fashion.
0
0
0
0
2010-12-02T10:05:00.000
2
1.2
true
4,333,711
0
0
1
1
I am going to let new users register on my service. Here is the way I think it should go: 1. User enters his email in a field and clicks Register button. 2. User receives a confirmation email with a link containing a verification code. 3. User goes by that link from the email message where he sees a message that his account is activated now. So, the main point I am to figure out how to implement is the second one. How do I better generate that code? Should I generate it when the user clicks Register button and save it in the field, say "verification_code" near the field "email" and then when he goes to the verification link, compare the values? Then, if that's fine, clear the "verification_code" field and set "user_is_active" field to "True". Or may be I don't have to keep that code in the database at all, but make a just in time verification with some algorithm? May be there are other things I should consider?
Ironpython 2.6.1 on Silverlight 4
4,358,122
2
3
127
0
silverlight,silverlight-4.0,ironpython
You have to use binaries from IronPython-2.6.1\Silverlight\bin folder in Silverlight.
1
0
0
0
2010-12-02T15:56:00.000
1
1.2
true
4,336,935
0
0
1
1
I am trying to integrate IronPython in my Silverlight application but am unable to do so. After downloading the binaries, every time I try to add the dlls as references in my VS2010 solution all I get is an error about them not being compiled for Silverlight. I have even tried downloading the source distribution, but cannot set the various projects making up the solution to build against Silverlight (the only choices I have are different versions of the .net framework). As the IronPython website explicitly states Silverlight compatibility, why is it not working? Is there any easier way of getting scripting capabilities in my Silverlight app?
Generating a default value with the Google App Engine Bulkloader
4,340,593
1
1
296
0
python,google-app-engine,bulkloader
Defining a custom conversion function, as you did, is the correct method. You don't have to modify transform.py, though - put the function in a file in your own app, and import it in the yaml file's python_preamble.
0
1
0
0
2010-12-02T20:05:00.000
1
1.2
true
4,339,325
0
0
1
1
I have successfully used the bulkloader with my project before, but I recently added a new field to timestamp when the record was modified. This new field is giving me trouble, though, because it's defaulting to null. Short of manually inserting the timestamp in the csv before importing it, is there a way I can insert the current right data? I assume I need to look toward the import_transform line, but I know nothing of Python (my app is in Java). Ideally, I'd like to insert the current timestamp (milliseconds since epoch) automatically. If that's non-trivial, maybe set the value statically in the transform statement before running the import. Thanks.
Celery - minimize memory consumption
4,349,979
1
13
19,420
0
python,django,profiling,memory-management,celery
The natural number of workers is close to the number of cores you have. The workers are there so that cpu-intensive tasks can use an entire core efficiently. The broker is there so that requests that don't have a worker on hand to process them are kept queued. The number of queues can be high, but that doesn't mean you need a high number of brokers either. A single broker should suffice, or you could shard queues to one broker per machine if it later turns out fast worker-queue interaction is beneficial. Your problem seems unrelated to that. I'm guessing that your agencies don't provide a message queue api, and you have to keep around lots of requests. If so, you need a few (emphasis on not many) evented processes, for example twisted or node.js based.
0
1
0
0
2010-12-03T14:08:00.000
4
0.049958
false
4,346,318
0
0
1
1
We have ~300 celeryd processes running under Ubuntu 10.4 64-bit , in idle every process takes ~19mb RES, ~174mb VIRT, thus - it's around 6GB of RAM in idle for all processes. In active state - process takes up to 100mb of RES and ~300mb VIRT Every process uses minidom(xml files are < 500kb, simple structure) and urllib. Quetions is - how can we decrease RAM consuption - at least for idle workers, probably some celery or python options may help? How to determine which part takes most of memory? UPD: thats flight search agents, one worker for one agency/date. We have 10 agencies, one user search == 9 dates, thus we have 10*9 agents per one user search. Is it possible start celeryd processes on demand to avoid idle workers(something like MaxSpareServers on apache)? UPD2: Agent lifecycle is - send HTTP request, wait for response ~10-20 sec, parse xml( takes less then 0.02s), save result to MySQL
is Video tag in html a POST request or GET request?
4,348,712
1
0
513
0
python,html
It will be a simple GET request, just like any other resource embedded in an HTML document. If you really want to examine exactly what browsers send, then use something like Charles or the Net tab of Firebug.
0
0
1
0
2010-12-03T18:37:00.000
2
0.099668
false
4,348,707
0
0
1
2
I am iusing in my html. I am trying to handle the request on server side using python BaseHTTPServer. I want to figure out how the request from video tag looks like???
is Video tag in html a POST request or GET request?
4,348,815
0
0
513
0
python,html
POST is usually reserved for form submissions because you are POSTing form information to the server. In this case you are just GETing the contents of a <video> source.
0
0
1
0
2010-12-03T18:37:00.000
2
0
false
4,348,707
0
0
1
2
I am iusing in my html. I am trying to handle the request on server side using python BaseHTTPServer. I want to figure out how the request from video tag looks like???
Need some help on Cookie Handling and session in python
4,368,390
1
1
383
0
python,google-app-engine,cookies
As mentioned above gaeutilties provides sessions support. If that's what you're looking for overall you may want to check it out. However, also to answer your question. Cookies set persist between requests, you don't need to keep resetting it unless you the expiration extremely low. If you do not set an expiration the cookie will persist until the browser is closed.
0
1
0
0
2010-12-04T12:29:00.000
2
0.099668
false
4,353,491
0
0
1
1
I want to set some value to cookie when user visits the homepage so that when he hits some url I'll get that value and compare it with what I've stored in db. Now do I have to set the same cookie value again to handle the next request(in order to maintain session). I'm using python on GAE and I couldn't find any session service available. So the way I've chosen is it the correct one? or Is there any other way to recognize the user? Any tutorial on session maintaining and cookie handling on python will also be very helpful. I'm using python 2.6 with django on GAE. Thanks
Does app engine have a Deploy Hook or Event?
4,355,054
4
5
525
0
python,google-app-engine
No. However, you could get the desired behavior if you write your own deployment script. This script could be a thin wrapper around appcfg.py which makes a request to your app once the deployment is complete (the request handler can execute the logic you wanted to put in your "deploy hook").
0
1
0
0
2010-12-04T16:58:00.000
1
1.2
true
4,354,647
0
0
1
1
I want to increase the version number on a model whenever there is a new deployment to the server. So the idea behind this is: Everytime there is a deployment I wanna run some code. Is this possible within App Engine using hooks or events? I'm using App Engine for Python.
With the rise of NoSQL, Is it more common these days to have a webapp without any model?
4,357,332
0
0
210
1
python,mysql,ruby-on-rails,nosql
The NoSQL effort has to do with creating a persistence layer that scales with modern applications using non-normalized data structures for fast reads & writes and data formats like JSON, the standard format used by ajax based systems. It is sometimes the case that transaction based relational databases do not scale well, but more often than not poor performance is directly related to poor data modeling, poor query creation and poor planning. No persistence layer should have anything to do with your domain model. Using a data abstraction layer, you transform the data contained in your objects to the schema implemented in your data store. You would then use the same DAL to read data from your data store, transform and load it into your objects. Your data store could be XML files, an RDBMS like SQL Server or a NoSQL implementation like CouchDB. It doesn't matter. FWIW, I've built and inherited plenty of applications that used no model at all. For some, there's no need, but if you're using an object model it has to fit the needs of the application, not the data store and not the presentation layer.
0
0
0
0
2010-12-04T21:24:00.000
3
0
false
4,355,909
0
0
1
3
With the rise of NoSQL, is it more common these days to have a webapp without any model and process everything in the controller? Is this a bad pattern in web development? Why should we abstract our database related function in a model when it is easy enough to fetch the data in nosql? Note I am not asking whether RDBMS/SQL is not relevant because that will only start flamewar.
With the rise of NoSQL, Is it more common these days to have a webapp without any model?
4,355,924
0
0
210
1
python,mysql,ruby-on-rails,nosql
SQL databases are still the order of the day. But it's becoming more common to use unstructured stores. NoSQL databases are well suited for some web apps, but not necessarily all of them.
0
0
0
0
2010-12-04T21:24:00.000
3
0
false
4,355,909
0
0
1
3
With the rise of NoSQL, is it more common these days to have a webapp without any model and process everything in the controller? Is this a bad pattern in web development? Why should we abstract our database related function in a model when it is easy enough to fetch the data in nosql? Note I am not asking whether RDBMS/SQL is not relevant because that will only start flamewar.
With the rise of NoSQL, Is it more common these days to have a webapp without any model?
4,355,976
4
0
210
1
python,mysql,ruby-on-rails,nosql
I don't think "NoSQL" has anything to do with "no model". For one, MVC originated in the Smalltalk world for desktop applications, long before the current web server architecture (or even the web itself) existed. Most apps I've written have used MVC (including the M), even those that didn't use a DBMS (R or otherwise). For another, some kinds of "NoSQL" explicitly have a model. An object database might look, to the application code, almost just like the interface that your "SQL RDBMS + ORM" are trying to expose, but without all the weird quirks and explicit mapping and so on. Finally, you can obviously go the other way, and write SQL-based apps with no model. It may not be pretty, but I've seen it done.
0
0
0
0
2010-12-04T21:24:00.000
3
1.2
true
4,355,909
0
0
1
3
With the rise of NoSQL, is it more common these days to have a webapp without any model and process everything in the controller? Is this a bad pattern in web development? Why should we abstract our database related function in a model when it is easy enough to fetch the data in nosql? Note I am not asking whether RDBMS/SQL is not relevant because that will only start flamewar.
how to create a user interface that a user can signup and login using django
4,361,550
1
0
888
0
python,django,user-interface,login
Django auth also provide generic views for login/logout etc. You can use build-in templates or expand it. See in documentation for generic views: django.contrib.auth.views.login, django.contrib.auth.views.logout
0
1
0
0
2010-12-04T22:43:00.000
2
0.099668
false
4,356,234
0
0
1
1
i love gae(google app engine),because it is easy to create a user interface for user login and signup, but now , my boss want me to create a site use django , so the first is to create a site that someone can be login , which is the esaist way to create a user interface ? thanks
How do I get the email address of the person who clicked the link in the email?
4,356,783
9
2
1,324
0
python,google-app-engine,email
Put a hash in the URL that uniquely identifies the address you sent it to.
0
0
0
1
2010-12-05T00:56:00.000
1
1.2
true
4,356,776
0
0
1
1
I am working with Google App Engine python version. The app sends an email to the user with a link to a page to upload an image as an avatar. It would be nice to have the email so that I can associate the avatar with that email. How can I get the email of the person who just clicked the link? Thank you.
New to web development. ASP.NET or Django?
4,357,364
6
5
12,666
0
c#,asp.net,python,django
I've been an ASP.NET programmer for a few years, and I think it's pretty easy to get into. The downsides here are that Microsoft products (TFS in particular) are expensive. Of course, my experiences have been directly related to that -- I've never tried Python in any regard -- so I can only offer my perspectives as an ASP.NET programmer. There are a lot of people who would (accurately) tell you that the page lifecycle in ASP.NET is a gigantic pain in the ass, and that's true too. I personally don't use the server-side part of ASP.NET very often anymore because juggling the lifecycle just leads to messy code and built-in obtuseness. That said, it's really easy to integrate ASP.NET WebServices with jQuery and JavaScript. My experiences with IIS have been pretty good as well, although I can't speak to its problems in more complex environments. I do love TFS, though. In particular, if you're working as a part of a team and need to get user bug reports or enhancement requests, there's a lot of great built-in integration. However, configuring and maintaining TFS is a full-time job in and of itself if you're a part of a development team in a corporation. All that said, I'm not sure it makes much sense to limit yourself to two core languages and then ask about career opportunities. These are going to vary from place to place. I don't see many Python positions where I live, and there were a lot of MS/C#/ASP.NET positions available when I was looking for a job.
0
0
0
0
2010-12-05T03:16:00.000
3
1.2
true
4,357,176
0
0
1
2
Hello I am interested in hearing objective responses in what should a beginner dedicate his or her time into: ASP.NET, Visual Studio, C#, IIS, Team Foundation Server? or Python, Django, PyCharm? These are just some criteria that I am interested in: Easy to start out with. Good documentation. Highly-scalable. Big Career opportunities. Feel free to post your personal opinion on this matter or if you've had an experience with both ASP.NET and Django.
New to web development. ASP.NET or Django?
4,357,372
16
5
12,666
0
c#,asp.net,python,django
C# or java will pay the bills, python will be way more fun
0
0
0
0
2010-12-05T03:16:00.000
3
1
false
4,357,176
0
0
1
2
Hello I am interested in hearing objective responses in what should a beginner dedicate his or her time into: ASP.NET, Visual Studio, C#, IIS, Team Foundation Server? or Python, Django, PyCharm? These are just some criteria that I am interested in: Easy to start out with. Good documentation. Highly-scalable. Big Career opportunities. Feel free to post your personal opinion on this matter or if you've had an experience with both ASP.NET and Django.
Framework design question
4,360,475
1
0
75
1
python,sqlite
I could be wrong, but I think there is no definite answer to this question. It depends on "language" level your framework provides. For example, if another parts of the framework accept data in non-canonical form and then convert it to an internal canonical form, it this case it would worth to support some input date formats that are expected. I always prefer to build strict frameworks and convert data in front-ends.
0
0
0
0
2010-12-05T18:24:00.000
2
1.2
true
4,360,407
0
0
1
2
When committing data that has originally come from a webpage, sometimes data has to be converted to a data type or format which is suitable for the back-end database. For instance, a date in 'dd/mm/yyyy' format needs to be converted to a Python date-object or 'yyyy-mm-dd' in order to be stored in a SQLite date column (SQLite will accept 'dd/mm/yyyy', but that can cause problems when data is retrieved). Question - at what point should the data be converted? a) As part of a generic web_page_save() method (immediately after data validation, but before a row.table_update() method is called). b) As part of row.table_update() (a data-object method called from web- or non-web-based applications, and includes construction of a field-value parameter list prior to executing the UPDATE command). In other words, from a framework point-of-view, does the data-conversion belong to page-object processing or data-object processing? Any opinions would be appreciated. Alan
Framework design question
4,360,452
2
0
75
1
python,sqlite
I think it belongs in the validation. You want a date, but the web page inputs strings only, so the validator needs to check if the value van be converted to a date, and from that point on your application should process it like a date.
0
0
0
0
2010-12-05T18:24:00.000
2
0.197375
false
4,360,407
0
0
1
2
When committing data that has originally come from a webpage, sometimes data has to be converted to a data type or format which is suitable for the back-end database. For instance, a date in 'dd/mm/yyyy' format needs to be converted to a Python date-object or 'yyyy-mm-dd' in order to be stored in a SQLite date column (SQLite will accept 'dd/mm/yyyy', but that can cause problems when data is retrieved). Question - at what point should the data be converted? a) As part of a generic web_page_save() method (immediately after data validation, but before a row.table_update() method is called). b) As part of row.table_update() (a data-object method called from web- or non-web-based applications, and includes construction of a field-value parameter list prior to executing the UPDATE command). In other words, from a framework point-of-view, does the data-conversion belong to page-object processing or data-object processing? Any opinions would be appreciated. Alan
Why don't django templates just use python code?
4,366,241
2
9
594
0
python,django,django-templates
Don't forget that you aren't limited to Django's template language. You're free to use whatever templating system you like in your view functions. However you want to create the HTML to return from your view function is fine. There are many templating implementations in the Python world: choose one that suits you better, and use it.
0
0
0
0
2010-12-06T03:20:00.000
4
0.099668
false
4,362,902
1
0
1
3
I mean I understand that these templates are aimed at designers and other less code-savvy people, but for developers I feel the template language is just a hassle. I need to re-learn how to do very simple things like iterate through dictionaries or lists that I pass into the template, and it doesn't even seem to work very well. I'm still having trouble getting the whole "dot" notation working as I would expect (for example, {{mydict.dictkey}} inside a for loop doesn't work :S -- I might ask this as a separate question), and I don't see why it wouldn't be possible to just use python code in a template system. In particular, I feel that if templates are meant to be simple, then the level of python code that would need to be employed in these templates would be of a caliber not more complicated than the current templating language. So these designer peeps wouldn't have more trouble learning that much python than they would learning the Django template language (and there's more places you can go with this knowledge of basic python as opposed to DTL) And the added advantage would be that people who already know python would be in familiar territory with all the usual syntax and power available to them and can just get going. Am I missing something? If so I plead django noob and would love for you to enlighten me on the many merits of the current system. But otherwise, any recommendations on other template systems that may be more what I'm looking for?
Why don't django templates just use python code?
50,607,955
1
9
594
0
python,django,django-templates
Django templates don’t just use Python code for the same reason Django uses the MVC paradigm:     No particular reason.     (ie: The same reason anyone utilizes MVC at all, and that reason is just that certain people prefer this rigid philosophical pattern.) In general I’d suggest you avoid Django if you don’t like things like this, because the Django people won’t be changing this approach. You could also, however, do something silly (in that it’d be contradictory to the philosophy of the chosen software), like put all the markup and anything else you can into the "view" files, turning Django from its "MVC" (or "MTV" ) paradigm into roughly what everything else is (a boring but straightforward lump).
0
0
0
0
2010-12-06T03:20:00.000
4
0.049958
false
4,362,902
1
0
1
3
I mean I understand that these templates are aimed at designers and other less code-savvy people, but for developers I feel the template language is just a hassle. I need to re-learn how to do very simple things like iterate through dictionaries or lists that I pass into the template, and it doesn't even seem to work very well. I'm still having trouble getting the whole "dot" notation working as I would expect (for example, {{mydict.dictkey}} inside a for loop doesn't work :S -- I might ask this as a separate question), and I don't see why it wouldn't be possible to just use python code in a template system. In particular, I feel that if templates are meant to be simple, then the level of python code that would need to be employed in these templates would be of a caliber not more complicated than the current templating language. So these designer peeps wouldn't have more trouble learning that much python than they would learning the Django template language (and there's more places you can go with this knowledge of basic python as opposed to DTL) And the added advantage would be that people who already know python would be in familiar territory with all the usual syntax and power available to them and can just get going. Am I missing something? If so I plead django noob and would love for you to enlighten me on the many merits of the current system. But otherwise, any recommendations on other template systems that may be more what I'm looking for?
Why don't django templates just use python code?
4,366,273
1
9
594
0
python,django,django-templates
Seperation of concerns. Designer does design. Developer does development. Templates are written by the designers. Design and development are independent and different areas of work typically handled by different people. I guess having template code in python would work very well if one is a developer and their spouse is a designer. Otherwise, let each do his job, with least interference.
0
0
0
0
2010-12-06T03:20:00.000
4
0.049958
false
4,362,902
1
0
1
3
I mean I understand that these templates are aimed at designers and other less code-savvy people, but for developers I feel the template language is just a hassle. I need to re-learn how to do very simple things like iterate through dictionaries or lists that I pass into the template, and it doesn't even seem to work very well. I'm still having trouble getting the whole "dot" notation working as I would expect (for example, {{mydict.dictkey}} inside a for loop doesn't work :S -- I might ask this as a separate question), and I don't see why it wouldn't be possible to just use python code in a template system. In particular, I feel that if templates are meant to be simple, then the level of python code that would need to be employed in these templates would be of a caliber not more complicated than the current templating language. So these designer peeps wouldn't have more trouble learning that much python than they would learning the Django template language (and there's more places you can go with this knowledge of basic python as opposed to DTL) And the added advantage would be that people who already know python would be in familiar territory with all the usual syntax and power available to them and can just get going. Am I missing something? If so I plead django noob and would love for you to enlighten me on the many merits of the current system. But otherwise, any recommendations on other template systems that may be more what I'm looking for?
Designing a web based game that would run in a browser - Where should I start?
4,369,685
9
3
3,099
0
python,web-applications
Step 1. Design a good game. Step 2. Be sure that it fits the HTTP model of simple request/reply GET/POST processing. Be sure that the game is still good. Some people try to do "real time" or "push" or other things that don't fit the model well and require lots of sophisticated GUI on the desktop. Step 3. Find a web framework. Django is okay. Others are good too. Learn the web framework. Don't start with your game. Start with the tutorials. Step 4. Rethink your game. Be sure that it fits the framework's model, as well as the HTTP model. Be sure that the game is still good. In particular, if your focus is "more about data models than graphics" then you have to really be sure that your game's data model fits your framework's capabilities. Step 5. Rethink your framework. Is Django still the right choice? Perhaps you need to go back to step 3 and learn another framework. There's nothing wrong with learning a second framework. Indeed, until you learn another framework, you won't fully get Django. Step 6. Now you should have enough background to actually implement your game.
0
0
0
0
2010-12-06T17:47:00.000
2
1.2
true
4,369,314
0
0
1
1
I would like to design a web based game preferably in Python ( using Django maybe) though I'm open to any language other than Java/Flash/ActionScript. The idea I have in mind is more about data models than graphics and will leverage social networking sites. I would like to extend it with a mobile web interface in the future. Please give your invaluable suggestions and recommend some resources with which I can get started.
In Django, how can I keep the value of the File input after it is returned to it through an error?
4,372,018
2
3
517
0
javascript,python,html,django,forms
If you validate the file separately you could store it before returning the error and provide an indication to the user that their upload has been saved (optionally allow them to choose between uploading yet another file or use the one from a previous submittal). This is a lot of extra housekeeping which could be streamlined but is unavoidable since, for security reasons, browsers do not allow the server to preselect a value for an <input type="file">.
0
0
0
0
2010-12-06T23:15:00.000
1
1.2
true
4,371,947
0
0
1
1
Let's say someone submits a form. (I'm using Django's form framework completely) The form goes through my models.py and doesn't validate well. I redirect them back to the page, and display the form errors. All of the text boxes have their initial value in them, so the user doesn't have to retype them. But my "Choose File" lost its value!!! It doesn't have the file picked anymore. THe user is now required to select the file again. This sucks!!
how to bring a background task to foreground in google app engine?
4,379,300
0
2
282
0
python,google-app-engine,task-queue
This won't work directly as you describe it. Once a background task is started, it's a background task for its entire existence. If you want to return some information from the background task to the user, you'll have to add it to the datastore, and have a foreground handler check the datastore for that information. You may also be able to use the Channel API to have a background task send messages directly to the browser, but I'm not sure if this will work or not (I haven't tried it). If you give a little more information about exactly what you're trying to accomplish I can try to give more details about how to get it done.
0
1
0
0
2010-12-07T16:46:00.000
2
0
false
4,379,200
0
0
1
1
Currently I have tasks running in background. After the tasks are done executing I need to show output. How do I do this in Google App Engine? Once the tasks are done the only thing I can do is create another task which is supposed to show output or is there any other way?
In Django models.py, what's the difference between default, null, and blank?
57,703,695
2
70
32,547
0
python,database,django,string,integer
Null: It is database-related. Defines if a given database column will accept null values or not. Blank: It is validation-related. It will be used during forms validation, when calling form.is_valid(). Default: All Time it store the given value(default value) to the field if one doesn't provide any value for this field. The default values of null and blank are False. That being said, it is perfectly fine to have a field with null=True and blank=False. Meaning on the database level the field can be NULL, but in the application level it is a required field. Now, where most developers get it wrong: Defining null=True for string-based fields such as CharField and TextField. Avoid doing that. Otherwise, you will end up having two possible values for “no data”, that is: None and an empty string. Having two possible values for “no data” is redundant. The Django convention is to use the empty string, not NULL.
0
0
0
0
2010-12-08T04:12:00.000
5
0.07983
false
4,384,098
0
0
1
2
null=True blank=True default = 0 What's the difference? When do you use what?
In Django models.py, what's the difference between default, null, and blank?
28,214,919
2
70
32,547
0
python,database,django,string,integer
In implementation terms: The 'blank' field corresponds to all forms. Specifies if this value is required in form and corresponding form validation is done. 'True' allows empty values. The 'null' field corresponds to DB level. It will be set as NULL or NOT NULL at the DB. Hence if leave a field empty in admin with blank=true, NULL is fed into the DB. Now this might throw an error if that particular column in the DB is specified as NOT NULL.
0
0
0
0
2010-12-08T04:12:00.000
5
0.07983
false
4,384,098
0
0
1
2
null=True blank=True default = 0 What's the difference? When do you use what?
passing information to mod_wsgi and returning to div tag
4,391,636
0
0
207
0
python,drupal,mod-wsgi
Drupal is a PHP-language framework, and wsgi/Django are waay too heavy for you IMHO. They're kinda designed to be used for the whole website. How about passthru in php? passthru — Execute an external program and display raw output You could execute the python script (maybe even with command line arguments from POST) and display raw HTML that the script outputs.
0
0
0
0
2010-12-08T19:34:00.000
2
0
false
4,391,487
0
0
1
2
long time reader first time poster. I've recently been tasked with incorporating some python into a webpage for my employer. After doing some research it seemed that mod_wsgi and Django were the way to go, and it seemed to work great. However, my employer would like to maintain the site in Drupal and incorporate python as such I don't think the Django (or any other python framework) is viable as there would be two competing frameworks running around. I've managed to setup a wsgi-scripts bin and can get python code to run however I have run into a few problems: 1.) The only method I've found for passing information to a wsgi/python script is via POST and GET, is there an alternative or is this the standard method? 2.) When I return from a wsgi/python script a new page is always loaded. Is it possible to have the script return to a div environment? e.g.) Someone fills in a form, submits it, data is processed by python, output is returned and displayed at the bottom of the page. Thanks, Paul
passing information to mod_wsgi and returning to div tag
4,391,744
0
0
207
0
python,drupal,mod-wsgi
1.) The only method I've found for passing information to a wsgi/python script is via POST and GET, is there an alternative or is this the standard method? This makes no sense out of context. If Apache (or whatever web server you're using) runs mod_wsgi, which runs Python, then the answer is "This is not only the standard, it's absolutely all you've got. Outside environment variables." I'm not sure why you're asking, since the standard for HTTP is quite clear and quite simple. 2.) When I return from a wsgi/python script a new page is always loaded. Is it possible to have the script return to a div environment? e.g.) Someone fills in a form, submits it, data is processed by python, output is returned and displayed at the bottom of the page. "have the script return to a div environment" doesn't make any sense at all. "Someone fills in a form, submits it, data is processed by python, output is returned and displayed at the bottom of the page." Doesn't make any sense at all. You seem to be describing something that's not HTTP at all. I'm not sure why you're asking, since the standard for HTTP is quite clear and quite simple. A request (GET, POST, PUT, DELETE, whatever) goes to the web server and a page comes back. That's more-or-less HTTP in a nutshell. There are no other inputs. There are no partial outputs. If you want a Python application (running under mod_wsgi) to get data from Drupal, that's just an API call from Python to whatever server is running Drupal. If you want the old page plus new information to be displayed, you have to assemble a page which contains the old page plus the new information. You have to write this new page. Use a template or some other tool.
0
0
0
0
2010-12-08T19:34:00.000
2
0
false
4,391,487
0
0
1
2
long time reader first time poster. I've recently been tasked with incorporating some python into a webpage for my employer. After doing some research it seemed that mod_wsgi and Django were the way to go, and it seemed to work great. However, my employer would like to maintain the site in Drupal and incorporate python as such I don't think the Django (or any other python framework) is viable as there would be two competing frameworks running around. I've managed to setup a wsgi-scripts bin and can get python code to run however I have run into a few problems: 1.) The only method I've found for passing information to a wsgi/python script is via POST and GET, is there an alternative or is this the standard method? 2.) When I return from a wsgi/python script a new page is always loaded. Is it possible to have the script return to a div environment? e.g.) Someone fills in a form, submits it, data is processed by python, output is returned and displayed at the bottom of the page. Thanks, Paul
How to override the stack trace template in django?
4,395,425
3
1
331
0
python,django,exception-handling,django-templates
Well, the trace is formatted by an internal template in views/debug.py. Look for TECHNICAL_500_TEMPLATE and for get_traceback_html() where it's used. So you could copy that template, hack it as you like, then monkeypatch it into django.view.debug. It ain't pretty, but this is fairly deep into the guts so you have to expect to get some "stuff" on you.
0
0
0
0
2010-12-08T22:12:00.000
2
1.2
true
4,392,902
0
0
1
1
How can I change the template that django uses to display a stack trace when DEBUG mode is enabled and an exception gets caught at the top of the stack resulting in a 500? Apologies if this is a dupe question -- I'm sure the answer is stated simply somewhere, but owing to the nature of the search terms I'm having a hard time tracking down the answer. Thanks!
Scability of Ruby-PHP-Python on Cassandra/Hadoop on 500M+ users
9,921,879
0
0
339
1
php,python,ruby-on-rails,scalability,cassandra
Because Cassandra is written in Java, a client also in Java would likely have the best stability and maturity for your application. As far as choosing between those 3 dynamic languages, I'd say whatever you're most comfortable with is best. I don't know of any significant differences between client libraries in those languages.
0
0
0
1
2010-12-09T12:46:00.000
1
0
false
4,398,341
0
0
1
1
Which one of Ruby-PHP-Python is best suited for Cassandra/Hadoop on 500M+ users? I know language itself is not a big concern but I like to know base on proven success, infrastructure and available utilities around those frameworks! thanks so much.
Java equivalent of python's getattr?
54,568,702
0
12
4,915
0
java,python,reflection
The easiest way to handle this is to create a Map object in Java class & keep adding the name value pairs & retrieve it accordingly though it might not support different types that setAttr supports.
0
0
0
1
2010-12-09T12:56:00.000
6
0
false
4,398,432
1
0
1
2
I'm converting some python code to java, and have a situation where I need to call methods of an object but don't know which methods until runtime. In python I resolve this by using getattr on my object and passing it a string that is the name of my method. How would you do something similar in Java?
Java equivalent of python's getattr?
4,398,473
0
12
4,915
0
java,python,reflection
In Java you do this with the Reflection API (and it's usually pretty cumbersome). MethodUtils in Apache Commons BeanUtils project may make it a bit easier to work with, though it's a pretty hefty dependency for something simple like this.
0
0
0
1
2010-12-09T12:56:00.000
6
0
false
4,398,432
1
0
1
2
I'm converting some python code to java, and have a situation where I need to call methods of an object but don't know which methods until runtime. In python I resolve this by using getattr on my object and passing it a string that is the name of my method. How would you do something similar in Java?
WCF Service Applcation remaining idle until hit manually .svc file
8,192,452
0
0
314
0
asp.net,.net,wcf,python-idle
WCF is meant to be consumed and to fire events, not to host long-running processes. You really want WF (workflow foundation) or BizTalk to host some long-running events. WCF events are typically short lived. You can create a XAMLX which combines the two concepts.
0
0
0
0
2010-12-09T13:45:00.000
2
0
false
4,398,856
1
0
1
1
I create a WCF Service Application that runs in IIS 7.0 . In its initialization I start an endless loop ( while(true) ) , but after a period of time ,where I didn't call a method from his svc file, the wcf pass in an idle mode, and it doesn't react in the process the loop has to do. It is like it stops working. And then if i call a method to his svc file then starts working again. Is there a solution to avoid the idle mode so it can continue to keep the procedure in the loop alive?
How can I add something to the heading part of HTML document with docutils
4,399,316
1
2
133
0
python,docutils
There is a meta directive to set meta tags if that's what you want. If you are wanting to control the whole web page with your own css and javascript then you might want to look at Sphinx and write your own theme.
0
0
0
0
2010-12-09T13:57:00.000
1
0.197375
false
4,398,962
0
0
1
1
This document (http://docutils.sourceforge.net/docs/ref/rst/directives.html) explains about using .. raw:: to pass through HTML code in docutils, and the HTML code is in the body part of generated HTML. How can I put something in heading part (..) with docutils?
what are python web frameworks
4,406,739
1
4
335
0
python,web-applications,cgi,web-frameworks
A web framework is a toolkit designed to make working with HTTP requests within a certain language easier. It usually provides things like URL routing and HTML templating, and may optionally provide a ORM. It may or may not come with its own web server. On Python they are usually written to WSGI, of which there are plenty of containers.
0
0
0
0
2010-12-10T07:42:00.000
2
0.099668
false
4,406,676
0
0
1
1
I've asked this question on some places but I never get a completely straight answer. I've heard a lot about web frameworks and only know a basic understanding. Okay is a web framework installed on top of server architecture like apache or is it its own thing? I've read a good amount about web frameworks and I like what I read, but I only have access to simple free apache web hosts. Python works on it because I've tested it but I don't have a whole lot of freedom on it to install different kinds of software and such.
Python in java, is it possible
4,413,778
13
0
286
0
java,python
JYthon is a python implementation in java , you should check it out www.jython.org
0
0
0
0
2010-12-10T22:12:00.000
2
1.2
true
4,413,763
0
0
1
1
I have a class that is written in Java. Can it be used in Python so i dont have to rewrite it?
Problem loading local files with webkit in python
4,421,093
3
2
2,182
0
python,webkit,gtk
You can't. webview.load_uri() takes a string containing a URI. 'file.html' isn't a URI, 'file://file.html' is.
1
0
0
0
2010-12-11T11:50:00.000
2
1.2
true
4,416,570
0
0
1
2
Every time I need to load a local file using webkit in python I need to start with "file://" which I need to include in all files I am working with. How can I eliminate the need to do that? I want to load files like webview.load_uri('file.html') instead of webview.load_uri('file://file.html')?
Problem loading local files with webkit in python
7,470,386
1
2
2,182
0
python,webkit,gtk
webview.load_string() takes the text of an html file. you can load the file into a file object without the file:// and read it into the load_string function.
1
0
0
0
2010-12-11T11:50:00.000
2
0.099668
false
4,416,570
0
0
1
2
Every time I need to load a local file using webkit in python I need to start with "file://" which I need to include in all files I am working with. How can I eliminate the need to do that? I want to load files like webview.load_uri('file.html') instead of webview.load_uri('file://file.html')?
"Invalid Filter" error for my custom Django template filters but not any other filters
4,417,129
7
1
6,013
0
python,django,django-templates,django-template-filters
The answer is maddeningly simple: split the custom tag and custom filter into two separate python files and it will work. I suspect the problem is this: the custom tag is using template.loader.get_template() to load another template. That template file contains a {% load %} tag which tries to load the same file in which the parent custom tag is defined. For some reason, this doesn't work-- perhaps because it would cause an infinite loop or because Django assumes it's already loaded. I didn't try recusrively loading a custom tag inside a filter, or a tag inside another tag, to see if the same problem occurs there too, but if it does, the fix would be the same: if you want to use template.loader.get_template() to load a template which contains calls to your own custom tags or filters, make sure that the file calling template.loader.get_template() is a different file from the file defining your included tags/filers.
0
0
0
0
2010-12-11T14:13:00.000
1
1.2
true
4,417,127
0
0
1
1
I have a python file in my Django project which contains a custom template tag and a custom template filter. My custom tag uses template.loader.get_template() to load another template file. This worked great... until I added my custom filter to the loaded template. Now I get a Django "Invalid Filter" TemplateSyntaxError exception. Looking at the call stack, Django is unable to load my template filter. Here's where things get weird. I can use my custom filters from another template. I can use any other filter inside the template loaded by my custom tag. But I can't use my own filter inside my own custom tag. The obvious cause of this would be not loading my custom tag/filter file inside my template HTML, but I am correctly loading it. (because when I don't load it, I'll get a different error -- "invalid block tag") I'm running Django 1.2.3 on Python 2.7. [BTW, I finally found the answer myself, but it took me several hours and I wasn't able to find the answer anywhere on stackoverflow or google, so I'm going to answer my own question so others won't have to waste as much time as I did]
How to maintain order of paragraphs in a Django document revision system?
4,418,851
2
1
304
0
python,django,database-design
Editors often solve this problem with a Piece Table. The table is a list of objects that point to spans of characters that are a) contiguous in memory, and b) share common attributes. The order of the pieces in the table is used for mapping character-in-document addresses to memory and vice versa. By reordering the piece table you effectively reorder the document without moving anything around. The key point is that the piece table itself is independent of the objects that make up the content of the document. So one way of mapping your paragraph order would be to have a simplified version of a peice table. This could be as simple as a list of para-ids in document order. When you need to change something, you fetch the list, unpickle it, make you edits on the list, pickle and save. Another advantage of the table is that it greatly simplifies implementing undo. The history file is a simple list of edits to the table, and undoing/redoing is a matter of reversing or reapplying a particular edit to the table, the data itself doesn't change. This should play well with any versioning you want to do.
0
0
0
0
2010-12-11T19:17:00.000
2
1.2
true
4,418,461
0
0
1
1
I'm having trouble figuring out how to best implement a document (paragraph-) revision system in Django. I want to save a revision history of a document, paragraph-by-paragraph. In other words, there will be a class Document, which has a ManyToManyField to Paragraph. To maintain the order of the paragraphs, a third class ParagraphContainer can be created. My question is, what is a good way to implement this in Django so that the order of paragraphs is maintained when someone adds a new paragraph in-between existing paragraphs? One obvious way would be to have a position attribute in the ParagraphContainer class, but then this field will have to be updated in all paragraphs following the inserted (or deleted) paragraph. A linked list is another option, but I'm scared that might be very slow for retrieval of the whole document. Any advice?
Django + Adsense on Google App Engine
4,426,058
1
0
1,724
0
python,django,google-app-engine,templates,adsense
adsense is javascript, if your django is returning nothing check your HttpResponse and how you are generating the template. it looks like you need to specify in settings.py the location of the template file. you may want add the following (in settings.py): import os ROOT_PATH = os.path.dirname(__file__) TEMPLATE_DIRS = ( os.path.join(ROOT_PATH, 'templates') ) then put your django templates in a sub-directory to your project called "/templates" or try the process of elimination: comment out any javascript and see if you can generate the template from django.
0
1
0
0
2010-12-12T16:52:00.000
2
0.099668
false
4,422,754
0
0
1
2
I have a problem with Django on Google App Engine. I finished to design html templet for my web application and I imported them on django using django template system. The problem is google ad-sense. I can say ad-sense banner on the html version of my pages if i try to open them in my browser. But nothing appear if I try to do the same operation with them loaded in django. I also tried to develop a simple html template that contains only the adSense script, if i load this on django it returns a white page. No banner, nothing. What can i do to solve this problem?
Django + Adsense on Google App Engine
4,448,211
0
0
1,724
0
python,django,google-app-engine,templates,adsense
I solved the problem! Sorry, I accidentally added some character with erroneous codeing.
0
1
0
0
2010-12-12T16:52:00.000
2
0
false
4,422,754
0
0
1
2
I have a problem with Django on Google App Engine. I finished to design html templet for my web application and I imported them on django using django template system. The problem is google ad-sense. I can say ad-sense banner on the html version of my pages if i try to open them in my browser. But nothing appear if I try to do the same operation with them loaded in django. I also tried to develop a simple html template that contains only the adSense script, if i load this on django it returns a white page. No banner, nothing. What can i do to solve this problem?
Intellij IDEA 10 + Python + Django does not run Apache Ant-scripts
4,428,911
0
0
679
0
python,django,ant,intellij-idea
Which module type have you created? Please try to create a regular Java module with a Java SDK, and to add a Python facet to it.
0
0
0
0
2010-12-13T07:57:00.000
1
0
false
4,426,808
0
0
1
1
Greetings! Intellij IDEA 10 + Python plugin when creating a project using Django, does not run Apache Ant-scripts. When I try to add an Ant-script error occurs «Cannot Add Files». I can’t understand reason of problem.
Extra Python libraries on phone
5,888,625
0
0
157
0
python,symbian,s60,pys60
I don't thinks those libraries will run on PyS60 if they are not designed for that platform.
0
0
0
0
2010-12-13T09:56:00.000
1
0
false
4,427,623
1
0
1
1
I have Python installed on my S60 phone...but I require some addtional libraries like pyaudio and lightblue to be installed on my phone...is there a way I can do this? Also where are the Python libraries installed on my phone?
How can I fix missing IronPython project templates in Visual Studio 2010?
7,561,040
2
1
1,945
0
visual-studio-2010,ironpython,ironpython-studio
I had a similar issue with IronPython 2.7 RTM on VS 2010 SP1. I had the python tools for VS 1.0 installed before I installed IronPython. I did the following to resolve the issue Uninstalled IronPython Uninstalled Python tools for VS Installed IronPython 2.7 RTM without the "Tools for VS" feature, this is provided by the python for VS installer Installed Python Tools for VS
0
0
0
0
2010-12-13T19:19:00.000
2
0.197375
false
4,432,606
1
0
1
1
I installed IronPython yesterday. After running Visual Studio the IronPython project template showed up but later it was gone. I've tried repairing, uninstalling, and reinstalling without fixing the issue. How can I make the templates show up?
How to get html tags from url?
4,435,929
0
1
646
0
python,html,url,printing
Fetch it (using mechanize, urllib or whatever else you want), parse what you get (using elementtree, BeautifulSoup, lxml or whatever else you want) and you have what you want.
0
0
1
0
2010-12-14T04:31:00.000
2
0
false
4,435,882
0
0
1
1
How would you get all the HTML tags from a URL and print them?
How do you submit a form to an app engine python application without refreshing the sending page?
4,437,354
8
0
514
0
python,google-app-engine,forms,submit,datastore
Sounds like you want to look into AJAX. The simplest way to do this is probably to use the ajax functions in one of the popular Javascript libraries, like jQuery.
0
1
0
0
2010-12-14T08:42:00.000
3
1
false
4,437,307
0
0
1
2
As a newbie to app engine and python I can follow the examples given by Google and have created a python application with a template HTML page where I can enter data, submit it to the datastore and by reading back the data, just sent, recreate the sending page so I can continue adding data and store again. However what I would like to do is submit the data, have it stored in the datastore without the sending page being refreshed. It seems like a waste of traffic to have all the data sent back again.
How do you submit a form to an app engine python application without refreshing the sending page?
4,439,461
-1
0
514
0
python,google-app-engine,forms,submit,datastore
Have a look at Pyjamas pyjs.org It's a Python Compiler for web browsers. Write your client side in Python and Pyjamas will compile it into JavaScript.
0
1
0
0
2010-12-14T08:42:00.000
3
-0.066568
false
4,437,307
0
0
1
2
As a newbie to app engine and python I can follow the examples given by Google and have created a python application with a template HTML page where I can enter data, submit it to the datastore and by reading back the data, just sent, recreate the sending page so I can continue adding data and store again. However what I would like to do is submit the data, have it stored in the datastore without the sending page being refreshed. It seems like a waste of traffic to have all the data sent back again.
Scaling a follower model
4,441,374
1
1
185
0
python,django,nosql,scaling,partitioning
Problem A: how to keep the query for items added by people you are following working well with growing datasets? starting with a dataset of (who are my followers / who am i following); one could save these values as tuples and segmentate them across several SQL databases (though I doubt real segmentation is really needed even for twitter size databases). This would give the list of people who are followed. Secondly, a table for follower->items, sorted by follower could be easily queried; and also segmentated if needed given humongous datasets. Problem B: we are seeing geographically disperse traffic. large userbase in the netherlands and brazil. any solution would probably need to allow for databases across multiple data centers. one could designate a master database (cluster) and a slave databse (cluster), and replicate data from the master to the slave. However, this does imply the data is always saved to the master database. data queries can be done locally. Another option is to run the database (clusters) in a master-master setup; but this is generally more trouble then it is worth.
0
0
0
0
2010-12-14T16:05:00.000
1
0.197375
false
4,441,209
0
0
1
1
The problem is somewhat similar to twitter/facebook's: followers and following users add items Subsequently you see the items added by all the people you are following. Problem A: how to keep the query for items added by people you are following working well with growing datasets? Problem B: we are seeing geographically disperse traffic. large userbase in the netherlands and brazil. any solution would probably need to allow for databases across multiple data centers. We are running on a django/python stack. Already running edge server caching. (Anonymous users get the cached version, logged in user's version is run through a second level template parsing service first)
Best practice for running a daily Python screen-scraping script 50 times (8.3 minutes total) per user?
4,441,983
0
0
772
0
php,python,design-patterns,cron,screen-scraping
Do you need to run the script 50 times per user, or only when the user has logged into your service to check on things?
0
0
0
1
2010-12-14T17:06:00.000
3
0
false
4,441,933
0
0
1
2
On the front-end, I have a PHP webapp that allows users to create a list of their websites (5 max). On the back-end, a Python script runs daily (and has ~10 iterations) for each website that the user registers. Each script per website takes about 10 seconds to run through all iterations and finish its scraping. It then makes a CSV file with its findings. So, in total, that's up to (5 websites * 10 iterations =) 50 iterations at 8.3 total minutes per user. Right now, the script works when I manually feed it a URL, so I'm wondering how to make it dynamically part of the webapp. How do I programmatically add and remove scripts that run daily depending on the number of users and the websites each user has each day? How would I schedule this script to run for each website of each user, passing in the appropriate parameters? I'm somewhat acquainted with cronjobs, as it's the only thing I know of that is made for routine processes.
Best practice for running a daily Python screen-scraping script 50 times (8.3 minutes total) per user?
4,441,994
0
0
772
0
php,python,design-patterns,cron,screen-scraping
Assuming you're using a database to store the users' web sites, you can have just 1 script that runs as a daily cron job and queries the database for the list of sites to process.
0
0
0
1
2010-12-14T17:06:00.000
3
0
false
4,441,933
0
0
1
2
On the front-end, I have a PHP webapp that allows users to create a list of their websites (5 max). On the back-end, a Python script runs daily (and has ~10 iterations) for each website that the user registers. Each script per website takes about 10 seconds to run through all iterations and finish its scraping. It then makes a CSV file with its findings. So, in total, that's up to (5 websites * 10 iterations =) 50 iterations at 8.3 total minutes per user. Right now, the script works when I manually feed it a URL, so I'm wondering how to make it dynamically part of the webapp. How do I programmatically add and remove scripts that run daily depending on the number of users and the websites each user has each day? How would I schedule this script to run for each website of each user, passing in the appropriate parameters? I'm somewhat acquainted with cronjobs, as it's the only thing I know of that is made for routine processes.
Package a django project and its dependencies for a standalone "product"
4,452,849
2
21
9,313
0
python,django,packaging
Yes, you can package it. Django may not be the easiest to do this with, but the principles are the same for other frameworks. You need to make an installer that installs everything you need. And that installer needs to be different for different platforms. such as Windows, Ubuntu, OS X etc. That also means that the answer is significantly different for each platform, and only half of the answer is dependning on Django. :-( This kinda sucks, but that's life, currently. There is no nice platform independent way to install software for end users.
0
0
0
0
2010-12-15T16:19:00.000
6
1.2
true
4,452,208
0
0
1
1
I've made a small little "application" utilizing Django as a framework. This is an application that is not ment to be deployed to a server but run locally on a machine. Thus the runserver.py works just nice. I, as an developer is comfortable with fireing up the terminal, running python manage.py runserver and using it. But I have some Mac OS X and Windows friends wanting to use my application, and they dont have virtualenv, git or anything else. Is there a way I can package this to be a standalone product? Of course it would depend on Python being installed on the system, but it is possbile to package the virtualenv — with django and everything, and just copy it to another system and make it work? And maybe even run the runserver in some kind a deamon mode?
alternative permissions model with repoze.what
4,638,281
0
0
225
0
python,authentication,authorization,web-frameworks
I have an answer, after a bit of fiddling. The answer is that the only reason to use the authentication schema suggested in the repoze.what documentation is that if you do, you can use their predicates for free. Fortunately, writing & using your own predicates is a piece of cake. It seems to me that the only hard requirement is for a user object (although obviously you can call this whatever you want). In my app I have a bunch of custom predicates that check certain things like: Is the user a member of this group? (group specified by a parameter) Is the user logged in? Does the user hold this particular site role? I can then use these predicates wherever I want.
0
0
0
0
2010-12-15T21:38:00.000
2
0
false
4,455,197
0
0
1
1
I'm writing a web app, and I'd like to use repoze.what & repoze.who to handle my authorisation & authentication. The problem is that repoze.what seems to be hard-coded to accept a certain permissions model, that is: Visitors to the site are either a logged in user, or anonymous. User accounts belong to 0 or more groups. Groups have 0 or more permissions associated with them. So, for example, your permissions might be 'can-post-article' and 'can-post-comment', and your groups might be 'author', 'visitor', where 'author' can both post articles & post comments, while visitors can only post comments. That model probably works for most sites. However, my site allows teams to collaborate with each other on different levels. So the security model that I need is: Visitors are either a logged in user, or anonymous. Users are a member of 0 or more groups. For each group that the user is a member of, that membership will have different permissions. For example, the user might be an 'author' or group A, but a 'commenter' on group B. The number of groups will change over time, and the memberships of those groups will also change. I can't see any easy way to integrate this permissions model into repoze.what. Am I missing something obvious?
How do I generate a Django CSRF key for my iPhone and Android apps that want to send a POST request?
4,457,172
6
3
1,747
0
python,django,http,ios,csrf
Is your goal to re-use an existing form? if so, iPhone app should GET the page with the form and then POST using the CSRF token. The whole point of CSRF tokens is that the server has to generate them. Is your goal to authenticate the iPhone app so that other apps can't POST to your API? That is a can of worms, since any secret that you give your iPhone app can be read by anybody who has downloaded the app.
0
0
0
0
2010-12-15T23:01:00.000
2
1.2
true
4,455,845
0
0
1
1
Here's the thing: Right now, on my website template, there is {% csrf_token %} that allows my website to send a POST request of a form. But what if my iPhone app (a client) wants to send a POST request to my web service? How do I give my iPhone app a CSRF token that it can temporarily use?
If I just want a simple comment box below my entry, should I use Django's comment framework or write my own?
4,456,547
1
1
477
0
python,django,templates,frameworks
Um... yes? More seriously - whatever makes you happier. If you're in a hurry, roll your own; if you have a bit more time, by all means get to know the Django system; it'll probably be worthwhile in the longer run.
0
0
0
0
2010-12-16T00:42:00.000
1
1.2
true
4,456,444
0
0
1
1
I'm split between writing my own comments model (pretty easy model, foreign key it to the entry) or using the full-out Django comment framework. I mean, for right now, I just want a basic box for people to post a comment. That's it.
Django: correct way to group a bunch of media's
4,462,233
0
2
135
0
python,django,django-forms,media
What happens if you just use {{ form.media }} for each form, and link up the media in the form's Meta? I seem to remember that making sure that it didn't insert anything twice, but it's been a while. Have you tried that yet?
0
0
0
0
2010-12-16T01:14:00.000
2
0
false
4,456,591
0
0
1
1
I send several forms to a template, and I want to put all required media in the <head> tag. Some forms might require the same media (for instance, the same JS file), so I would like to unify all medias before putting them in the <head>. Question is, how do I do that? I know you can unify two medias by doing m1 + m2, but this will look ugly in the generic case where I have an unknown number of forms. Is there some shortcut?
Multi threaded webserver vs single threaded
4,458,917
0
4
7,079
0
python,database,multithreading,webserver
If the Web server is single-threaded and DB requests are synchronous (meaning the Web server is blocked while the DB request is being processed) then making it multi-threaded would help. This would enable you to process multiple requests simultaneously. Your DB engine is probably quite good at that. However, right now you're not letting it to service multiple requests simultaneously because you have the Web server sitting right in front of it that only feeds it one request at a time.
0
0
0
0
2010-12-16T08:49:00.000
5
0
false
4,458,890
1
0
1
5
We have a simple webserver for internal use that has only one duty: listen for requests, read them, and push the data in a database. The db and webserver are both located on the same machine. The db is a mysql-db and the server is a python webserver (BaseHTTPServer.HTTPServer) which runs single threaded. The problem is that two requests can't be handled at the same time. The question is, would it help to make the webserver multi-threaded (using django, cheryypy,..)? Intuitively, the webserver is only performing CPU consuming tasks so changing it to multi-threaded shouldn't help. Is this correct?
Multi threaded webserver vs single threaded
4,458,945
0
4
7,079
0
python,database,multithreading,webserver
My instinct says you're right, but it also says that using Django or Cherrypy is WAY overkill, even if you did want to make it multithreaded. I think you're right, though, since if the webserver really isn't doing anything other than working a DB, then any other thread wouldn't be able to do anything other than start a response. The client will happily wait the ten-to-hundred ms necessary for the other request to finish, and then the server will be able to accept() right away.
0
0
0
0
2010-12-16T08:49:00.000
5
0
false
4,458,890
1
0
1
5
We have a simple webserver for internal use that has only one duty: listen for requests, read them, and push the data in a database. The db and webserver are both located on the same machine. The db is a mysql-db and the server is a python webserver (BaseHTTPServer.HTTPServer) which runs single threaded. The problem is that two requests can't be handled at the same time. The question is, would it help to make the webserver multi-threaded (using django, cheryypy,..)? Intuitively, the webserver is only performing CPU consuming tasks so changing it to multi-threaded shouldn't help. Is this correct?
Multi threaded webserver vs single threaded
4,458,981
3
4
7,079
0
python,database,multithreading,webserver
Having several threads or processes will indeed help you (indeed it's in practice required) when you want to handle more than one request at a time. That doesn't mean that the two requests will be handled faster. Having a pool of processes or threads is very helpful for webserver performance, but that's not really noticeable in cases like this (unless you have multiple cores). But MySQL has no problem handling two requests at the same time, so if your webserver can do it as well, then you get rid of the problem of handling just one request. But if it's worth the effort to start using such a server only you can answer. :) Django is surely overkill in any case, look at some small WSGI server.
0
0
0
0
2010-12-16T08:49:00.000
5
0.119427
false
4,458,890
1
0
1
5
We have a simple webserver for internal use that has only one duty: listen for requests, read them, and push the data in a database. The db and webserver are both located on the same machine. The db is a mysql-db and the server is a python webserver (BaseHTTPServer.HTTPServer) which runs single threaded. The problem is that two requests can't be handled at the same time. The question is, would it help to make the webserver multi-threaded (using django, cheryypy,..)? Intuitively, the webserver is only performing CPU consuming tasks so changing it to multi-threaded shouldn't help. Is this correct?
Multi threaded webserver vs single threaded
4,459,115
0
4
7,079
0
python,database,multithreading,webserver
You should go for multithreaded or asynchronous webserver, otherwise each request is being blocked. Django is a web framework, you might have to look for scripts which you can transparently replace in your current setup and still have your pure python multithreaded webserver. Otherwise twisted is a good solution too. AFA I can see, you may not want a Web Framework because you are not doing a template driven MVC style app.
0
0
0
0
2010-12-16T08:49:00.000
5
0
false
4,458,890
1
0
1
5
We have a simple webserver for internal use that has only one duty: listen for requests, read them, and push the data in a database. The db and webserver are both located on the same machine. The db is a mysql-db and the server is a python webserver (BaseHTTPServer.HTTPServer) which runs single threaded. The problem is that two requests can't be handled at the same time. The question is, would it help to make the webserver multi-threaded (using django, cheryypy,..)? Intuitively, the webserver is only performing CPU consuming tasks so changing it to multi-threaded shouldn't help. Is this correct?
Multi threaded webserver vs single threaded
4,460,274
1
4
7,079
0
python,database,multithreading,webserver
Step 1. Use Apache. It may seem like overkill but it's cheap multi-threading with no programming on your part. Apache can be configured to fork off several servers. No programming on your part. This may be sufficient to make your application run concurrently. Step 2. Rewrite your application to use the wsgi framework and embed it in the wsgiref server. This won't change much, but it's the way you should always write small web applications. Step 3. Use mod_wsgi in Apache. It allows you to have one or more background daemon versions of your application. With no additional programming you get a heap of concurrency available to you. Important lesson learned. Always use WSGI.
0
0
0
0
2010-12-16T08:49:00.000
5
0.039979
false
4,458,890
1
0
1
5
We have a simple webserver for internal use that has only one duty: listen for requests, read them, and push the data in a database. The db and webserver are both located on the same machine. The db is a mysql-db and the server is a python webserver (BaseHTTPServer.HTTPServer) which runs single threaded. The problem is that two requests can't be handled at the same time. The question is, would it help to make the webserver multi-threaded (using django, cheryypy,..)? Intuitively, the webserver is only performing CPU consuming tasks so changing it to multi-threaded shouldn't help. Is this correct?
Does Django have a template tag that can detect URLs and turn them into hyperlinks?
4,465,784
0
8
3,616
0
python,django,http,templates,url
Another option is to parse plain text in some way, for example as reStructuredText (my favourite) or Markdown (Stack Overflow uses a slightly modified variant of Markdown). These will both turn valid plain text links targets into hyperlinks. This also gives you more power over what you can do; you won't need to resort to HTML to achieve some basic formatting. Note also as stated with urlize that you should only use it on plain text; it's not designed to be mixed with HTML.
0
0
0
0
2010-12-16T21:41:00.000
3
0
false
4,465,636
0
0
1
1
When someone writes a post and copies and pastes a url in it, can Django detect it and render it as a hyperlink rather than plain text?
Best way to request-scope data in Django?
4,468,901
1
0
1,377
0
python,django
Just assign the dictionary directly to the request. You can do that in middleware or in your view, as you like.
0
0
1
0
2010-12-17T01:18:00.000
2
1.2
true
4,466,923
0
0
1
1
I'm wondering if there's a clever pattern for request-scoping arbitrary information without resorting to either TLS or putting the information in the session. Really, this would be for contextual attributes that I'd like to not look up more than once in a request path, but which are tied to a request invocation and there's no good reason to let them thresh around in the session. Something like a dict that's pinned to the request where I can shove things or lazy load them. I could write a wrapper for request and swap it out in a middleware, but I figured I'd check to see what best-practice might be here?
Is there a Django app that can give me easy friend importing AND invite from Facebook, Twitter, and Gmail?
7,865,880
1
3
667
0
python,django,facebook,gmail
Take a look at the pinax (http://pinaxproject.com/). They have a lot of reusable apps and one of those provide mechanism for inviting friends from openid based sites (i.e. facebook)
0
0
0
0
2010-12-18T00:38:00.000
1
0.197375
false
4,475,930
0
0
1
1
Super easy django app that just lets people click "Facebook", and then invite AND import their friends
Inside Django's models.py, if I am validating a form, how do I get the user's IP?
4,477,440
1
0
179
0
python,django,validation,forms,ip
You can pass the request object to the form/model code that is being called: this will then provide access to request.META['REMOTE_ADDR']. Alternatively, just pass that in.
0
0
0
0
2010-12-18T03:19:00.000
3
0.066568
false
4,476,430
0
0
1
2
I know how to get it in views.py.... request.META['REMOTE_ADDR'] However, how do I get it in models.py when one of my forms is being validateD?
Inside Django's models.py, if I am validating a form, how do I get the user's IP?
4,476,456
0
0
179
0
python,django,validation,forms,ip
If you are validating at form level or at model level, both instances know nothing about the HTTP request (where the client IP info is stored). I can think of two options: Validate at the view level where you can insert errors into the form error list. You can put the user IP (may be encrypted) in a hidden field at your form.
0
0
0
0
2010-12-18T03:19:00.000
3
0
false
4,476,430
0
0
1
2
I know how to get it in views.py.... request.META['REMOTE_ADDR'] However, how do I get it in models.py when one of my forms is being validateD?
django shared library/classes
4,480,885
0
13
9,474
0
python,django
Wherever you want, you can import them if they are in the PYTHON_PATH.
0
0
0
0
2010-12-18T20:06:00.000
4
0
false
4,479,901
1
0
1
1
Am new to django and was looking for advice where to place my shared library. Am planning on creating classes that I want to use across all my apps within the project. Where would be the best location to place them? e.x abstract models regards,
How to encrypt my data on the server side using django
4,483,185
0
1
1,120
0
javascript,jquery,python,django
If you use javascript obfuscator chances are high it might be cracked, obfuscation is not encryption. You should hash the conten on the serverside using md5. Can you be more clear and specific in the question?
0
0
0
0
2010-12-19T06:50:00.000
2
0
false
4,481,944
0
0
1
1
This is my demand: User content is ultimately stored on the server side, but the preservation of data is encrypted Server side, that is, site technical staff, can not have any way to decrypt the contents of the user, as the user's password as stored on the server side is a long list of md5 encrypted characters. For encryption, we can temporarily consider only the text The same as the password I want to process the data, but these data need to output to the user, so i have to decrypt the data on the client-side , what can i do , thanks updated: if i use javascript obfuscator on my javascript data , How much chance to be cracked by somebody .
Deploy python application
4,485,440
1
1
318
1
python,client-server,rich-internet-application
If possible, make the application run without any installation procedure, and provide it on a network share (e.g. with a fixed UNC path). You didn't specify the client operating system: if it's Windows, create an MSI that sets up something in the start menu that will still make the application launch from the network share. With that approach, updates will be as simple as replacing the files on the file server - yet it will always run on the client.
0
0
0
0
2010-12-19T22:13:00.000
1
0.197375
false
4,485,404
0
0
1
1
I am developing an application for managers that might be used in a large organisation. The app is improved and extended step by step on a frequent (irregular) basis. The app will have SQL connections to several databases and has a complex GUI. What would you advise to deploy the app ? Based on my current (limited) knowledge of apps in lager organisations I prefer a setup where the app runs on a server and the user uses a thin client via the web. I prefer not to use a webbrowser because of (possible)limitations of the user GUI. The user experience should be as if the app was running on his own laptop/pc/tablet(?) What opensource solution would you advise ? Thanks !
web application firewall development
4,486,208
1
3
3,881
0
python,security,activemq,mod-security,apache-modules
Django is a web application framework. I don't see anyone writing a firewall implementation using it.
0
0
0
0
2010-12-20T01:19:00.000
5
0.039979
false
4,486,178
0
0
1
4
I have an assignment to develop a web application firewall. I have been researching for some source codes about that.My main source was ModSecurity. Main question is that: -Which framework or programming language I can use, to develop a web application firewall? Which one would be the most useful? -Can I use Django & Python? It would be a starting point for the project research.
web application firewall development
4,486,453
3
3
3,881
0
python,security,activemq,mod-security,apache-modules
OK, so my guess was basically correct, although I thought it was protecting an app with no or bad security, but it's more about protecting against attacks. In that Case, Django is definitely wrong. It's clearly doable in Python, but don't expect to be able to handle 100.000 requests per second. :) But if it's research and development, I think Python can be a great choice, as it's fast to develop in, and with tools like Cython it can be quite fast to run as well. Should you then end up making a finished product that does need extreme performance, you can take the algorithms and translate them to C/C++. I'd look into Twisted in your case. That may be the correct solution. "It will be used on the server side to control the user transactions via HTTP." Most web application frameworks have security settings. These are usually not called "firewalls", and you didn't answer my questions, so I'm going to guess here: You are writing a web proxy that will act to filter out requests which do not have the correct permission because there is an application which does not have any access control at all. Is this correct? Yes, you can do that in Python. Django is probably not the correct solution. If you need to implement access control with login pages and user management, then you probably want SQL and templating and a lightweight Python framework could be helpful. Otherwise Twisted or just doing it with the functionality in standard lib might be the correct solution.
0
0
0
0
2010-12-20T01:19:00.000
5
1.2
true
4,486,178
0
0
1
4
I have an assignment to develop a web application firewall. I have been researching for some source codes about that.My main source was ModSecurity. Main question is that: -Which framework or programming language I can use, to develop a web application firewall? Which one would be the most useful? -Can I use Django & Python? It would be a starting point for the project research.