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
Custom logs in AppEngine
8,844,141
2
2
228
0
python,google-app-engine,logging
Your best option is to store this data in the datastore. If you're concerned about latency, you can either use asynchronous operations, and start the write as soon as possible, or you can use the task queue to do the writes offline.
0
1
0
0
2012-01-12T16:08:00.000
2
0.197375
false
8,838,243
0
0
1
2
I have an application for which I would like to record some statistics for later analysis but which are not at all needed within the application itself. i.e. The data will never need to be read by the application. Whatever system is used for storing these statistics, I just need to be able to take periodic dumps of the data. I could use the logging built into AppEngine, but then it will display in the application logs. I would like to keep the application logs for debugging the application without having to see other custom information every time I check them. How would you do this? Edit: More details on the stats. Each time a user completed a particular task (1-3 times a day) we need to store details about that task. Such as time and order of events. These would be stored in a single string per session - 1-2kB.
appengine datastore - filter by string or integer
8,844,099
2
1
276
0
python,google-app-engine,google-cloud-datastore
Practically speaking, no. Any difference in the efficiency of comparing different datatypes is insignificant compared to disk access times.
0
1
0
0
2012-01-12T19:20:00.000
1
1.2
true
8,840,999
0
0
1
1
Will a query with a filter over IntegerProperty perform any better than a query with a filter over String Property? (same indexes)
Browser charsets order of precedence
8,841,681
2
1
114
0
python,html,character-encoding
The request header Accept-Charset (which may get mapped to HTTP_ACCEPT_CHARSET server-side) expresses the client’s preferences, to be used when the server is capable to serving the resource in different encodings. The server may ignore it, and often will. If your page is UTF-8 encoded and declared as such, then any form on your page will send its data as UTF-8 encoded, unless you specify an accept-charset attribute. So if a browser posts data as ISO-8859-1 encoded, then this is a browser bug. However, this would need to be analyzed before drawing conclusions. There’s an ald technique of including some special character, written using a character reference for safety, as the value of a hidden field. The server-side handler can then pick up the value of this field and detect an encoding mismatch, or even to heuristically deduce the actual encoding from the encoded form of the special character.
0
0
1
0
2012-01-12T19:38:00.000
2
1.2
true
8,841,227
0
0
1
1
Client browsers are sending the header HTTP_ACCEPT_CHARSET: ISO-8859-1,utf-8;q=0.7,*;q=0.3. I only serve webpages as utf8 with the correct header but browsers are posting data from forms encoded with the ISO-8859-1 charset. My question is, will a browser always prefer charsets in the order of its ACCEPT_CHARSET header so I can reliably write a middleware that will decode any posted data with the first entry, in this case ISO-8859-1, and encode it as utf8. UPDATE: I updated the form tag with accept-charset="utf-8" and I'm still seeing non-unicode characters appearing. Is it possible that a user copy/pasting their password from somewhere else (lastpass, excel file) could be injecting non-unicode characters?
Is learning Django without initial knowledge of Python possible?
8,841,829
2
4
7,541
0
python,django
I would suggest it's possible, but definitely steepens the learning curve. When learning a new language, I usually enjoy using it to actually do something useful rather than just writing Hello World programs. Learning Django while learning Python at the same time might be a good way to do this. I did learn Ruby at the same time as I learned Rails, and I did find myself having to lookup basic Ruby syntax every 30 seconds, but I eventually got the hang of it. I found that looking at some of the weird Rails constructs pushed me into having to learn various Ruby features that I might have not run into on my own as well, so that was an advantage. I would say give it a shot, and if you find the whole thing overwhelming, then back off a bit and focus on some command line scripts or other simple programs.
0
0
0
0
2012-01-12T20:19:00.000
5
0.07983
false
8,841,705
0
0
1
5
I am coming from procedural PHP with fair amount of knowledge on it. I want to learn Django but I don't have initial knowledge of Python. Can I learn Django at the same time also learning Python? Thank you so much!
Is learning Django without initial knowledge of Python possible?
8,841,861
1
4
7,541
0
python,django
Short answer: no. Long answer: Learning a framework for a particular language is essentially taking the basic syntax with its nuances, and adding a new level of complexity to it. You're coming from a different language with a different semantic structure, so you would require time to both understand what Python's doing, and how it's doing it with Django.
0
0
0
0
2012-01-12T20:19:00.000
5
0.039979
false
8,841,705
0
0
1
5
I am coming from procedural PHP with fair amount of knowledge on it. I want to learn Django but I don't have initial knowledge of Python. Can I learn Django at the same time also learning Python? Thank you so much!
Is learning Django without initial knowledge of Python possible?
25,205,713
0
4
7,541
0
python,django
Learning Python through Django is like learning PHP through wordpress. You will learn python, but Django is it's own beast. If you are experienced in another language or web programming then you will be fine jumping into Django. If this is your first language then you need to learn basic python first. I also recommend something lighter like Flask to start with as you will use more raw python and learn to setup your own scaffold and folder structure which will help you understand Django behind the scenes.
0
0
0
0
2012-01-12T20:19:00.000
5
0
false
8,841,705
0
0
1
5
I am coming from procedural PHP with fair amount of knowledge on it. I want to learn Django but I don't have initial knowledge of Python. Can I learn Django at the same time also learning Python? Thank you so much!
Is learning Django without initial knowledge of Python possible?
8,842,267
6
4
7,541
0
python,django
Yes! It's called 'immersion.' You learn Spanish by speaking Spanish. You learn Python by writing Python. Having a concrete project ("I'm going to make webapp that does xyz in Django") in mind gives you something to work on and towards. If you have the time and the determination to stick with it, and useful resources at your disposal (google, SO, docs), this is a great way to learn. It helps to be a certain type of person (stubborn, willful, patient).
0
0
0
0
2012-01-12T20:19:00.000
5
1
false
8,841,705
0
0
1
5
I am coming from procedural PHP with fair amount of knowledge on it. I want to learn Django but I don't have initial knowledge of Python. Can I learn Django at the same time also learning Python? Thank you so much!
Is learning Django without initial knowledge of Python possible?
8,841,721
11
4
7,541
0
python,django
No. You'll be writing Python code. In Python. You'll have to learn Python. A little bit of your project will be CSS, JavaScript and HTML with template tags inserted. Most of your project will be Python.
0
0
0
0
2012-01-12T20:19:00.000
5
1.2
true
8,841,705
0
0
1
5
I am coming from procedural PHP with fair amount of knowledge on it. I want to learn Django but I don't have initial knowledge of Python. Can I learn Django at the same time also learning Python? Thank you so much!
Google App Engine Go-Python/Java hybrid application
8,847,345
5
1
469
0
java,python,google-app-engine,go,hybrid
You can deploy several "versions" of the same application at once. Each version will be accessible using a fully qualified URL, and they can all be in different languages.
0
1
0
0
2012-01-13T07:31:00.000
1
1.2
true
8,847,266
0
0
1
1
Can one write a hybrid Go-Python/Java application and run it on Google App Engine as one application, or do they need to be split into two apps and communicate with each other through HTTP calls? Is there any tutorial or example on something like this being done?
Python in Desktop Application Development
8,848,472
4
15
14,031
0
java,python,desktop-application
It is entirely possible to build a SWING GUI application with Python. Look for Jython, which is Python for the JVM. Any pure Python (no compiled C code) libraries for Python will work with Jython including most of the Python standard libraries. Also, because Jython is a JVM language, it has access to objects provided by Java libraries such as SWING, and also can use the JVM threading model. Multithreading in plain Python is difficult due to the Global Interpreter Lock. Jython does not have that limitation. If other people in the company are leaning towards Java, then Jython with SWING would be a safer choice because when people say that you should have used Java because Cool Library X is available, you just smile and say that Jython can also leverage Cool Library X because Jython is a JVM language.
0
0
0
0
2012-01-13T09:21:00.000
2
0.379949
false
8,848,285
0
0
1
1
My company is revamping the IT infrastructure and systems, so we are at the middle of finalizing the technology for developing the new system. We have come to two candidates; Java & Python. The main criteria of the choice is the language must be complete; in a sense that it must be able to use for web & desktop applications development. Java is proven is this field, with many good web framework (JSF, Hibernate, etc) and relatively good GUI library (SWT, Swing). However, Python looks more delicious as from my personal experience, development in Python is efficient, I could do more with less time (I only have experience in web development with Django). However, as for the desktop application, I have yet find any good GUI library that comes integrated with the IDE as Swing. Can someone points me the best if possible GUI framework for desktop application for Python?
Django. Edit model form in popup in admin
9,381,961
8
2
8,165
0
python,django,django-admin
If you want to open a popup, simply create a link to your 'add' view with the following attribute on that link onclick='return showAddAnotherPopup(this);'
0
0
0
0
2012-01-13T12:02:00.000
2
1.2
true
8,850,273
0
0
1
1
Is there any ready apps for django admin, that allows to edit model in popup? I want next functionallity: View edit form for model in popup. On model save - update row in list of models. Motivation: reduce page reloads. Also, if there any solutions oriented on massive manual data updates for django? I've taken a look at django grappelli - it improves view of data, but edit data is still not usable. P.S.: If such kind of app is not available - I'll start open source project.
How can I use the mongolab add-on to Heroku from python?
8,859,701
4
3
6,640
0
python,mongodb,heroku,mlab
Get the connection string settings by running heroku config on the command line after installed the add-on to your heroku app. There will be an entry with the key MONGOLAB_URI in this form: MONGOLAB_URI => mongodb://user:[email protected]:27707/db Simply the info from the uri in python by creating a connection from the uri string.
0
0
0
1
2012-01-14T01:57:00.000
5
0.158649
false
8,859,532
0
0
1
1
The documentation only talks about how to do it from ruby.
Jinja nested rendering on variable content
16,856,530
2
9
9,958
0
python,jinja2
I thought of an interesting way to do this: Set up a dictionary Wrap a DictLoader around it (but keep a reference to the dictionary around) Pass a ChainLoader with the DictLoader and your normal Loader to the environment Implement a custom filter that adds its parameters to the aforementioned dictionary Use the include directive to call the template code in the current context Haven't tried it, but it just might work!
0
0
0
0
2012-01-14T14:13:00.000
7
0.057081
false
8,862,731
0
0
1
1
Say I have actual jinja template code in a variable X. Let us say the content of X is "{{ some_other_variable }}". How can I display X while also rendering its content? e.g., this does not work: {{ X }} As it simply renders this to screen "{{ some_other_variable }}" rather than the contents of some_other_variable. The reason I'm doing it this way is that I have a site in which (trusted) users can create posts which themselves may contain jinja template code. The view page displays these posts, but due to the above problem, renders them directly, rather than substituting variables as I'd like.
Django - saving fields in invalid form submissions
8,869,942
1
2
739
0
python,django,django-forms
You will need to provide your own clean method to deal with the non-validating fields, and prevent cleaned_data being clobbered. You will need to also provide your own save method which knows to only save the right fields.
0
0
0
0
2012-01-15T13:21:00.000
1
1.2
true
8,869,918
0
0
1
1
What is the recommended way of handling a "save"-style form submission (created from a ModelForm) when: A non-empty subset of the form's fields validate A non-empty subset of the form's fields do not validate I want to save the subset of fields that are valid to the instance in question, and not the invalid ones. I'm fairly sure I could write the code to do this but as with much of Django I'm sure there's a "normal"/"recommended" way of solving this, or some pattern I can follow. All advice much appreciated.
Is there RequestHandler an equivalent of finalize() call for python?
8,875,514
1
1
88
0
python,google-app-engine
You could override __del__, but this is dangerous (can introduce GC loops and uncollectable objects), and doesn't gain you anything. You don't gain anything because the App Engine runtime does not return the response to the user until the WSGI application has returned, which does not happen until all user code has finished executing. Likewise, threads on a frontend cannot run longer than the scope of the request for which they were created. If you want to do work outside the scope of a request, you should use the Task Queue.
0
0
0
0
2012-01-16T00:18:00.000
1
1.2
true
8,874,580
0
0
1
1
webapp.RequestHandler based Handlers can override initialize () to carry out setup. Is there a similar finalize() ? Could I override del() to achieve this ? Basically, I am looking to making some journal entries after the post/get functions have completed such that this is not in the critical path of the Response back to the browser.. I could either (1) do this in this 'finalize' call assuming it is called after the Response is flushed to the browser or (2) push the work on a separate thread-pool-queue. If there is a way to do former, that would be a lot easier/simpler. Thanks.
Django RSS-feed escaping €
8,880,484
5
2
196
0
python,django,rss,escaping
€ is a perfectly valid utf-8 character. You are almost certainly creating utf-8 output, therefore it doesn't need escaping.
0
0
0
0
2012-01-16T12:37:00.000
1
1.2
true
8,880,138
0
0
1
1
I've made a rss-feed in django and i wish to turn € into €. I already use |escape to escape link tags and such. But somehow |escape doesn't work on €. Does anybody now a way to also escape € ?
PyCharm: Forcing Django Template Syntax Highligting
8,880,818
56
32
8,350
0
python,django,pycharm
File » Settings » Template language, do you have Template language setting set to django?
0
0
0
0
2012-01-16T13:26:00.000
1
1.2
true
8,880,652
0
0
1
1
I've just installed PyCharm, and have opened an existing project with multiple apps. When I open django templates, they are highlighted as if plain HTML, i.e. {% block %} elements and {{variable}} references are not treated specially. Is there any way I can force it to use the django template syntax highlighter for these files? Or am I doing something wrong? The project is configured as a django project.
Choosing Python/SQLObject webframework
8,896,107
0
0
375
1
python,sqlobject
Try the pyramid, it does not impose anything you like as opposed to Django. And has a wealth of features for building Web applications at any level.
0
0
0
0
2012-01-17T14:05:00.000
2
0
false
8,895,942
0
0
1
1
I have a regular desktop application which is written in Python/GTK and SQLObject as ORM. My goal is to create a webinterface where a user can login and sync/edit the database. My application is split up in different modules, so the database and gtk code are completly separate, so I would like to run the same database code on the webserver too. So, I would like to know if there's a webframework which could handle these criteria: User authentication Use my own database code/SQLObject Some widgets to build a basic ui This would be my first webproject, so I'm a bit confused by all searchresults. CherryPy, Turbogears, web2py, Pyramid? I would be happy if someone could give me some pointers what would be a good framework in my situation.
Simple and effective solution for combining Java, Python, PyTables and HDF5
8,904,389
3
2
1,638
0
java,python,jython,hdf5,pytables
For me is not cool writing scripts from Java using java.io.*. Same here -- you have already parsed the data from the XML into some internal representation in Java, and then you re-write this data into a Python script, and then the Python interpreter will re-parse the data into an internal representation for writing to the HDF5 files. It couples together both the Java XML parsing interface, the XML data format, and the Python APIs for manipulating HDF5 files, which sounds like more moving parts than there ought to be. (Do you really want to break out javac just to update a renamed Python package?) I think it'd be worth taking another step backwards and look at the two steps of the problem: parse XML write HDF5 There's no reason why there should be two languages between those -- I'd stick entirely with Java or entirely with Python. The end result will run faster in less memory on more systems and be more maintainable regardless of which language you choose.
0
0
0
0
2012-01-18T02:12:00.000
2
0.291313
false
8,904,318
0
0
1
1
I'm a newbie in Python, PyTables and HDF5. I'm looking for simple and best solution for my problem. Problem is next. On one side I have many XML files with data. I just wanna parse these files and put data in hdf5 file on other side. Later, I will use this data trough some search criteria.Why HDF5? Because need to put large dataset and because speed. Using RDBMS will make problems with performance during JOIN operations. Solution must provide speed and good memory performance. After some googling I find Python and PyTables as possible solution. My idea is parse data from XML in Java (this code must be writen in Java), after that write python script which insert data in hdf5 using PyTables API and executing python script from Java. So, I'm writing and executing python script from Java program. For writing python script in Java I'm using java.io.* package and for executing Process class in Java. For example: p.exec("cmd /c C:\MyScripts\myscript.py") I don't know is this solution good. For me is not cool writing scripts from Java using java.io.*. Probably, I will have problems later with reading results from scripts ( when I make some search criteria using Python scripts and PyTables API). So, I have few questions about my problem. What is the best solution between parsing XML data on one side and store data in hdf5 on other side? Am I on right way with this solution (writing and executing python scripts from Java code)? What about Python and PyTables? Are these technologies good solution for my problem? Also I read couple things about Jython, but I don't know is it possible combine it with PyTables? Opinion and tips from professionals are welcome. Thanks for helping.
Rendering a page after jQuery POST
8,906,825
5
0
376
0
javascript,jquery,python,web.py
Don't use Ajax to do this. If posting data to the server should result in a new page being displayed, just use the traditional model. You gain nothing by using Ajax in this case.
0
0
0
0
2012-01-18T07:44:00.000
2
1.2
true
8,906,766
0
0
1
2
I have a problem with web.py. Basically the user clicks a button, which makes a POST request to the server. The POST request returns "render.edit()", which is short hand for rendering the "edit" template. However, since I'm making the POST request via jQuery, the HTML of the page is simply in the callback function and doesn't get displayed. Is there a way for me to change the HTML of the entire page? Thanks!
Rendering a page after jQuery POST
8,924,998
0
0
376
0
javascript,jquery,python,web.py
you can also try raise web.seeother('URL') inside the POST of python script, but in this case it will also run all GET instructions of the class.
0
0
0
0
2012-01-18T07:44:00.000
2
0
false
8,906,766
0
0
1
2
I have a problem with web.py. Basically the user clicks a button, which makes a POST request to the server. The POST request returns "render.edit()", which is short hand for rendering the "edit" template. However, since I'm making the POST request via jQuery, the HTML of the page is simply in the callback function and doesn't get displayed. Is there a way for me to change the HTML of the entire page? Thanks!
How I can request a local url in my app engine application?
8,915,133
2
1
165
0
python,json,google-app-engine,url,blob
This wouldn't on the development server (but will work on the production server) because its single threaded and you can't do a request to yourself from within a request. There are several workarounds for your issue: Use the file write API to store the data. Use the multithread dev_server (required to switch to python 2.7 + HRD) Store the file asynchronously using queues or deferred.
0
1
0
0
2012-01-18T18:04:00.000
2
0.197375
false
8,915,042
0
0
1
1
I am using Blobs to store json files for my application. What I am trying to achieve is to request an internal url of my application in order to get the relevant file. I have tried urllib, urllib2, urlfetch but every time I am getting a 5 second DeadlineExceededError: 5 timed out error. Is there a way to retrieve my blob in my get request or an alternative for retrieving my data?
Reportlab can't find _imaging module using production server
8,930,498
2
0
847
0
python,django,python-imaging-library,reportlab
PIL should be installed before library which uses it. I got similar problem with libimaging - PIL wasn't installed before libimaging so libimaging was compiled without it. Solution was uninstall libimaging and install it again with PIL already present in system.
0
0
0
0
2012-01-19T16:32:00.000
2
0.197375
false
8,929,695
0
0
1
1
I'm trying to push a django app to the production server, but for some reason it fails and says: ImportError: The _imaging C module is not installed The weird part is that when I use the development server on the same machine, it works just fine. PIL is installed, and I can import the _imaging module by hand in the shell. The production server uses Apache. Any ideas? Traceback (most recent call last): File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 111, in get_response response = callback(request, *callback_args, **callback_kwargs) File "C:/portal2\compliance\views.py", line 91, in show_statement doc.build(Story, onFirstPage=firstPage, onLaterPages=otherPage) File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 1117, in build BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker) File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 877, in build self.clean_hanging() File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 510, in clean_hanging self.handle_flowable(self._hanging) File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 757, in handle_flowable f.apply(self) File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 140, in apply getattr(doc,arn)(*args) File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 1093, in handle_pageBegin self._handle_pageBegin() File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 535, in handle_pageBegin self.pageTemplate.onPage(self.canv,self) File "C:/portal2\compliance\views.py", line 55, in firstPage canvas.drawImage(img,0,0,8.5*inch,11*inch) File "C:\Python27\lib\site-packages\reportlab\pdfgen\canvas.py", line 857, in drawImage imgObj = pdfdoc.PDFImageXObject(name, image, mask=mask) File "C:\Python27\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 2094, in init self.loadImageFromA85(src) File "C:\Python27\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 2100, in loadImageFromA85 imagedata = map(string.strip,pdfutils.makeA85Image(source,IMG=IMG)) File "C:\Python27\lib\site-packages\reportlab\pdfbase\pdfutils.py", line 34, in makeA85Image raw = img.getRGBData() File "C:\Python27\lib\site-packages\reportlab\lib\utils.py", line 658, in getRGBData annotateException('\nidentity=%s'%self.identity()) File "C:\Python27\lib\site-packages\reportlab\lib\utils.py", line 655, in getRGBData self._data = im.tostring() File "C:\Python27\lib\site-packages\PIL\Image.py", line 532, in tostring self.load() File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 164, in load self.load_prepare() File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 231, in load_prepare self.im = Image.core.new(self.mode, self.size) File "C:\Python27\lib\site-packages\PIL\Image.py", line 37, in getattr raise ImportError("The _imaging C module is not installed") ImportError: The _imaging C module is not installed identity=[ImageReader@0x4517a30 filename='C:\portal2\pdf\Certification_fullframe.tif'] handle_pageBegin args=()
Trigger Javascript event on remote website with Python
8,943,959
2
3
2,574
0
javascript,python,dom,web-scraping
Figure out the AJAX request URL and request it directly. :-)
0
0
1
0
2012-01-20T05:38:00.000
1
1.2
true
8,937,190
0
0
1
1
I wrote some basic Python code to scrape a remote webpage and grab a few pieces of data. On a different page I'm trying to scrape, the data is hidden from view, and only appears after changing the value of a <select> box. After de-minifying and digging through the remote website's javascript, I confirmed that it is using AJAX (custom implementation of Prototype I think) to switch the <tbody> of the <table> I'm interested in scraping. Is there a way to use Python (or Javascript via Python) to trigger the onChange event of that select box so I can "refresh" the DOM and grab the new HTML?
python appengine memcache optimization
8,980,637
1
0
259
0
python,google-app-engine,memcached,djangoappengine
Cache everything that might be frequent, and let Memcache's LRU policy evict items that aren't accessed frequently enough to warrant remaining in the cache.
0
1
0
0
2012-01-20T12:05:00.000
2
0.099668
false
8,941,192
0
0
1
1
I am developing an api on google appengine django nonrel that will serve a lot of requests. I would like to cache repeated requests. It is estimated that there will be some really frequent queries to the api, and I would like to be able to find out what these queries are on the fly so that I may pre-cache them. Is there a way of getting the most frequent memcache keys?
Django post initialization modules
8,957,923
2
0
74
0
python,django
Probably, the best place for this is the end of the settings.py ;-)
0
0
0
0
2012-01-21T23:42:00.000
1
0.379949
false
8,957,711
0
0
1
1
Is there a way that I can call some functions/modules right after all the settings in Django have been imported?
How do I learn Python 2 if I already know Python 3?
8,965,225
5
7
501
0
python,django,python-3.x,python-2.x
If you already are familiar with Python 3, then there are almost no differences you will have to worry about when coding in Python 2. The most user-visible differences have to do with details of the print statement, which you probably won't be using for Django anyway. So, just write code, and ask about any specific problems you might encounter.
0
0
0
0
2012-01-22T22:01:00.000
5
0.197375
false
8,965,120
1
0
1
1
I have some knowledge of Python 3 (I'm not a beginner, but I'm not an expert). I'm interested in web development, so I want to use Django. What are the differences between the two versions of Python? How should I switch from 3 to 2.x?
Using Regex to Search for HTML links near keywords
8,966,597
0
4
366
0
python,regex,negative-lookahead
I don't think you can do this one with regex alone (especially looking before the keyword match) as it has no sense of comparing distances. I think you're best off doing something like this: find all occurences of sales & get substring index, called salesIndex find all occurences of https?://[-A-Za-z0-9./]+ and get the substring index, called urlIndex loop through salesIndex. For each location i in salesIndex, find the urlIndex closest. Depending on how you want to judge "closest" you may need to get the start and end indices of the sales and http... occurences to compare. i.e., find the end index of a URL that is closest to the start index of the current occurence of sales, and find the start index of a URL that is closest to the end index of the current occurence of sales, and pick the one that is closer. You can use matches = re.finditer(pattern,string,re.IGNORECASE) to get a list of matches, and then match.span() to get the start/end substring indices for each match in matches.
0
0
1
0
2012-01-23T01:05:00.000
4
0
false
8,966,244
0
0
1
1
If I'm looking for the keyword "sales" and I want to get the nearest "http://www.somewebsite.com" even if there is multiple links in the file. I want the nearest link not the first link. This means I need to search for the link that comes just before the keyword match. This doesn't work... regex = (http|https)://[-A-Za-z0-9./]+.*(?!((http|https)://[-A-Za-z0-9./]+))sales sales Whats the best way to find a link that is closest to a keyword?
How do you restrict large file uploads in wsgi?
8,975,702
3
5
1,729
0
python,http,wsgi,webob
It would depend on your front-end server. If it has any configuration to block big request even before it goes into your app, use it. If you want to block this with your code I see two approaches: Look ate the Content-Length HTTP Header. If it's bigger than you can handle, deny the request right away. Don't trust the headers and start reading the request body, until you reach your limit. Note that this is not a very clever way, but could work. =) Trusting the HTTP header could lead you to some problems. Supose some one send a request with a Content-Length: 1024 but sends a 1GB request body. If your front-end server trusts the header, it will start do read this request and would find out later that the request body is actually much bigger that it should be. This situation could still fill your server disk, even being a request that "passes" the "too big check". Although this could happen, I think trusting the Header would be a good start point.
0
0
0
0
2012-01-23T11:12:00.000
2
1.2
true
8,970,713
0
0
1
1
I'm trying to get an understanding of the best way of handling file uploads safely in a wsgi app. It seems a lot of solutions involve using FieldStorage from the cgi module to parse form data. From what I understand about FieldStorage it performs a bit of 'magic' behind the scenes by streaming data into a tempfile. What I'm not 100% clear on is how to restrict a request containing a file greater than a specified amount (say 10MB). If someone uploads a file which is several GB in size you obviously want to block the request before it chews through your server's disk space right? What is the best way to restrict file uploads in a wsgi application?
url-enabled access to ressources with pyramid
8,973,728
2
0
88
0
python,session,authorization,pyramid
If you've figured out how to do this for authenticated users, it should be obvious how to do it for anonymous users as well. They will have the pyramid.security.Everyone principal, which you can use in your ACLs to assign various permissions. Route factories will allow you to assign custom ACLs to individual routes. They simply override the default root factory on the Configurator.
0
0
0
1
2012-01-23T11:47:00.000
1
1.2
true
8,971,115
0
0
1
1
I'm setting up a pyramid application where access to ressources can be shared across registered users. I would also like to give access to non-members, using non-trivial links to files or directories. While I see how to do this for registered members, I'm not sure how to do this with anonymous users. Do I need to create an unprotected view and perform security checks myself ? Maybe a better way would be to append access rights to users sessions using cookies? Can route factories help me for this purpose? Any other way?
App Engine Blobstore download all blobs at once
8,981,549
5
2
578
0
python,google-app-engine,blobstore
No, there's no way to do this. The blobstore can be aribrarily large, far larger than is practical to download in a single file.
0
1
0
0
2012-01-24T01:42:00.000
4
0.244919
false
8,981,103
0
0
1
3
I would like to download all blobs as a single zipped file (or another way) to my computer. Anyway to do that? I use the python SDK.
App Engine Blobstore download all blobs at once
8,993,546
1
2
578
0
python,google-app-engine,blobstore
It's probably better to download them one at a time anyway. That way if your job dies part way through you can restart for where it failed rather than starting over again from scratch.
0
1
0
0
2012-01-24T01:42:00.000
4
0.049958
false
8,981,103
0
0
1
3
I would like to download all blobs as a single zipped file (or another way) to my computer. Anyway to do that? I use the python SDK.
App Engine Blobstore download all blobs at once
9,376,684
-1
2
578
0
python,google-app-engine,blobstore
How about copy the blobs to google storage and then use gsutil to download the blobs from there?
0
1
0
0
2012-01-24T01:42:00.000
4
-0.049958
false
8,981,103
0
0
1
3
I would like to download all blobs as a single zipped file (or another way) to my computer. Anyway to do that? I use the python SDK.
Parser for command line parameters in Java/C/C++/Python/shell
8,993,917
1
4
393
0
java,python,c,parsing,command-line
getopt is also usable in Python and shell. Python has the argparse module, which is much easier to use (particularly for more complex argument parsing), but if you want consistency across all those languages, I don't know of any better option than getopt. If Java doesn't have a getopt implementation, you could possibly write one yourself without too much effort.
0
1
0
1
2012-01-24T18:31:00.000
1
1.2
true
8,992,077
0
0
1
1
I am looking for a library to parse command-line parameters that would work identically in Java, C/C++, Python and (preferably) shell. By "identical" I mean (1) have exactly the same rules for parsing of the parameters in all three languages, (2) use the same configuration files or have similar API to specify the parameters, (3) have similar APIs to access the values of the parameters. I've always used getopt in C and Apache CLI in Java but it would be nice to use the same specification for the parameters across multiple languages.
General : always saving settings on close vs saving only when changed
9,001,676
1
1
84
0
python,coding-style
I don't think this is even python related. In general you'll have something like this: Load settings from file Use and maybe modify settings in memory. Write settings to file. Detecting a settings modification would either introduce a change in 2 (keep a "changed" state) or in 3 (diff with the current persisted settings). The first solution has little overhead (could be one boolean) but it is overhead nonetheless and it is in the "active" state of your program (not startup/shutdown). Also, it is additional logic that could go wrong (accidentally resetting the boolean to false on a copy for example). The second solution has large overhead because you have to load a file, diff all the settings. This would actually slow down your code significantly compared to a simple "overwrite". In the end you do all that work just to save one file write at shutdown, which is usually not the most time critical part of your application. If nothing changes you'll just rewrite the same file. So I would not do it unless either storing a file is terribly complicated/slow or you really do not want things like "modify time" of the file changed unless you actually changed the settings. But these circumstances seem rather exceptional to me.
0
0
0
0
2012-01-25T10:49:00.000
2
0.099668
false
9,001,434
1
0
1
1
I am kind of beta testing a small python app - whenever the app is closed the settings are saved, even when I made no changes. I was wondering if this is general practice - sounds like settings should be saved only when a change is made but are there reasons (apart from the reduced complexity) pro saving settings always on close ?
What's a good strategy for generating unique hash keys for a very large collection of images in Python?
9,008,635
-1
1
2,116
0
python,hash,unique,key
MD5 of datetime.now() (at a time of file upload) will be OK, imho.
0
0
0
0
2012-01-25T18:55:00.000
3
-0.066568
false
9,008,502
0
0
1
1
I have a listing of millions of files and am uploading them to Amazon's S3. I need to create unique keys for each of the images. I'd rather not use md5 because it requires scanning the entire file, which can be slow. Additionally, there could be duplicate images, which is allowed in our application. Any suggestion for quickly generating an almost guaranteed to be unique key? Preferably, 32-characters alpha numeric (can be case sensitive). Thanks!
Django project loads in site-packages
9,020,680
0
0
290
0
python,django,django-templates,setup.py
Either you chose a name for your project that conflicts with an existing python package and it's merely coincidental, or you somehow managed to build your project as an egg. I'm not sure how you would do that and not realize you had done that, though. Regardless, check the package to make sure that it is in fact your code and not some other python package. If it's not your code, change your project name to avoid the conflict. If it is your code, you can simply remove the egg from your 'site-packages' directory. You may have to sudo, though.
0
0
0
0
2012-01-26T15:34:00.000
1
0
false
9,020,589
0
0
1
1
After I run setup.py to install a project, the project admin works fine but here's the problem. Except of the project running from my c:\project. It's runs from another location at C:\Python27\Lib\site-packages\project-0.1-py2.7.egg\project Why does it clone my project to the site-packages location? And why does it run from that location instead of my c:/project? The funny thing is I was able to do a "runserver" from c:\project yet it loads in the site-packages location. Can anyone help? thanks.
How to create columns in a csv file and insert row under them in python scrapy
9,144,538
0
0
506
0
python,scrapy
1)you can use custom Csv feed exporter each item key will be treated as a column heading and value as column value. 2) you can write a pipeline that can write data in csv file using python csv lib.
0
0
0
0
2012-01-27T09:01:00.000
2
0
false
9,030,953
0
1
1
2
Please help me in creating columns and inserting rows under them in a csv file using python scrapy. I need to write scraped data into 3 columns. So first of all three columns are to be created and then data is to be entered in each row.
How to create columns in a csv file and insert row under them in python scrapy
9,032,800
1
0
506
0
python,scrapy
CSV is a Comma Saparated Values format. That basically means that it is a text file with some strings separated by commas and line-downs. Each line down creates a row and each comma creates a column in that row. I guess the simplest way to create a CSV file would be to create a Pythonic dict where each key is a column and the value for each column is a list of rows where None stands for the obvious lack of value. You can then fill in your dict by appending values to the requested column (thus adding a row) and then easily transform the dict into a CSV file by iterating over list indexes and for each column either add a VALUE, entry in the file or a , entry for index-out-of-bound or a None value for the corresponding list. For each row add a line down.
0
0
0
0
2012-01-27T09:01:00.000
2
0.099668
false
9,030,953
0
1
1
2
Please help me in creating columns and inserting rows under them in a csv file using python scrapy. I need to write scraped data into 3 columns. So first of all three columns are to be created and then data is to be entered in each row.
How to import a java class i created in jython and call a method
9,047,483
3
2
5,286
0
java,python,jython
Jython supports loading Java classes as if they were Python modules. It searches the directories in sys.path for .class files. First, make sure your Java class has already been compiled with javac. Then, do a sys.path.append(d), where d is the directory containing the package. So if your class says package foo.bar; at the top, and resides at mydir/foo/bar/myclass.java, then you must have mydir in sys.path (NOT one of the subdirs of mydir). Finally, import the class via something like from foo.bar import myclass. The names between must match up between Python and Java! You'll be doing "from [package] import [class]".
0
0
0
0
2012-01-27T18:52:00.000
2
1.2
true
9,038,505
1
0
1
1
I have made a java class that calls other java classes and then prints to a screen. i am trying to build a python interface that calls my java class, runs the one method within it, and terminates. i cannot get access to my method. i have used the line "import directory.directory2.myClass.java (and .jar and .class) i made the .jar file from both the raw code and from the .class file. none of these seem to be working. i set sys.path.append to point to the directory where the java files are. Do i need to convert my java class file to a python module? and if so how do i do that?
Python database widgets/environment like MSAccess
15,711,432
1
3
684
1
python,database,widget,rad
I am also looking for something similar to Kexi. Unfortunately python scripting is not supported in Kexi for windows. I would like to find something better than MS Access, and it does not have to be based on python. So far I have looked at quite a few IDE's but have not found anything where a GUI and database application can be built us as quickly as in access. I think of all the best one I have seen is Alpha 5. There could be something based on Net Beans but I really do not know. Oracle APEX is another one I have heard about but it doesn't support desktop applications (as far as I know).
1
0
0
0
2012-01-28T13:49:00.000
2
0.099668
false
9,045,723
0
0
1
1
First of all, I am sorry if this question doesn't belong to SO since I don't know where else to post it, anyway... I am looking for a decent python based database development RAD framework with nice data aware widgets and grids. A desktop framework would be much preferable to a web framework (I've developed heavy DB-centric apps in django but the web dev experience is still painful compared to a desktop one), although a web framework will do as long as there are powerful data-centric widgets to go along with it. Ideally, it should be as useful as say Delphi or MSAccess / VBA (I used to develop using those a long time ago). For the record, I have very good development experience in django and wxPython and as I've said developing heavy data-centric web apps is tough and wxPython although very powerful lacks DB-related widgets. Please note that the use of Python is mandatory because I've been using this language exclusively for all my projects in the last few years and I can't bear the idea of switching back to more mundane languages. Thanks for any suggestion...
Task Queues or Multi Threading on google app engine
9,047,335
1
1
980
0
python,multithreading,google-app-engine,web2py,task-queue
maybe i'm misunderstanding something, but thos sounds like the perfect match for a task queue, and i can't see how multithreading will help, as i thought this only ment that you can serve many responses simultaneously, it won't help if your responses take longer than the 30 second limit. With a task you can add it, then process until the time limit, then recreate another task with the remainder of the task if you haven't finished your job by the time limit.
0
1
0
0
2012-01-28T17:25:00.000
3
0.066568
false
9,047,267
0
0
1
2
I have my server on Google App Engine One of my jobs is to match a huge set of records with another. This takes very long, if i have to match 10000 records with 100. Whats the best way of implementing this. Im, using Web2py stack and deployed my application on Google App Engine.
Task Queues or Multi Threading on google app engine
9,047,823
1
1
980
0
python,multithreading,google-app-engine,web2py,task-queue
Multithreading your code is not supported on GAE so you can not explicitly use it. GAE itself can be multithreaded, which means that one frontend instance can handle multiple http requests simultaneously. In your case, best way to achieve parallel task execution is Task Queue.
0
1
0
0
2012-01-28T17:25:00.000
3
0.066568
false
9,047,267
0
0
1
2
I have my server on Google App Engine One of my jobs is to match a huge set of records with another. This takes very long, if i have to match 10000 records with 100. Whats the best way of implementing this. Im, using Web2py stack and deployed my application on Google App Engine.
Django RawQuerySet.__repr__ : not enough arguments for format string
9,047,552
2
1
1,159
0
python,django,string-formatting,django-queryset
I eventually found the explanation. I'm not sure this will be of much help to others, but anyways. The problem came from the fact that params in the call was a list. It appears you can use a list to instantiate a RawQuerySet, but it is not converted into a tuple so you can't use it for string-formatting later on. Conclusion I'll use MyModel.objects.raw(SQL, tuple(params)).
0
0
0
0
2012-01-28T17:37:00.000
1
1.2
true
9,047,378
0
0
1
1
I'm using a RawQuerySet in Django, and I need to pass it a few parameters (5). I'm able to call the constructor using MyModel.objects.raw(SQL, params). The SQL is pretty long and not that relevant, but params is [991L, 991L, 991L, 7L, 3]. I do get a RawQuerySet in return. Hence, the call is OK. However, my problem is that when __repr__ is called (through print here), I get a "Not enough arguments for format string" error. Now, what I don't get is the following: Why would I not have enough arguments since the call worked? [m.start() for m in re.finditer('%s', qs.raw_query)] gives me 5 items and so does qs.params. I'm pretty sure I'm missing something, but I can't seem to find what.
Django Overriding Model Clean() vs Save()
9,048,338
49
40
10,208
0
python,django,django-models,django-admin
You should use clean to do validation-related work, and to parse/change/otherwise clean the input. Capitalizing fields and generating a slug can happen here. I also use clean to force a field like post_type to a specific value in proxy models. If you raise django.core.exceptions.ValidationError('error text') inside clean, the 'error text' is added to the form.non_field_errors. Save is the place to change the way a model is actually saved. For instance, I've used save to create a crop of an uploaded picture. ValidationErrors are not caught if raised here, and I feel like that's the most important practical difference between the two.
0
0
0
0
2012-01-28T19:57:00.000
1
1.2
true
9,048,108
0
0
1
1
I have a couple of actions to perform when saving a models, especially from the admin. I capitalize a couple of fields and check to make sure that either one field or the other is filled. I also create the field slug. RIght now these are split between overriding the clean and the save functions. It works now, but I am curious on when to use each. I looked through the docs, and I couldn't find specifically which to use when.
{% url %} not work in Django
9,054,738
0
1
417
0
python,django,google-app-engine,internationalization,django-templates
There is an earlier error that you did not yet fix: Error Importing data store piston.gae_store OAuth: "No module named piston.gae_store" This does not seem to be related to the lines that you change. It will probably even occur when your remove the {% url ...%} completely, right? Try to fix the existing error first.
0
0
0
0
2012-01-28T20:52:00.000
2
0
false
9,048,513
0
0
1
1
I have a problem using the tag {% url%} in Django on GAE, I found the problem applying internationalization in JavaScript files, writing: {% url django.views.i18n.javascript_catalog %} Django throws the error: TemplateSyntaxError at / view / test / Caught ImproperlyConfigured while rendering: Error Importing data store piston.gae_store OAuth: "No module named piston.gae_store" And try other parameters: {% url prueba.views.prueba %} I get the same error. If I remove piston throws another error on another package, and if only the URL url.py let me test the latter throws error: 'str' object has no attribute 'resolve' The final url.py: urlpatterns = patterns('', url(r'^view/', include('website.urls')), ) I hope I can help or show another way to get the url of the JavaScript I want without using {% url django.views.i18n.javascript_catalog %}
Documents requests and memory issue using MongoDB
9,056,220
1
0
66
0
python,performance,memory,mongodb
If you are going to display all of the data on the web interface anyways, start simple: Get a the whole document. It reduces your latency by requiring less round trips to the database.
0
0
0
0
2012-01-29T18:33:00.000
2
1.2
true
9,055,624
1
0
1
2
I have documents in Mongo that contain questionnaire-like data (company's name, address, phone numbers, etc.). I should have this data displayed in web interface. How to make it better: get the whole document as dict into a variable and fill webform from its data or make lots of database requests to fill each field of the web form?
Documents requests and memory issue using MongoDB
9,057,896
1
0
66
0
python,performance,memory,mongodb
Agree with GPS - if you need all, or most, of the data then it should be a better option to retrieve the document in one request as opposed to hitting the database x number of times.
0
0
0
0
2012-01-29T18:33:00.000
2
0.099668
false
9,055,624
1
0
1
2
I have documents in Mongo that contain questionnaire-like data (company's name, address, phone numbers, etc.). I should have this data displayed in web interface. How to make it better: get the whole document as dict into a variable and fill webform from its data or make lots of database requests to fill each field of the web form?
Ensure a page has downloaded correctly in Python
9,081,637
0
0
109
0
python,beautifulsoup,mechanize
The most generic solution is to check that the </html> closing tag exists. That will allow you to detect truncation of the page. Anything else, and you will have to describe your failure mode more clearly.
0
0
1
0
2012-01-31T13:52:00.000
3
0
false
9,080,634
0
0
1
2
I am writing a basic screen scraping script using Mechanize and BeautifulSoup (BS) in Python. However, the problem I am running into is that for some reason the requested page does not download correctly every time. I am concluding this because when searching the downloaded pages using BS for present tags, I get an error. If I download the page again, it works. Hence, I would like to write a small function that checks to see if the page has correctly downloaded and re-download if necessary (I could also solve it by figuring out what goes wrong, but that is probably too advanced for me). My question is how would I go about checking to see if the page has been downloaded correctly?
Ensure a page has downloaded correctly in Python
9,081,631
0
0
109
0
python,beautifulsoup,mechanize
I think you may simple search for html ending tag if this tag is in - this is a valid page.
0
0
1
0
2012-01-31T13:52:00.000
3
0
false
9,080,634
0
0
1
2
I am writing a basic screen scraping script using Mechanize and BeautifulSoup (BS) in Python. However, the problem I am running into is that for some reason the requested page does not download correctly every time. I am concluding this because when searching the downloaded pages using BS for present tags, I get an error. If I download the page again, it works. Hence, I would like to write a small function that checks to see if the page has correctly downloaded and re-download if necessary (I could also solve it by figuring out what goes wrong, but that is probably too advanced for me). My question is how would I go about checking to see if the page has been downloaded correctly?
Is Django for the frontend or backend?
9,081,163
5
62
151,975
0
python,django,architecture
(a) Django is a framework, not a language (b) I'm not sure what you're missing - there is no reason why you can't have business logic in a web application. In Django, you would normally expect presentation logic to be separated from business logic. Just because it is hosted in the same application server, it doesn't follow that the two layers are entangled. (c) Django does provide templating, but it doesn't provide rich libraries for generating client-side content.
0
0
0
0
2012-01-31T14:23:00.000
3
0.321513
false
9,081,123
0
0
1
3
I often see people claiming their backend is implemented in Django, but isn't Django supposed to be for the frontend? I'd assume the backend refers to the business logic where the frontend refers to the presentation. Am I missing something?
Is Django for the frontend or backend?
9,081,179
107
62
151,975
0
python,django,architecture
Neither. Django is a framework, not a language. Python is the language in which Django is written. Django is a collection of Python libs allowing you to quickly and efficiently create a quality Web application, and is suitable for both frontend and backend. However, Django is pretty famous for its "Django admin", an auto generated backend that allows you to manage your website in a blink for a lot of simple use cases without having to code much. More precisely, for the front end, Django helps you with data selection, formatting, and display. It features URL management, a templating language, authentication mechanisms, cache hooks, and various navigation tools such as paginators. For the backend, Django comes with an ORM that lets you manipulate your data source with ease, forms (an HTML independent implementation) to process user input and validate data and signals, and an implementation of the observer pattern. Plus a tons of use-case specific nifty little tools. For the rest of the backend work Django doesn't help with, you just use regular Python. Business logic is a pretty broad term. You probably want to know as well that Django comes with the concept of apps, a self contained pluggable Django library that solves a problem. The Django community is huge, and so there are numerous apps that do specific business logic that vanilla Django doesn't.
0
0
0
0
2012-01-31T14:23:00.000
3
1.2
true
9,081,123
0
0
1
3
I often see people claiming their backend is implemented in Django, but isn't Django supposed to be for the frontend? I'd assume the backend refers to the business logic where the frontend refers to the presentation. Am I missing something?
Is Django for the frontend or backend?
9,082,219
13
62
151,975
0
python,django,architecture
It seems you're actually talking about an MVC (Model-View-Controller) pattern, where logic is separated into various "tiers". Django, as a framework, follows MVC (loosely). You have models that contain your business logic and relate directly to tables in your database, views which in effect act like the controller, handling requests and returning responses, and finally, templates which handle presentation. Django isn't just one of these, it is a complete framework for application development and provides all the tools you need for that purpose. Frontend vs Backend is all semantics. You could potentially build a Django app that is entirely "backend", using its built-in admin contrib package to manage the data for an entirely separate application. Or, you could use it solely for "frontend", just using its views and templates but using something else entirely to manage the data. Most usually, it's used for both. The built-in admin (the "backend"), provides an easy way to manage your data and you build apps within Django to present that data in various ways. However, if you were so inclined, you could also create your own "backend" in Django. You're not forced to use the default admin.
0
0
0
0
2012-01-31T14:23:00.000
3
1
false
9,081,123
0
0
1
3
I often see people claiming their backend is implemented in Django, but isn't Django supposed to be for the frontend? I'd assume the backend refers to the business logic where the frontend refers to the presentation. Am I missing something?
Design issue: client side or server side?
9,095,840
1
1
215
0
javascript,python,ruby
String manipulation is pretty fast in the server side but it's fine to do on the client side too. However make sure to validate the string once it arrives at the server side because any client can replicate requests to your server with a string and try to cause trouble.
0
0
1
0
2012-02-01T12:24:00.000
4
0.049958
false
9,095,758
0
0
1
4
Whenever there is dilemma to do a particular task, which can be accomplished either by client side code or by using a server code, which should be preferred? For example: I can iterate through a javascript object and construct a string and then send it to server, or should i send the javascript object and process it in the server? My views: whenever I come across this situation I use the client side code as it reduces the computation load on server. What has to be done in such a situation? Which is the right approach?
Design issue: client side or server side?
9,095,857
0
1
215
0
javascript,python,ruby
You must take into consideration a lot of factors, including and especially security ones. For example, if you must do some complicated form validation, then it is extremely important to do it server-side, even if that puts a little more load on the server. Always keep in mind that a bad guy can change/break your javascript and send invalid (or possibly malicious) data to the server. When it comes to web programming, the single and most important rule of all is: Never trust the user. With anything. Period. In your case (with the String), you probably can do it client-side and verify on the server that it's ok.
0
0
1
0
2012-02-01T12:24:00.000
4
0
false
9,095,758
0
0
1
4
Whenever there is dilemma to do a particular task, which can be accomplished either by client side code or by using a server code, which should be preferred? For example: I can iterate through a javascript object and construct a string and then send it to server, or should i send the javascript object and process it in the server? My views: whenever I come across this situation I use the client side code as it reduces the computation load on server. What has to be done in such a situation? Which is the right approach?
Design issue: client side or server side?
9,096,236
1
1
215
0
javascript,python,ruby
(This answer assumes a web programming context) I personally put a lot of front-end logic in Javascript running on the client side, because it makes things very responsive, even for people with a slow connection. This also means that some functionality continues working even if the user goes offline. I find some programmers use AJAX for things which don't reallly require communication with the server at all. When using this technique, if possible, I find it helpful to embed all the data which the front-end Javascript may need in the page, so it doesn't have to go back and request more data from the server using an AJAX call. (In general, whenever data is being communicated over a high-latency channel, you want to send it in big chunks so the client doesn't have to keep constantly coming back for more. The same applies to DB queries: you can often increase performance by pulling back all the data you might need with a single query, rather than making numerous fine-grained queries. Even if you don't end up using all of that data, performance will still usually be better.) One caution: unless you are very disciplined to keep things organized, Javascript which updates the UI by dynamically generating HTML in response to user actions can become very hairy. If the Javascript is also dynamically generated using another language (running on the server side), things can get downright frightening. Testability is also important in any app. If you are using something like Selenium, testing a combination client/server web app may not be a problem, but if you aren't, testing server-side code may be easier. As others have noted, you must also make sure that you don't compromise security. Don't expect that people will only invoke your server-side code in the way you provide for. View all the types of requests your server handles as forming an "API" which people may invoke with any arguments and in any order.
0
0
1
0
2012-02-01T12:24:00.000
4
1.2
true
9,095,758
0
0
1
4
Whenever there is dilemma to do a particular task, which can be accomplished either by client side code or by using a server code, which should be preferred? For example: I can iterate through a javascript object and construct a string and then send it to server, or should i send the javascript object and process it in the server? My views: whenever I come across this situation I use the client side code as it reduces the computation load on server. What has to be done in such a situation? Which is the right approach?
Design issue: client side or server side?
9,095,862
0
1
215
0
javascript,python,ruby
I am a django/python developer and my logic is "templates should be used for rendering". I keep my load minimum on the client side and all computation is done on the server side. Another reason for doing this is because a user cannot be trusted. Keep the equation simple for the user.
0
0
1
0
2012-02-01T12:24:00.000
4
0
false
9,095,758
0
0
1
4
Whenever there is dilemma to do a particular task, which can be accomplished either by client side code or by using a server code, which should be preferred? For example: I can iterate through a javascript object and construct a string and then send it to server, or should i send the javascript object and process it in the server? My views: whenever I come across this situation I use the client side code as it reduces the computation load on server. What has to be done in such a situation? Which is the right approach?
Python should I use threading
9,297,208
0
4
269
0
python
I have decided to adopt a process rather than a threaded approach to resolving this issue. The primary factor in this decision is simplicity. The second factor is whilst one of these applications will be carrying out data acquisition the other will be communicating with a modem on an ad-hoc basis (receiving calls) I don't have control over the calling application but based on my investigations, there is the potential for a lot to go wrong. There are a couple of factor which may change the approach further down the line primarily the need for the two processes to interact to prevent data contention on the database. Secondly if resources (memory/disk space/cpu) become an issue (due to the size of the device) one application should give me the ability to manage these problems. That said the data acquisition application is already threaded. This allows the parent thread to manage the worker when exceptions arise, as the device will not be in a managed environment.
0
0
0
0
2012-02-01T14:52:00.000
4
0
false
9,097,911
1
0
1
3
I currently have a couple of small applications < 500 lines. I am intending to eventually run them on a small LINUX ARM box. Is it better to combine these applications and use threading, or continue to have them as two separate applications? These applications plus a very small website use a small sqlite database, though only one of the applications write everything else currently does reads. Due to constraints of the target box I am using Python 2.6. I am using SQLite to prevent data loss over several days of use. There is no direct interaction between the two application though there is the potential for database locking issue especially during period data maintenance. Stopping these issue are a concern also the foot print of the two applications as the target devices are pretty small.
Python should I use threading
9,098,387
2
4
269
0
python
For performance purpose, I will suggest you to use threads, process consumes much more resources than threads, it will be faster to create and need less memory (usefull in embedded environment), but of course, you'll have to deal with the common traps of multithreading programmation (concurent access solved by locks, but locks may lead to interlocking...) If you plan to use many libraries that make low level calls, maybe with C extension developped that could not release properkly the GIL (Global Interpreter Lock), in this case, processes can be a better solution, to allow your applications to run even when one is blocked by GIL.
0
0
0
0
2012-02-01T14:52:00.000
4
0.099668
false
9,097,911
1
0
1
3
I currently have a couple of small applications < 500 lines. I am intending to eventually run them on a small LINUX ARM box. Is it better to combine these applications and use threading, or continue to have them as two separate applications? These applications plus a very small website use a small sqlite database, though only one of the applications write everything else currently does reads. Due to constraints of the target box I am using Python 2.6. I am using SQLite to prevent data loss over several days of use. There is no direct interaction between the two application though there is the potential for database locking issue especially during period data maintenance. Stopping these issue are a concern also the foot print of the two applications as the target devices are pretty small.
Python should I use threading
9,097,976
4
4
269
0
python
Depends on whether you need them to share data and how involved the sharing is. Other than that, from a speed point of view, for a multiprocessing machine, threading won't give you much of an advantage over separate processes. If sharing can easily take place via a flat file or database then just let them be separate rather than complicating via threading.
0
0
0
0
2012-02-01T14:52:00.000
4
0.197375
false
9,097,911
1
0
1
3
I currently have a couple of small applications < 500 lines. I am intending to eventually run them on a small LINUX ARM box. Is it better to combine these applications and use threading, or continue to have them as two separate applications? These applications plus a very small website use a small sqlite database, though only one of the applications write everything else currently does reads. Due to constraints of the target box I am using Python 2.6. I am using SQLite to prevent data loss over several days of use. There is no direct interaction between the two application though there is the potential for database locking issue especially during period data maintenance. Stopping these issue are a concern also the foot print of the two applications as the target devices are pretty small.
converting NavigableString to unicode string
41,417,621
0
2
7,115
0
python,string,unicode,beautifulsoup
There should not be any problem just using python's str() method on the navigable string object you have. From my experience with NavigableString's they are already in unicode so if you want a string on which .lower will work then you need to cast it to a python string (UTF-8) then recast it back to unicode.
0
0
0
0
2012-02-01T16:34:00.000
2
0
false
9,099,523
1
0
1
1
When I run the following code: if substr in movie.lowercase: I get the following error AttributeError: 'NavigableString' object has no attribute 'lowercase' movie is from here: movie = row.td.div.h4.string I tried to change it to (without success) movie = row.td.div.h4.string.string or movie = unicode(row.td.div.h4.string) Do you know how to convert NavigableString to normal unicode string with lowercase method?
What are the limitations of Django's ORM?
9,112,738
0
20
8,580
0
python,django,orm
One of the biggest problem that come to mind is that Building inheritance into Django ORM's is difficult. Essentially this is due to the fact that (Django) ORM layers are trying to bridge the gap by being both relational & OO. Another thing is of course multiple field foreign keys. One charge leveled at Django ORM is that they abstract away so much of the database engine that writing efficient, scalable applications with them is impossible. For some kinds of applications - those with millions of accesses and highly interrelated models — this assertion is often true. The vast majority of Web applications never reach such huge audiences and don't achieve that level of complexity. Django ORMs are designed to get projects off the ground quickly and to help developers jump into database-driven projects without requiring a deep knowledge of SQL. As your Web site gets bigger and more popular, you will certainly need to audit performance as described in the first section of this article. Eventually, you may need to start replacing ORM-driven code with raw SQL or stored procedures (read SQLAlchemy etc). Happily, the capabilities of Django's ORMs continue to evolve. Django V1.1's aggregation library is a major step forward, allowing efficient query generation while still providing a familiar object-oriented syntax. For even greater flexibility, Python developers should also look at SQLAlchemy, especially for Python Web applications that don't rely on Django.
0
0
0
0
2012-02-02T12:47:00.000
6
0
false
9,112,571
0
0
1
1
I've heard developers not wanting to use ORM, but don't know why. What are the shortcomings of the ORM?
How do I install in-house requirements for Python Heroku projects?
9,112,921
0
9
1,227
0
python,heroku,pip
You can write, say, "-e git+ssh://git@.../PIL#egg=PIL" instead of "PIL" in your requirements.txt file and it'll fetch it from there. However, this would require you to somehow specify the ssh private key to be used by heroku when pulling.
0
0
0
0
2012-02-02T13:02:00.000
4
0
false
9,112,784
1
0
1
1
We have a few in-house libraries that we've split off (for several reasons, mostly administrative or to have the possibility to easily open source them later). They live in private Github repositories, if that matters. I'd like to deploy an app to Heroku to try it out. It depends on one of those libraries. I'm supposed to specify my dependencies in requirements.txt. That's easy for the PyPI-installable stuff, but what do I do for these in-house dependencies? I could either run my own private PyPI mirror that has this stuff, or I could use editable packages (even though the documentation says they shouldn't be used in production). What's the appropriate way to do it?
Django url template confusion
9,117,883
2
0
163
0
python,django,django-urls
Use the application name in the url tag, e.g. {% url myapp.views.contest_overview %}
0
0
0
0
2012-02-02T18:11:00.000
2
0.197375
false
9,117,590
0
0
1
1
Okay I am having a bit of an issue. I want to create a button with a link, and right now I am using action={% url views.contest_overview %} in hopes that the reverse lookup by Django will match (r'^category/$', views.contest_overview), in my urls.py. However, this is not working and I can't figure out the proper nomenclature, despite numerous guesses. The error I get (with my best guess above) is: Caught NoReverseMatch while rendering: Reverse for 'views.contest_overview' with arguments '()' and keyword arguments '{}' not found. Thank you very much for your time!
How to upload/publish products to Amazon via Amazon MWS API?
9,312,763
2
6
2,077
0
python,amazon-mws
The general gist of it is you use SubmitFeed to send your product list. Then you must check the status of the submission. Once the submission is complete you can then get the results. You have to repeat these steps for images, pricing and availability. It's a bit of a pain to get started with it, Amazon supply a LOT of useful information but it is everywhere and not particulary very easy to understand at first. Experiment with just adding products to your inventory and go from there. Make use of the scratchpad too, very handy tool indeed. As for python I can't help you there I'm afraid but I think there is sample code within the python download available from Amazon.
0
0
1
0
2012-02-03T04:40:00.000
1
0.379949
false
9,123,764
0
0
1
1
I heard SubmitFeed API is for adding products. But i didn't find any example. By the way, i need a Python solution. Thanks a lot.
Caching the entire response (HTML, js, json, ecc) only for non-logged in users
9,134,197
1
1
184
0
python,django
Have you tried CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True? Assuming whatever caching you're using utilizes Django's cache framework, that should do the trick.
0
0
0
0
2012-02-03T18:33:00.000
1
0.197375
false
9,133,704
0
0
1
1
I love django-staticgenerator. Unfortunately you can't use it in cases in which you have to display different content depending on the user, plus is not being actively developed. Is it possible to return the cached response only to non-logged in users? I saw an app that used nginx to do it, is it possible to do it with apache? Has anybody tried this solution and can you suggest if there is any actively developed django app that serves this purpose? Thanks!
Background job/task monitor for Django
9,178,073
1
4
719
0
python,django
I used django-chronograph for managing my scheduled jobs and django-peavy for logging. That provided everything I needed.
0
0
0
0
2012-02-04T11:13:00.000
3
1.2
true
9,140,441
0
0
1
1
I have a few management commands for my Django poject that is run automatically by cron. Are there any django packages that allow me to monitor the status of my background jobs? Currently I have to trudge through my log files to find out if everything went okay or not and I'm confident that writing a simple job/task monitor for Django wouldn't be hard all but if there were already some existing packages that you know about, it would help a lot as I don't have cobble together something myself. Thanks
Serialization with JDBC with MySQL, JAVA REST and Python REST
9,158,709
1
0
253
1
java,python,mysql,rest,jdbc
Of course they need to be thread safe. You should be writing your Java server as if it were single threaded, because a Java EE app server will assign a thread per incoming request. You also need to think about database isolation and table locking. Will you allow "dirty reads" or should your transactions be serializable? Should you SELECT FOR UPDATE? That's a database setting, separate from threading considerations.
0
0
0
0
2012-02-06T10:16:00.000
1
1.2
true
9,158,578
0
0
1
1
I have a project in which i use JDBC with MySQL to store some user information, Java REST for the server and Python REST for the client. My question is: by default(i haven't changed anything in the configurations), are the http requests from the client serialized on the server's side? I ask this because i'd like to know if i need to make the database insert/delete querys thread-safe or something.
Only allow a subset of users to access a google app project
9,171,764
1
0
122
0
python,google-app-engine
Wouldn't it be easier to write a user model rather than access it with the Google accounts API? That way you could define user groups and access without having to rely on Google. The Google Accounts API in the example is really for low-level init debugging.
0
1
0
0
2012-02-07T04:38:00.000
1
1.2
true
9,171,080
0
0
1
1
We are trying to develop a project in google app engine for a senior project, and its set up in such a way that only a subset of user at our college should be able to login to it. Our college uses google domains for email, so that is currently out login requirement (a college email though google that is), but how can we limit it to not just people without that domain, but a subset or per-approved users with that domain? Also if it matters, within the subset of users, there are four additional types of usesr, who will have access to different pages, functions and information. Right now we are just using the google login APIs, and we are at a loss of how to micro-manage the user pool. Would we have to create a data store entry for each user who should be authorized to access the service and run a check at each page to ensure they have the privileges to be there? Or does google provide some type of service to make this easier that I've missed? Thanks folks!
Realtime data server architecture
9,189,761
0
2
319
1
python,real-time
I would say, run the two on the same machien to start with, and see how the performance goes. Why spend money on a second machine if you don’t have to? As for “dealing with the ever growing amount of data”—do you need to keep old data around? If not, your second task can simply delete old data when it’s done with it. Provided all the records are properly time-stamped, you don’t need to worry about race conditions between the two tasks.
0
0
0
0
2012-02-07T19:56:00.000
1
1.2
true
9,182,936
0
0
1
1
I wanted your advice for the best design approach at the following Python project. I am building a web service system that is split into 2 parts: This part grabs realtime data from a 3rd party API and puts the data in a DB. This part exposes a json API to access data from the DB mentioned in 1). Some background info - 2) runs on django, and exposes the API via view methods. It uses SQLAlchemy instead of the django ORM. My questions are: - Should 1) and 2) run on the same machine, considering that they both access the same MySQL DB? - What should 1) run on? I was thinking about just running cron jobs with Python scripts that also use SQLAlchemy. This is because I don't see a need for an entire web framework here, especially because this needs to work super fast. Is this the best approach? - Data size - 1) fetches about 60,000 entries and puts them in the DB every 1 minute (an entry contains of about 12 Float values and a few Dates and Integers). What is the best way to deal with the ever growing amount of data here? Would you split the DB? If so, into what? Thanks!
pip uninstall broken w/ --environment flag?
9,184,903
7
3
2,999
0
python,virtualenv,pip
Appears to be a bug in pip 1.0. Seems to work if I pip install --upgrade pip and then try it.
0
0
0
0
2012-02-07T22:19:00.000
1
1.2
true
9,184,873
1
0
1
1
I can't seem to get pip to uninstall a package when using the environment flag. I've created a virtual environment: virtualenv --no-site-packages /path/to/testenv While not in the virtual environment, I issue: pip install --environment /path/to/testenv django Django is downloaded and installed. If I do the same command in reverse, it doesn't work: pip uninstall --environment /path/to/testenv django The uninstall command outputs: Uninstalling Django: Proceed (y/n)? y Successfully uninstalled Django But if I actually go in to the virtual environment: . /path/to/testenv/bin/activate and then run the uninstall command: pip uninstall django I get: Uninstalling Django: /path/to/testenv/bin/django-admin.py /path/to/testenv/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg-info /path/to/testenv/lib/python2.7/site-packages/django Proceed (y/n)? I'm running pip 1.0 Am I missing something, or did I hit a bug?
Overloading a part of or entire Django app for a specific User
9,189,836
0
0
53
0
python,django
In short, you can't (or, at least, it would be fairly tricky and magical). In longer: apart from performing the checks in the apps themselves, you might want to consider creating a router app which handles the requests, then decides which sub-app should be responsible for them. If you can give some more details, it would be possible to give a more detailed answer.
0
0
0
0
2012-02-08T08:23:00.000
1
0
false
9,189,795
0
0
1
1
I am developing a large Django site where some of the users are going to have specific needs. So I am looking for a way to overload part of a Django app if the user meets specific conditions. I would prefer to be able to dynamically load a user tailored version of an app, instead of loading the standard app all together. The idea is all good in theory, but i have no idea how to do this in a clean python/django-esque way, I would also prefer if my urls would remain the same even when an user app is loaded.
Getting Credentials File in the boto.cfg for Python
33,725,689
5
4
14,015
0
python,amazon-web-services,boto
For anyone looking for information on the now-current boto3, it does not use a separate configuration file but rather respects the default one created by the aws cli when running aws configure (Ie, it will look at ~/.aws/config)
0
1
0
0
2012-02-08T16:27:00.000
3
0.321513
false
9,197,385
0
0
1
1
I'm using AWS for the first time and have just installed boto for python. I'm stuck at the step where it advices to: "You can place this file either at /etc/boto.cfg for system-wide use or in the home directory of the user executing the commands as ~/.boto." Honestly, I have no idea what to do. First, I can't find the boto.cfg and second I'm not sure which command to execute for the second option. Also, when I deploy the application to my server, I'm assuming I need to do the same thing there too...
How to Copy/Clone a Virtual Environment from Server to Local Machine
12,794,019
2
30
19,745
0
python,django,ubuntu,webserver,virtualenv
Please using Freeze command and you will get text file with all the versions of packages. Then install them using easy install or pip install
0
0
0
0
2012-02-09T08:21:00.000
2
0.197375
false
9,207,430
1
0
1
2
I have an existing Python django Project running in Web Server. Now the client needs to make some changes in the existing code. So I need to set it up in my Local Machine. All the packages needed for this project is installed in a Virtual environment. How can I copy or clone this virtual environment to my Local machine to run this Project.
How to Copy/Clone a Virtual Environment from Server to Local Machine
9,207,511
51
30
19,745
0
python,django,ubuntu,webserver,virtualenv
Run pip freeze > requirements.txt on the remote machine Copy that requirements.txt file to your local machine In your local virtual environment, run pip install -r requirements.txt And, so long as all of the requirements are well behaved Python packages, you should be good to go.
0
0
0
0
2012-02-09T08:21:00.000
2
1.2
true
9,207,430
1
0
1
2
I have an existing Python django Project running in Web Server. Now the client needs to make some changes in the existing code. So I need to set it up in my Local Machine. All the packages needed for this project is installed in a Virtual environment. How can I copy or clone this virtual environment to my Local machine to run this Project.
Isolated debugging session with PyDev
9,226,643
0
0
79
0
python,eclipse,debugging,pydev
I don't think this is possible out of the box... you'd need to architecture your production server so that this would be possible (i.e.: when you send a given request it should spawn a different interpreter just to handle your request for debugging purposes and shutdown that interpreter after the debug session ends), but you have to make sure that the debugger will actually run in a separate interpreter, otherwise it could end up tracing more things from other people (and in the best situation it'd only make things slower and in the worse it could end up having unexpected consequences because of some interaction of the debugger with your code).
0
1
0
1
2012-02-09T23:20:00.000
1
0
false
9,220,493
0
0
1
1
I'm using Eclipse + PyDev to work on python web projects. Sometimes I need to run debug session on production server rather then locally, due to specific environment. I was wondering if there is a way to run isolated remote debugging session, so the other users don't experience any issues, and code execution doesn't suspend for them? Thanks.
get_login_url goes to blank page when coming from naked url
9,221,655
1
0
84
0
python,google-app-engine
When accessing the site via "example.com", self.request.uri is from that domain, which is the domain where the cookie is created. When it then redirects back, it goes to "www.example.com", which has no cookie, but your site is expecting a user to be logged in. Suggestions: use a relative path like / (or webapp2's uri routing) instead of a full URI, or first redirect to www.example.com before doing the login.
0
0
0
0
2012-02-10T00:44:00.000
1
1.2
true
9,221,195
0
0
1
1
I just started hosting my app on a new domain. I selected a url forwarding option with my registrar. Which seems to work. example.com didn't work before (as opposed to the subdomain www.example.com) but now it does. The problem is that if I access the site via example.com and try to login, users.create_login_url(self.request.uri), I go to a blank page. If I go to www.example.com the login works fine. In both cases self.request.uri is returning the www subdomain, even though in the first case example.com is still shown in the browser. I don't really know much about this stuff. Any tips on where I should go from here?
Localhost web-app. Get full path to file in browser
18,676,841
2
1
1,581
0
python,file,select,browser,path
One approach is to communicate with your server; your client would start with the path "home" (or empty string) and the server would return the physical path ("c:\users\me" or "/home/me"), and the list of subfolders and files in the folder... And then if you give any other path to the server, it will return you info about that other path. The tricky part would be to get notified when new mounts or drives appear in the the system (usb keys and so on). Then you could make a file picker in the client using that information that the fully-privileged server gives you. Actually with the proper JS libraries it wouldn't be that hard to code, and it is being done by various projects, the problem (besides the extra work) being that your file picker will look out of place compared to the system file picker that users are used to.
0
0
0
0
2012-02-10T19:57:00.000
1
1.2
true
9,234,029
0
0
1
1
My question may seem strange, I'd love suggestions if you have a better way to go about what I'm doing: I'm running a local web server with the Bottle web framework for python. I'm using jQuery, HTML, and CSS to write the graphical front end to my "app", and just navigating to the address of the local host in a browser (firefox). I'm doing this because I want the flexibility that html and css offer for designing UIs over the abilities offered by tools like QT, and PyQt. Here's the problem: An important part of my app is to obtain the full path to a file on disk which the program will operate on. So as to not make the user type the full path the entire time, I'd love to have a file selection dialogue fill it in for them. However, I've been reading that for security reasons, the browser will not allow that full path to come through. I understand that the full path to a file would never be useful in a normal server-client set up, but in this case the server and client are one in the same, and I'm not concerned with that aspect of security. Am I approaching this problem in a silly way? Is there a way to ask the file browser to return the full path to a file it is selecting? Or do I need to find another path entirely? Thanks! Murphy
Full text search with google app engine using ndb models
9,243,456
1
4
2,635
0
python,google-app-engine,full-text-search,google-cloud-datastore
The best solution is to wait until app engine's full text search is released. They are currently in trusted tester phase, so it's coming soon. If you roll your own solution now, you may end up redoing it in a few months.
0
1
0
0
2012-02-11T10:45:00.000
3
0.066568
false
9,239,575
0
0
1
1
I have made a google app using next db module (ndb) to create my models. Now the problem is i want to deploy search over the fields of these models, and i have found two modules to do that: 1. The officially shipped with google app engine (appengine/google/ext/search) and 2. gae text search (http://code.google.com/p/gae-text-search/). Both of these provide the Searchable Model for the old db module properties. Is there any way i can do full text search using ndb and google app engine 1.6.2. Also i want to store those search queries to the datastore, how can i achieve that too? I am using python 2.7 for my development. Thanks in advance.
How do set Python path to run Django with WSGI and Apache?
9,253,022
3
1
1,793
0
python,django
You need to build mod_wsgi against python 2.7 and load this module into apache instead of the current mod_wsgi version you are using that links against python 2.4. This requires root access to the machine.
0
0
0
0
2012-02-12T21:43:00.000
4
1.2
true
9,252,986
0
0
1
3
The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. Now, how do I specify for Apache/WSGI to use Python 2.7 to run the Django project? [edit] I can't update Python 2.4 because CentOS depends on that version of Python. Unless there is a safe way of updating without breaking a service such as yum
How do set Python path to run Django with WSGI and Apache?
9,253,191
0
1
1,793
0
python,django
"You got peanut butter on my chocolate!" "You got chocolate in my peanut butter!" Two great tastes that go together. As Thiefmaster says, you need to use the correct version of wsgi. As Alex says, you need to run in a virtualenv for the later python so that you don't mess up everything else. Install all your python stuff, including your preferred Django, into your virtualenv and everything will be good.
0
0
0
0
2012-02-12T21:43:00.000
4
0
false
9,252,986
0
0
1
3
The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. Now, how do I specify for Apache/WSGI to use Python 2.7 to run the Django project? [edit] I can't update Python 2.4 because CentOS depends on that version of Python. Unless there is a safe way of updating without breaking a service such as yum
How do set Python path to run Django with WSGI and Apache?
9,253,152
0
1
1,793
0
python,django
You can run Django 1.3 in Python 2.4 without problems. I think it's the best choice for CentOS, and you won't have to upgrade Python. I've installed django on Centos 5 with Apache+mod_wsgi and Cherokee+uwsgi (I prefer the last one)
0
0
0
0
2012-02-12T21:43:00.000
4
0
false
9,252,986
0
0
1
3
The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. Now, how do I specify for Apache/WSGI to use Python 2.7 to run the Django project? [edit] I can't update Python 2.4 because CentOS depends on that version of Python. Unless there is a safe way of updating without breaking a service such as yum
Django : Project consuming data from REST API, How to use external apps in this system?
9,451,170
-2
8
2,102
0
python,database,django,rest
I'm facing a similar obstacle with a new ecommerce project. The project is a front end to a full-fledged store management software (CMS+ERP+CRM). It needs to use the master product database, but have its own entries for product reviews, ratings and so on. The initial thought was to make a cached copy of the master database. The website will benefit from fast loading times for the cached items, but the implementation is not trivial. After some considerations, the selected approach was updating the website's DB from the management program. This way the website's copy will always be correct, and most of the implementation doesn't need to worry about REST services (it'll still be used for user registration, shipment tracking etc.) In your case, where you can't have the service update your own database remotely, you need to come up with a mechanism that allows you to refer to REST recourses like regular models, and that caches them in the background. Important note: research for a way to make sure the cache is always correct (non-dirty)...
0
0
0
0
2012-02-13T04:55:00.000
3
-0.132549
false
9,255,776
0
0
1
1
I have a Django web front-end that consumes data from a REST API backend. Even the users are made and created on the backend. My Problem : How to use 3rd party apps within this system, that heavily depend on django models/ORM ? Is there something that can provide some bridge between the REST API resources and the ORM? How can this problem be dealt with ? Update DRY principal seems to be failing in this situation.
Django : Which approach is better [ virtualenv + pip ] vs [manually carrying packages in svn]?
19,614,229
0
2
699
0
python,django,directory-structure
Virtualenv and pip are fantastic for working on multiple django projects on one machine. However, if you only have one project that you are editing, it is not necessary to use virtualenv.
0
0
0
0
2012-02-13T05:19:00.000
3
0
false
9,255,930
0
0
1
1
I have a django project that uses a lot of 3rd party apps, so wanted to decide out of the two approaches to manage my situation : I can use [ virtualenv + pip ] along with pip freeze as requirements file to manage my project dependencies. I don't have to worry about the apps, but can't have that committed with my code to svn. I can have a lib folder in my svn structure and have my apps sit there and add that to sys.path This way, my dependencies can be committed to svn, but I have to manage sys.path Which way should I proceed ? What are the pros and cons of each approach ? Update: Method1 Disadvantage : Difficult to work with appengine.
Django return json and html depending on client python
9,260,320
7
3
3,193
0
python,html,django,json
Use different URLs for the JSON and HTML versions. I suggest that your JSON version be available on a url like r'normal/api(?P<json_flag>/json/?)$', and have a parameter in your view to receive the json flag. You can then serve appropriately. Naturally, your view will have to use different logic to generate HTML and JSON. I strongly suggest that you use the json module instead of a template to generate JSON.
0
0
0
0
2012-02-13T12:07:00.000
1
1.2
true
9,260,249
0
0
1
1
I have a django app which has html templates and I also have a command line python api which can do GET and POST requests to the django app on the server. The api can pretty much do everything that the django app can do. How do I make it such that when I access the django app through the browser it returns html but when I access it through the api it returns json? Where will I have to put the json and what changes do I have to make to my app? Thank you
Python: Running Daemon Processes in Windows7
9,271,567
-1
5
8,604
0
python,windows
You simply need to leave your program running! Please google "python daemon" and see how to implement a persistent background process in Python. Now, you cannot know when a website changes unless you poll it. If the website is well designed, the page you are trying to poll will have a "Last-Modified" header, you can make a "HEAD" request every so often (be nice: don't poll like crazy) and act when Last-Modified is >= than the one on record. If the site is not well designed, it will not have a reliable Last-Modified or ETAG header, in that case you will have to parse manually and check for changes yourself. Cheers.
0
0
0
0
2012-02-14T04:04:00.000
4
-0.049958
false
9,271,525
0
0
1
2
I had a program that Scraped certain data from certain Web-Pages, and when the Web-Pages changed, acted accordingly. How would one set up the program so it continues to run in the background? I don't need any specifics I'm just really confused on this concept and would appreciate whatever help anybody has to offer.
Python: Running Daemon Processes in Windows7
9,274,957
10
5
8,604
0
python,windows
start path-to-pythonw.exe your-code.py pythonw means without console. start means start on background. if your python is installed system-wide, you can probably start your-code.pyw .pyw is associated with pythonw.exe remember you cannot use print (to stdout) in this case.
0
0
0
0
2012-02-14T04:04:00.000
4
1
false
9,271,525
0
0
1
2
I had a program that Scraped certain data from certain Web-Pages, and when the Web-Pages changed, acted accordingly. How would one set up the program so it continues to run in the background? I don't need any specifics I'm just really confused on this concept and would appreciate whatever help anybody has to offer.
How to include plug-n-play widget statics [CSS/JS] without repetition?
9,272,857
0
0
162
0
php,python,django,templates,include
Depending on your use case a few options: Use a separate base template for all pages that need the widget; in that base add the required js/css files. For all views that need the widget, inherit from the modified base. Using javascript implement conditional includes.
0
0
0
0
2012-02-14T06:35:00.000
1
1.2
true
9,272,710
0
0
1
1
I have a reusable google-maps widget that can be plugged into any page that might want to use it. Widget has : Google maps specific js includes. Map specific css to style the map. Problem: Widget code gets included as server-side include. Widget specific js and css has to included with the widget code. Therefore, if widget repeats 5 times on a page, then the include statements for js and css get included 5 times. I can-not keep the widget specific includes in the <head> tag, since if the widget is not used on the page, then un-used js and css gets downloaded on client. So, how should I keep the js and css so they gets included only when the widget is used and no multiple include are done in case the widget is repeated. My technology: Django-Python [ If that matters ] I also faced the same problem on php Note : I understand that including the same js and css multiple times on a page doesn't forces the client to download them multiple times, but I want to avoid the multiple includes. How should I tackle this problem ? Please feel free to ask for more info, if I missed something. :)
Why use werkzeug when there is flask
9,288,773
13
9
3,175
0
python,flask,werkzeug
Flask and Werkzeug are different things. Flask contains Werkzeug as one of the things in it, but also has much more (which might be unwanted). Flask is a web microframework. Werkzeug is a WSGI middleware.
0
0
0
0
2012-02-15T06:16:00.000
1
1.2
true
9,288,747
0
0
1
1
I am just curious to know as why should we use werkzeug when flask is there. Any specific reason to consider werkzeug over flask.
Retrieve a list of browsers/agents installed in client system
9,307,042
0
1
300
0
java,javascript,python,django,web-applications
"Scanning" a client from a server may be possible if you break their security or get them to break it for you through some extension (see windows udate, for example). Either way, it's evil.
0
0
0
0
2012-02-16T06:16:00.000
4
0
false
9,306,460
0
0
1
4
I would like to write a web application (in django) which scans the client/remote computers (assumption is windows) and retrieve the list of software's(mainly browsers) installed. Looking for suggestions to implement it. Is this possible without asking the user to download any scritps/exe's? If so, is it possible via java script? I am planning to use python/django to write the entire app. Any input would be much appreciated. EDIT : Comments on feasibility in java also much appreciated
Retrieve a list of browsers/agents installed in client system
9,306,601
3
1
300
0
java,javascript,python,django,web-applications
Short answer: No, it is not possible Long answer: This is something that any sane (operating) system designer / administrator would try to prevent - scanning of local system by a web page. However, you could use a plug-in component, such as a java applet, to do so - but in practice you probably would need to handle each client platform (OS) separately, since each of them has a different way of storing the information of installed software
0
0
0
0
2012-02-16T06:16:00.000
4
1.2
true
9,306,460
0
0
1
4
I would like to write a web application (in django) which scans the client/remote computers (assumption is windows) and retrieve the list of software's(mainly browsers) installed. Looking for suggestions to implement it. Is this possible without asking the user to download any scritps/exe's? If so, is it possible via java script? I am planning to use python/django to write the entire app. Any input would be much appreciated. EDIT : Comments on feasibility in java also much appreciated
Retrieve a list of browsers/agents installed in client system
9,307,607
1
1
300
0
java,javascript,python,django,web-applications
You want to access the data from the client side so from the conceptual/logically its not good to access the client system. You have to use some medium which run on client side on behalf of server. JavaScript and JavaApplet is good in this. You can get the data by JavaScript or Applet and in backend you can send data to the server.
0
0
0
0
2012-02-16T06:16:00.000
4
0.049958
false
9,306,460
0
0
1
4
I would like to write a web application (in django) which scans the client/remote computers (assumption is windows) and retrieve the list of software's(mainly browsers) installed. Looking for suggestions to implement it. Is this possible without asking the user to download any scritps/exe's? If so, is it possible via java script? I am planning to use python/django to write the entire app. Any input would be much appreciated. EDIT : Comments on feasibility in java also much appreciated
Retrieve a list of browsers/agents installed in client system
9,306,570
0
1
300
0
java,javascript,python,django,web-applications
You cannot do this unless you have some signed control installed on the client computer; or have them download a program which runs (separate from a browser) and sends the information to your server, where your django app can access it. This is not possible using javascript (as it runs in a sandbox).
0
0
0
0
2012-02-16T06:16:00.000
4
0
false
9,306,460
0
0
1
4
I would like to write a web application (in django) which scans the client/remote computers (assumption is windows) and retrieve the list of software's(mainly browsers) installed. Looking for suggestions to implement it. Is this possible without asking the user to download any scritps/exe's? If so, is it possible via java script? I am planning to use python/django to write the entire app. Any input would be much appreciated. EDIT : Comments on feasibility in java also much appreciated
What does thread local mean in Flask framework?
9,317,857
4
9
1,559
0
python,web-services,scalability,flask
It's not really a scalability issue, rather it can make it more difficult to maintain a complex code-base. This is because thread locals are used as a global data store, to avoid passing state via function arguments, which makes it harder to follow what's going on. Speed-wise, thread locals are not particularly slow, but they do make it hard or impossible to use an asynchronous framework, where lots of tasks run for short amounts of time on a single thread.
0
0
0
0
2012-02-16T18:44:00.000
1
0.664037
false
9,317,168
1
0
1
1
I am evaluating python frameworks to build a REST API. I have gone through many frameworks including flask and found Flask pretty interesting and easy to use with all the features needed to build a REST web service. One thing i don get is in flask docs it is mentioned that it uses "thread local and has issues with scalability". Flask uses thread local objects (context local objects in fact, they support greenlet contexts as well) for request, session and an extra object you can put your own things on (g). Why is that and isn’t that a bad idea? Yes it is usually not such a bright idea to use thread locals. They cause troubles for servers that are not based on the concept of threads and make large applications harder to maintain. However Flask is just not designed for large applications or asynchronous servers. Flask wants to make it quick and easy to write a traditional web application. Can someone help me understand this, what scalability issues is being mentioned and how other frameworks handle this??
How to keep WSGI from launching multiple instances
9,321,430
2
0
676
0
python,apache,wsgi
Put the WSGI app in daemon mode and tell it to use a single process. Note that this could have a detrimental effect on performance.
0
0
0
1
2012-02-17T00:38:00.000
2
0.197375
false
9,321,335
0
0
1
1
I have a python web application that I have configured in apache as: WSGIScriptAlias /firetalk /scripts/firetalkServer2 When I access this from javascript using XMLHttpRequest, WSGI/Apache end up launching multiple instances which breaks what I am trying to accomplish. So, is there any way to limit WSGI/Apache to a single instance of the specified python script? Thank you.
Is virtualenv recommended for django production server?
9,337,514
50
80
20,184
0
python,django,deployment
I would do it that way if you ever think you'll run more than one project on the webserver. As soon as you have two projects you run the risk of a future upgrade of any python package breaking the other site.
0
0
0
0
2012-02-18T00:03:00.000
6
1.2
true
9,337,149
0
0
1
4
I have always been using virtualenv for testing my app in localhost since I have isolated environment and can safely test new release of packages. Now It comes the time when I have to deploy my app to a production server. I am wondering if I should also use virtualenv for production server or just normal installation should do. Since it's production server I can always use the correct version that I tested in the dev server (under virtual-env)
Is virtualenv recommended for django production server?
41,409,586
0
80
20,184
0
python,django,deployment
Using Docker containers for both development and production deployment is pretty popular now, so if you're considering following this trend, you won't need virtualenv anymore.
0
0
0
0
2012-02-18T00:03:00.000
6
0
false
9,337,149
0
0
1
4
I have always been using virtualenv for testing my app in localhost since I have isolated environment and can safely test new release of packages. Now It comes the time when I have to deploy my app to a production server. I am wondering if I should also use virtualenv for production server or just normal installation should do. Since it's production server I can always use the correct version that I tested in the dev server (under virtual-env)
Is virtualenv recommended for django production server?
9,340,145
3
80
20,184
0
python,django,deployment
In most cases I would agree it is best to have a virtualenv even if it doesn't seem like you need it when you first set up the server. That said if you are using some kind of cloud service and spinning up servers for a specific task for a short time then I don't see the point of using a virtualenv.
0
0
0
0
2012-02-18T00:03:00.000
6
0.099668
false
9,337,149
0
0
1
4
I have always been using virtualenv for testing my app in localhost since I have isolated environment and can safely test new release of packages. Now It comes the time when I have to deploy my app to a production server. I am wondering if I should also use virtualenv for production server or just normal installation should do. Since it's production server I can always use the correct version that I tested in the dev server (under virtual-env)
Is virtualenv recommended for django production server?
9,339,816
15
80
20,184
0
python,django,deployment
Is virtualenv recommended for django production server? Yes, it makes your project not depend on certain aspects of the system environment and also it allows you to make the deployment process more clear and configurable. I use fabric, pip and virtualenv to deploy all my Django projects.
0
0
0
0
2012-02-18T00:03:00.000
6
1
false
9,337,149
0
0
1
4
I have always been using virtualenv for testing my app in localhost since I have isolated environment and can safely test new release of packages. Now It comes the time when I have to deploy my app to a production server. I am wondering if I should also use virtualenv for production server or just normal installation should do. Since it's production server I can always use the correct version that I tested in the dev server (under virtual-env)
Python Computer -to- Android Phone
9,356,229
2
2
604
0
android,python,sl4a
You are talking about Client-Server to set the location of your client. You have to create one server which will be provide you a webservice to submit your data. You can you any web service like xmlrpc, soap ... to fulfill your needs. Python provide the module to develop this services. You have to use SL4A to develop a client script which will be sending data to the server every 5 min.
1
0
0
0
2012-02-20T03:19:00.000
1
1.2
true
9,355,779
0
0
1
1
I am trying to write server code for my python computer and make the android phone a client. The client needs to be able to send its location as well as be able to get data from the server and should run in the background and start itself every 5 minutes or so and send location data to the server. The python side should just receive and send messages as I want to. Can you guys point me in the write direction. I would like to have a GUI for this so should I use the SL4A for the android?