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
Call program from within a browser without using a webserver
1,025,901
0
2
2,904
0
python,html,browser
Try also XML-RPC it gives you a simple way to pass remote procedure calls from YUI towards a simple XMLRPC server and from that towards your rs232 device
0
0
0
0
2009-06-22T07:03:00.000
7
0
false
1,025,817
0
0
1
3
Is there a way to call a program (Python script) from a local HTML page? I have a YUI-colorpicker on that page and need to send its value to a microcontroller via rs232. (There is other stuff than the picker, so I can't code an application instead of an HTML page.) Later, this will migrate to a server, but I need a fast and easy solution now. Thanks.
Call program from within a browser without using a webserver
1,026,086
0
2
2,904
0
python,html,browser
I see no reason why you can't setup a handler for .py/.bat/.vbs files in your browser. This should result in your chosen application running a script when you link to it. This won't work when you migrate to the server but as a testing platform it would work. Just remember to turn it off when you're done or you expose yourself to viruses from other sites.
0
0
0
0
2009-06-22T07:03:00.000
7
0
false
1,025,817
0
0
1
3
Is there a way to call a program (Python script) from a local HTML page? I have a YUI-colorpicker on that page and need to send its value to a microcontroller via rs232. (There is other stuff than the picker, so I can't code an application instead of an HTML page.) Later, this will migrate to a server, but I need a fast and easy solution now. Thanks.
Simple User management example for Google App Engine?
1,030,362
1
17
7,295
1
php,python,google-app-engine
You don't write user management and registration and all that, because you use Google's own authentication services. This is all included in the App Engine documentation.
0
1
0
0
2009-06-23T01:58:00.000
3
0.066568
false
1,030,293
0
0
1
1
I am newbie in Google App Engine. While I was going through the tutorial, I found several things that we do in php-mysql is not available in GAE. For example in dataStore auto increment feature is not available. Also I am confused about session management in GAE. Over all I am confused and can not visualize the whole thing. Please advise me a simple user management system with user registration, user login, user logout, session (create,manage,destroy) with data Store. Also please advise me where I can get simple but effective examples. Thanks in advance.
Python/Django or C#/ASP.NET for web development?
1,031,492
14
7
7,667
0
asp.net,python,django,scalability
Almost all the well known frameworks and languages can scale. It doesn't really matter which one you use. Its about how well you structure the code that matters most. On a personal level it is always good to know more than one language. But, you can create perfectly scalable Python, PHP, .NET applications. The quality of the code is the first place scalability will fall down not the language.
0
0
0
0
2009-06-23T09:01:00.000
4
1
false
1,031,438
1
0
1
4
I am a .NET developer. I have no experience on Python. Which platform is more scalable? Which platform is more suitable for large-size high-traffic web sites? If you have any experience about scalability on these platforms, please inform us. Thank you.
Python/Django or C#/ASP.NET for web development?
1,036,254
3
7
7,667
0
asp.net,python,django,scalability
Derek had a great answer, so I won't repeat it. I would like to make one observation, however. While for the most part, the language choice isn't really a big deal these days, if you really need high performance and scalability, the dynamic nature of python might come back to haunt you. For all the benefits that a dynamic language can provide, those benefits do come at the cost of additional overhead. The .NET platform offers fully compiled languages, and offers a variety of ways to tune the performance of compiled code (including ngen support, so you can create natively compiled modules that do not need to be JITted.) I do not know if the performance edge .NET compiled languages have over Python is really enough for your particular application, but given that you are already a .NET developer, going with ASP.NET might be the best option.
0
0
0
0
2009-06-23T09:01:00.000
4
0.148885
false
1,031,438
1
0
1
4
I am a .NET developer. I have no experience on Python. Which platform is more scalable? Which platform is more suitable for large-size high-traffic web sites? If you have any experience about scalability on these platforms, please inform us. Thank you.
Python/Django or C#/ASP.NET for web development?
3,224,766
1
7
7,667
0
asp.net,python,django,scalability
There is a added scalability cost with going with .NET over Python, the cost of Windows Server licenses (at the minimum, you usually add SQL Server to that as well).
0
0
0
0
2009-06-23T09:01:00.000
4
0.049958
false
1,031,438
1
0
1
4
I am a .NET developer. I have no experience on Python. Which platform is more scalable? Which platform is more suitable for large-size high-traffic web sites? If you have any experience about scalability on these platforms, please inform us. Thank you.
Python/Django or C#/ASP.NET for web development?
1,036,216
16
7
7,667
0
asp.net,python,django,scalability
Much as I love Python (and, that's a LOT!-), if you're highly skilled at C# and, as you say, "have no experience on Python", your code will be more scalable and suitable (for the next several months, at least) if you stick with what you know best. For a hypothetical developer extremely skilled at both platforms, scalability would essentially be a wash, and Python would enhance that developer's productivity; but getting really good at any technology takes some months of practice, it doesn't "just happen" magically. So, unless you're trying to broaden your range of skills and job opportunities, or enhance your productivity, but rather are specifically, strictly focused on the scalability of the web apps you're coding right now, I have, in good conscience, to recommend you stick with C#. You should also try IronPython (and get the great "IronPython in Action" book from Mannings -- bias alert, I'm friends with the author and was a tech reviewer of that book;-) for all sorts of non-production supporting code, to get a taste of it and the incredible productivity boost it can give you... but, to deliver best value to your clients or employers, stick with what you REALLY master, C#, for any scalability-critical work you deliver to them!
0
0
0
0
2009-06-23T09:01:00.000
4
1.2
true
1,031,438
1
0
1
4
I am a .NET developer. I have no experience on Python. Which platform is more scalable? Which platform is more suitable for large-size high-traffic web sites? If you have any experience about scalability on these platforms, please inform us. Thank you.
how to addreference to Ritmo for iSeries in ironpython
1,034,326
0
0
438
0
c#,ironpython
Jonathan helped me to figure out that I had not copied the dll file to the location where IronPython can find it. After copying the dll file to the location, usually it s "c:\Program Files\IronPython 2.0\" unless stated otherwise, I did: import clr clr.AddReference('System.Data') clr.AddReferenceToFile('Sql400.dll') from System.Data import Sql400 from System.Data.Sql400 import *
0
0
0
0
2009-06-23T14:24:00.000
2
0
false
1,032,888
0
0
1
2
I was just wondering if anybody knows how to add reference to "Ritmo for iSeries" in IronPython. I did it successfully in C# and get it to work (since it is just click click click) And I was trying to do the same in IronPython but it says, "could not add reference to assembly Ritmo for iSeries". I was doing import clr clr.AddReference('Ritmo for iSeries') from Ritmo........ IOError: Could not add reference to assembly Ritmo for iSeries
how to addreference to Ritmo for iSeries in ironpython
1,032,962
0
0
438
0
c#,ironpython
You need to use the actual name of the assembly (it won't have spaces). In your C# project, what does it list under the 'references' folder once you've added it as a reference? Try putting that. Also, make sure you've copied the dll for the library to where your IronPython script can find it (if it's not in the GAC).
0
0
0
0
2009-06-23T14:24:00.000
2
0
false
1,032,888
0
0
1
2
I was just wondering if anybody knows how to add reference to "Ritmo for iSeries" in IronPython. I did it successfully in C# and get it to work (since it is just click click click) And I was trying to do the same in IronPython but it says, "could not add reference to assembly Ritmo for iSeries". I was doing import clr clr.AddReference('Ritmo for iSeries') from Ritmo........ IOError: Could not add reference to assembly Ritmo for iSeries
Per-session transactions in Django
1,121,915
2
8
2,065
1
python,django,transactions
I came up with something similar to the Memento pattern, but different enough that I think it bears posting. When a user starts an editing session, I duplicate the target object to a temporary object in the database. All subsequent editing operations affect the duplicate. Instead of saving the object state in a memento at each change, I store operation objects. When I apply an operation to an object, it returns the inverse operation, which I store. Saving operations is much cheaper for me than mementos, since the operations can be described with a few small data items, while the object being edited is much bigger. Also I apply the operations as I go and save the undos, so that the temporary in the db always corresponds to the version in the user's browser. I never have to replay a collection of changes; the temporary is always only one operation away from the next version. To implement "undo," I pop the last undo object off the stack (as it were--by retrieving the latest operation for the temporary object from the db) apply it to the temporary and return the transformed temporary. I could also push the resultant operation onto a redo stack if I cared to implement redo. To implement "save changes," i.e. commit, I de-activate and time-stamp the original object and activate the temporary in it's place. To implement "cancel," i.e. rollback, I do nothing! I could delete the temporary, of course, because there's no way for the user to retrieve it once the editing session is over, but I like to keep the canceled edit sessions so I can run stats on them before clearing them out with a cron job.
0
0
0
0
2009-06-23T17:16:00.000
3
0.132549
false
1,033,934
0
0
1
1
I'm making a Django web-app which allows a user to build up a set of changes over a series of GETs/POSTs before committing them to the database (or reverting) with a final POST. I have to keep the updates isolated from any concurrent database users until they are confirmed (this is a configuration front-end), ruling out committing after each POST. My preferred solution is to use a per-session transaction. This keeps all the problems of remembering what's changed (and how it affects subsequent queries), together with implementing commit/rollback, in the database where it belongs. Deadlock and long-held locks are not an issue, as due to external constraints there can only be one user configuring the system at any one time, and they are well-behaved. However, I cannot find documentation on setting up Django's ORM to use this sort of transaction model. I have thrown together a minimal monkey-patch (ew!) to solve the problem, but dislike such a fragile solution. Has anyone else done this before? Have I missed some documentation somewhere? (My version of Django is 1.0.2 Final, and I am using an Oracle database.)
Any Python Script to Save Websites Like Firefox?
1,035,855
1
3
2,633
0
python
Like Cobbal stated, this is largely what wget is designed to do. I believe there's some flags/arguments that you can set to make it download the entire page, CSS + all. I suggest just alias-ing into something more convenient to type, or tossing it into a quick script.
0
0
1
0
2009-06-23T23:40:00.000
5
0.039979
false
1,035,825
0
0
1
1
I am tired of clicking "File" and then "Save Page As" in Firefox when I want to save some websites. Is there any script to do this in Python? I would like to save the pictures and css files so that when I read it offline, it looks normal.
Python Web-based Bot
1,036,758
0
3
6,042
0
python,html,bots
Well obviously python won't interpret the JS for you (though there may be modules out there that can). I suppose you need to convert the JS instructions to equivalent transformations in Python. I suppose ElementTree or BeautifulSoup would be good starting points to interpret the HTML structure.
0
0
1
0
2009-06-24T06:15:00.000
7
0
false
1,036,660
0
0
1
2
I am trying to write a Python-based Web Bot that can read and interpret an HTML page, then execute an onClick function and receive the resulting new HTML page. I can already read the HTML page and I can determine the functions to be called by the onClick command, but I have no idea how to execute those functions or how to receive the resulting HTML code. Any ideas?
Python Web-based Bot
5,873,989
0
3
6,042
0
python,html,bots
Why don't you just sniff what gets sent after the onclick event and replicate that with your bot?
0
0
1
0
2009-06-24T06:15:00.000
7
0
false
1,036,660
0
0
1
2
I am trying to write a Python-based Web Bot that can read and interpret an HTML page, then execute an onClick function and receive the resulting new HTML page. I can already read the HTML page and I can determine the functions to be called by the onClick command, but I have no idea how to execute those functions or how to receive the resulting HTML code. Any ideas?
HTML conversion
14,180,592
0
0
677
0
wxpython
stylesheet, not slidesheet. f = open('NAMEOFSTYLESHEET.css','w') f.write('#ID{}\n.class{}')
1
0
0
0
2009-06-24T12:54:00.000
3
0
false
1,038,182
0
0
1
1
How to convert HTML CSS file to wxPython files? That is, how to create slidsheet in wxPython like HTML CSS files?
how to use french letters in a django template?
1,063,665
7
5
4,002
0
python,django,unicode
You are probably storing the template in a non-unicode encoding, such as latin-1. I believe Django assumes that templates are in UTF-8 by default (though there is a setting to override this). Your editor should be capable of saving the template file in the UTF-8 encoding (probably via a dropdown on the save as page, though this may depend on your editor). Re-save the file as UTF-8, and the error should go away.
0
0
0
0
2009-06-30T13:14:00.000
2
1.2
true
1,063,626
0
0
1
1
I have some french letters (é, è, à...) in a django template but when it is loaded by django, an UnicodeDecodeError exception is raised. If I don't load the template but directly use a python string. It works ok. Is there something to do to use unicode with django template?
What is the best way to add an API to a Django application?
1,064,563
2
2
299
0
python,django,api,django-models,django-admin
Web services API's are just more URL's. These WS API URL's map to view functions. The WS view functions handle GET and POST (and possibly PUT and DELETE). The WS view functions use Forms as well as the Models to make things happen. It is, in a way, like an admin interface. Except, there's no HTML. The WS view functions respond with JSON messages or XML messages.
0
0
0
0
2009-06-30T15:56:00.000
2
0.197375
false
1,064,520
0
0
1
1
I am adding MetaWeblog API support to a Django CMS, and am not quite sure how to layer the application. I am using django_xmlrpc, which allows me to map to parameterised functions for each request. It is just a case of what level do I hook in calls to the django application from the service functions (AddPage, EditPage etc) For django-page-cms, and I suppose many django apps, the business logic and validation is contained within the forms. In this case there is PageForm(forms.ModelForm) and PageAdmin(ModelAdmin), which both contain a lot of logic and validation. If I am to build an API to allow maintenance of pages and content, does this mean I should be programmatically creating and filling a PageAdmin instance? Then catching any exceptions, and converting to their api equivalent? Or would this be a bad idea - misusing what forms are intended for? The other option is refactoring the code so that business and logic is kept outside of the form classes. Then I would have the form and api, both go through the separate business logic. Any other alternatives? What would be the best solution?
Django way to do conditional formatting
1,068,601
2
8
6,131
0
python,django,formatting,django-templates
Since you are doing static comparison (no queries needed), you should go for the most DRY and easy to implement option. In this case, I would go for option 4, make a template filter. Then you could do value|filter to get the class you would need to set the background colour. Template filters are actually a bit simpler than template tags to implement.
0
0
0
0
2009-07-01T11:21:00.000
4
0.099668
false
1,068,573
0
0
1
1
What is the correct way to do conditional formatting in Django? I have a model that contains a date field, and I would like to display a list of records, but colour the rows depending on the value of that date field. For example, records that match today's date I want to be yellow, records that is before today I want green and ones after I want red. Somewhere in Django you will need to do that comparison, comparing the current date with the date in the record. I can see three different places that comparison could be done: Add a method to my model, for example, status(), that returns either 'past', 'present', 'future' and then use that in the template to colour the rows. In the view instead of returning a queryset to the template, pre-process the list and compare each record, build a new dict containing the 'past', 'present' and 'future' values to be used in the template Create a new template tag that does the comparison. Which of these methods is the correct Django way of doing it? It sounds like conditional formating is something that would come up quite often, and since you can't do arbitrary comparisons in the template some other solution is needed. The same would apply for simpler formatting rules, for example, if I wanted to display a list of student grades, and I wanted to make the ones higher than 80% green and the ones below 30% red.
user friendly framework for personal website?
1,073,087
-1
7
6,057
0
php,python,frameworks
Kentico,Umbraco and Sitefinity,DotNetNuke are meant for developers/designers/integrators. Use Wordpress or if you are looking for .NET version use Community server.
0
0
0
0
2009-07-02T07:02:00.000
8
-0.024995
false
1,072,920
0
0
1
2
Hi, Which are the user friendly frameworks for building personal sites? Specially if that comes with little programming knowledge. And integrated jquery will be great. python or php based framework will do better. I tried wordpress and joomla! But those are far more complex for a simple personal site with personal blogging, live commenting, twitting, keeping personal projects and resume etc. Please suggest me. Thanks in advance.
user friendly framework for personal website?
22,913,432
0
7
6,057
0
php,python,frameworks
AnchorCMS gets a lot of good feedback, give it a try.
0
0
0
0
2009-07-02T07:02:00.000
8
0
false
1,072,920
0
0
1
2
Hi, Which are the user friendly frameworks for building personal sites? Specially if that comes with little programming knowledge. And integrated jquery will be great. python or php based framework will do better. I tried wordpress and joomla! But those are far more complex for a simple personal site with personal blogging, live commenting, twitting, keeping personal projects and resume etc. Please suggest me. Thanks in advance.
How to debug SCons scripts using eclipse and pydev?
1,075,694
3
4
2,414
0
python,eclipse,pydev,scons
I'm not an Eclipse expert, but since you didn't get any other answer... If you make the SCons source a part of the Eclipse project, and run the whole command from within Eclipse it should work like any Eclipse debugging. SCons is written in Python, there is no reason it shouldn't be debuggable in Eclipse just like anything else.
0
1
0
1
2009-07-02T16:16:00.000
6
1.2
true
1,075,304
0
0
1
5
I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?
How to debug SCons scripts using eclipse and pydev?
45,216,082
0
4
2,414
0
python,eclipse,pydev,scons
As an addendum: on Windows, I had to copy the scons-installed files to reside under C:\Python27\Lib\site-packages\scons in order for this to work. Adding the original installed location, qualified with the version number, to the PYTHONPATH, did not work.
0
1
0
1
2009-07-02T16:16:00.000
6
0
false
1,075,304
0
0
1
5
I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?
How to debug SCons scripts using eclipse and pydev?
15,386,322
1
4
2,414
0
python,eclipse,pydev,scons
On MAC to debug scons through pydev follow Lennart's answer but with one simply addition. Using Finder (or terminal) browse to where scons is installed. You can find this with the "which" command. e.g. which scons -> /usr/local/bin/scons Make a copy of the scons file and call it scons.py. Now when you create the Debug Configuration in Eclipse use scons.py as the "Main Module". PS: To add a scons project to Eclipse I found it easier to use a "Linked Folder" pointing at /usr/local/bin/. i.e. Because I was getting a read-only error when trying to add the directory itself.
0
1
0
1
2009-07-02T16:16:00.000
6
0.033321
false
1,075,304
0
0
1
5
I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?
How to debug SCons scripts using eclipse and pydev?
1,077,102
6
4
2,414
0
python,eclipse,pydev,scons
You are right. Since the SCons is python based, the SCons scripts are debuggable via EClipse PyDev. For this, you need to do the following in the debug configuration... 1. Under the main tab, set the main module to the SCons file which will be available under the python/scripts directory if you have installed SCons. If you have not run the install of SCons you can point to this file under the SCons directory. 2. Under the arguments tab, set the working directory to the root of your project. Now set the breakpoint either on SConstruct or SConcript and run in debug mode. That's all!! With this approach you can not only debug your product code but also the build scripts that builds your product :-) Happy Debugging!!!!
0
1
0
1
2009-07-02T16:16:00.000
6
1
false
1,075,304
0
0
1
5
I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?
How to debug SCons scripts using eclipse and pydev?
32,887,089
0
4
2,414
0
python,eclipse,pydev,scons
I've since gain more experience with SCons / Python and I'd recommend using python's pdb module. To use it simply add the following code to your SCons/Python files. import pdb; pdb.set_trace() When the file is run from the command line a breakpoint will be hit at this line. I also moved away from Eclipse. A lightweight editor will be just as good for Python development. I use Sublime.
0
1
0
1
2009-07-02T16:16:00.000
6
0
false
1,075,304
0
0
1
5
I'm a newbie to SCons and also using pydev. Can someone help me with instructions on how to debug scons scripts using Eclipse and pydev? Is it even possible considering the fact that SCons is a seperate app and not an extension to python?
Restarting a Django application running on Apache + mod_python
1,078,235
-1
8
7,641
0
python,django,mod-python
Use a test server included in Django. (like ./manage.py runserver 0.0.0.0:8080) It will do most things you would need during development. The only drawback is that it cannot handle simultaneous requests with multi-threading. I've heard that there is a trick that setting Apache's max instances to 1 so that every code change is reflected immediately--but because you said you're running other services, so this may not be your case.
0
0
0
0
2009-07-03T07:23:00.000
4
-0.049958
false
1,078,166
0
0
1
2
I'm running a Django app on Apache + mod_python. When I make some changes to the code, sometimes they have effect immediately, other times they don't, until I restart Apache. However I don't really want to do that since it's a production server running other stuff too. Is there some other way to force that? Just to make it clear, since I see some people get it wrong, I'm talking about a production environment. For development I'm using Django's development server, of course.
Restarting a Django application running on Apache + mod_python
1,078,289
1
8
7,641
0
python,django,mod-python
You can reduce number of connections to 1 by setting "MaxRequestsPerChild 1" in your httpd.conf file. But do it only on test server, not production. or If you don't want to kill existing connections and still restart apache you can restart it "gracefully" by performing "apache2ctl gracefully" - all existing connections will be allowed to complete.
0
0
0
0
2009-07-03T07:23:00.000
4
0.049958
false
1,078,166
0
0
1
2
I'm running a Django app on Apache + mod_python. When I make some changes to the code, sometimes they have effect immediately, other times they don't, until I restart Apache. However I don't really want to do that since it's a production server running other stuff too. Is there some other way to force that? Just to make it clear, since I see some people get it wrong, I'm talking about a production environment. For development I'm using Django's development server, of course.
Deploying a Web.py application with WSGI, several servers
1,406,572
0
7
6,152
0
python,wsgi,web.py
Here is an example of two hosted apps using cherrypy wsgi server: #!/usr/bin/python from web import wsgiserver import web # webpy wsgi app urls = ( '/test.*', 'index' ) class index: def GET(self): web.header("content-type", "text/html") return "Hello, world1!" application = web.application(urls, globals(), autoreload=False).wsgifunc() # generic wsgi app def my_blog_app(environ, start_response): status = '200 OK' response_headers = [('Content-type','text/plain')] start_response(status, response_headers) return ['Hello world! - blog\n'] """ # single hosted app server = wsgiserver.CherryPyWSGIServer( ('0.0.0.0', 8070), application, server_name='www.cherrypy.example') """ # multiple hosted apps with WSGIPathInfoDispatcher d = wsgiserver.WSGIPathInfoDispatcher({'/test': application, '/blog': my_blog_app}) server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 8070), d) server.start()
0
0
0
0
2009-07-03T09:35:00.000
3
0
false
1,078,599
0
0
1
1
I've created a web.py application, and now that it is ready to be deployed, I want to run in not on web.py's built-in webserver. I want to be able to run it on different webservers, Apache or IIS, without having to change my application code. This is where WSGI is supposed to come in, if I understand it correctly. However, I don't understand what exacly I have to do to make my application deployable on a WSGI server? Most examples assume you are using Pylons/Django/other-framework, on which you simply run some magic command which fixes everything for you. From what I understand of the (quite brief) web.py documentation, instead of running web.application(...).run(), I should use web.application(...).wsgifunc(). And then what?
How to put Google login box inside flash in GAE?
1,353,761
1
0
237
0
python,flash,google-app-engine,authentication
Of course this is possible you just need to use flash to post http request to your server and your server could communicate to flash through several ways like: xml , html, and AMF or even johnson( I am not sure). I recommend you use pyamf at server side to build a native support for flash at server side
0
0
0
0
2009-07-03T11:50:00.000
1
0.197375
false
1,079,022
0
0
1
1
I am putting my old flash site into GAE. I want to use Google's user authentication too. Now, I want to put Googles login box inside the flash instead of redirecting to Google's login page. Same thing I want for forgot password. Is it possible to do this? How to do this?
How to check available Python libraries on Google App Engine & add more
1,085,550
1
1
1,050
0
python,google-app-engine,sqlite
Afaik, you can only use the GAE specific database.
0
1
0
0
2009-07-06T05:23:00.000
2
0.099668
false
1,085,538
0
0
1
1
How to check available Python libraries on Google App Engine & add more? Is SQLite available or we must use GQL with their database system only? Thank you in advance.
Django file upload input validation and security
5,921,094
2
4
4,001
0
python,django,security,file-upload
Also, you might want to put the target files outside Apache's DocumentRoot directory, so that they are not reachable by any URL. Rules in .htaccess offer a certain amount of protection if they're written well, but if you're seeking for maximum security, just put the files away from web-reachable directory.
0
0
0
0
2009-07-07T22:50:00.000
2
0.197375
false
1,095,250
0
0
1
2
I'm creating a very simple django upload application but I want to make it as secure as possible. This is app is going to be completely one way, IE. anybody who uploads a file will never have to retrieve it. So far I've done the following: Disallow certain file extensions (.php, .html, .py, .rb, .pl, .cgi, .htaccess, etc) Set a maximum file size limit and file name character length limit. Password protected the directory that the files are uploaded to (with .htaccess owned by root so the web server cannot possibly overwrite it) Assuming that apache and mod_python are on the front end of this and that apache itself has been secured, are there any other "best practice" things I should do or consider to protect my application? Thanks in advance.
Django file upload input validation and security
1,095,662
7
4
4,001
0
python,django,security,file-upload
Disallowing a file extension is -- potentially -- a waste of time. A unix server doesn't use the extension -- it uses ownership and permissions. When accepting an upload, you will often rename the file to prevent it being misused. Uploaded files should be simply named "upload_xxx" with the "xxx" being a key to some database record that provides the claimed name and data type. You have to actually read the file and confirm that the content of the file is what someone claims it is. For example, if they claim to upload a .JPG, you have to actually read the file to be sure it's a JPEG, not an .EXE.
0
0
0
0
2009-07-07T22:50:00.000
2
1.2
true
1,095,250
0
0
1
2
I'm creating a very simple django upload application but I want to make it as secure as possible. This is app is going to be completely one way, IE. anybody who uploads a file will never have to retrieve it. So far I've done the following: Disallow certain file extensions (.php, .html, .py, .rb, .pl, .cgi, .htaccess, etc) Set a maximum file size limit and file name character length limit. Password protected the directory that the files are uploaded to (with .htaccess owned by root so the web server cannot possibly overwrite it) Assuming that apache and mod_python are on the front end of this and that apache itself has been secured, are there any other "best practice" things I should do or consider to protect my application? Thanks in advance.
Pylons/Routes rewrite POST or GET to fancy URL
1,096,315
2
2
1,116
0
python,routes,pylons
HTML forms are designed to go to a specific URL with a query string (?q=) or an equivalent body in a POST -- either you write clever and subtle Javascript to intercept the form submission and rewrite it in your preferred weird way, or use redirect_to (and the latter will take some doing). But why do you need such weird behavior rather than just following the standard?! Please explain your use case in terms of application-level needs...!
0
0
0
0
2009-07-08T05:49:00.000
2
0.197375
false
1,096,300
0
0
1
2
The behavior I propose: A user loads up my "search" page, www.site.com/search, types their query into a form, clicks submit, and then ends up at www.site.com/search/the+query instead of www.site.com/search?q=the+query. I've gone through a lot of the Pylons documentation already and just finished reading the Routes documentation and am wondering if this can/should happen at the Routes layer. I have already set up my application to perform a search when given www.site.com/search/the+query, but can not figure out how to send a form to this destination. Or is this something that should happen inside a controller with a redirect_to()? Or somewhere else? Followup: This is less an actual "set in stone" desire right now and more a curiosity for brainstorming future features. I'm designing an application which uses a Wikipedia dump and have observed that when a user performs a search on Wikipedia and the search isn't too ambiguous it redirects directly to an article link: en.wikipedia.org/wiki/Apple. It is actually performing an in-between HTTP 302 redirect step, and I am just curious if there's a more elegant/cute way of doing this in Pylons.
Pylons/Routes rewrite POST or GET to fancy URL
1,097,943
2
2
1,116
0
python,routes,pylons
You can send whatever content you want for any URL, but if you want a particular URL to appear in the browser's address bar, you have to use a redirect. This is independent of whether you use Pylons, Django or Rails on the server side. In the handling for /search (whether POST or GET), one would normally run the query in the back end, and if there was only one search result (or one overwhelmingly relevant result) you would redirect to that result, otherwise to a page showing links to the top N results. That's just normal practice, AFAIK.
0
0
0
0
2009-07-08T05:49:00.000
2
1.2
true
1,096,300
0
0
1
2
The behavior I propose: A user loads up my "search" page, www.site.com/search, types their query into a form, clicks submit, and then ends up at www.site.com/search/the+query instead of www.site.com/search?q=the+query. I've gone through a lot of the Pylons documentation already and just finished reading the Routes documentation and am wondering if this can/should happen at the Routes layer. I have already set up my application to perform a search when given www.site.com/search/the+query, but can not figure out how to send a form to this destination. Or is this something that should happen inside a controller with a redirect_to()? Or somewhere else? Followup: This is less an actual "set in stone" desire right now and more a curiosity for brainstorming future features. I'm designing an application which uses a Wikipedia dump and have observed that when a user performs a search on Wikipedia and the search isn't too ambiguous it redirects directly to an article link: en.wikipedia.org/wiki/Apple. It is actually performing an in-between HTTP 302 redirect step, and I am just curious if there's a more elegant/cute way of doing this in Pylons.
Why is Ruby more suitable for Rails than Python?
1,100,263
-6
91
14,973
0
python,ruby-on-rails,ruby,web-frameworks
All of this is TOTALLY "IMHO" In Ruby there is ONE web-application framework, so it is the only framework that is advertised for that language. Python has had several since inception, just to name a few: Zope, Twisted, Django, TurboGears (it itself a mix of other framework components), Pylons (a kinda-clone of the Rails framework), and so on. None of them are python-community-wide supported as "THE one to use" so all the "groundswell" is spread over several projects. Rails has the community size solely, or at least in the vast majority, because of Rails. Both Python and Ruby are perfectly capable of doing the job as a web applications framework. Use the one YOU (and your potential development team) like and can align on.
0
0
0
0
2009-07-08T16:55:00.000
13
-1
false
1,099,305
1
0
1
10
Python and Ruby are usually considered to be close cousins (though with quite different historical baggage) with similar expressiveness and power. But some have argued that the immense success of the Rails framework really has a great deal to do with the language it is built on: Ruby itself. So why would Ruby be more suitable for such a framework than Python?
Why is Ruby more suitable for Rails than Python?
1,099,320
1
91
14,973
0
python,ruby-on-rails,ruby,web-frameworks
Some have said that the type of metaprogramming required to make ActiveRecord (a key component of rails) possible is easier and more natural to do in ruby than in python - I do not know python yet;), so i cannot personally confirm this statement. I have used rails briefly, and its use of catchalls/interceptors and dynamic evaluation/code injection does allow you to operate at a much higher level of abstraction than some of the other frameworks (before its time). I have little to no experience with Python's framework - but i've heard it's equally capable - and that the python community does a great job supporting and fostering pythonic endeavors.
0
0
0
0
2009-07-08T16:55:00.000
13
0.015383
false
1,099,305
1
0
1
10
Python and Ruby are usually considered to be close cousins (though with quite different historical baggage) with similar expressiveness and power. But some have argued that the immense success of the Rails framework really has a great deal to do with the language it is built on: Ruby itself. So why would Ruby be more suitable for such a framework than Python?
Why is Ruby more suitable for Rails than Python?
1,123,890
4
91
14,973
0
python,ruby-on-rails,ruby,web-frameworks
I suppose we should not discuss the language features per se but rather the accents the respective communities make on the language features. For example, in Python, re-opening a class is perfectly possible but it is not common; in Ruby, however, re-opening a class is something of the daily practice. this allows for a quick and straightforward customization of the framework to the current requirement and renders Ruby more favorable for Rails-like frameworks than any other dynamic language. Hence my answer: common use of re-opening classes.
0
0
0
0
2009-07-08T16:55:00.000
13
0.061461
false
1,099,305
1
0
1
10
Python and Ruby are usually considered to be close cousins (though with quite different historical baggage) with similar expressiveness and power. But some have argued that the immense success of the Rails framework really has a great deal to do with the language it is built on: Ruby itself. So why would Ruby be more suitable for such a framework than Python?
Why is Ruby more suitable for Rails than Python?
2,040,561
-1
91
14,973
0
python,ruby-on-rails,ruby,web-frameworks
Two answers : a. Because rails was written for ruby. b. For the same reason C more suitable for Linux than Ruby
0
0
0
0
2009-07-08T16:55:00.000
13
-0.015383
false
1,099,305
1
0
1
10
Python and Ruby are usually considered to be close cousins (though with quite different historical baggage) with similar expressiveness and power. But some have argued that the immense success of the Rails framework really has a great deal to do with the language it is built on: Ruby itself. So why would Ruby be more suitable for such a framework than Python?
Why is Ruby more suitable for Rails than Python?
1,204,243
1
91
14,973
0
python,ruby-on-rails,ruby,web-frameworks
I think that the syntax is cleaner and Ruby, for me at least, is just a lot more "enjoyable"- as subjective as that is!
0
0
0
0
2009-07-08T16:55:00.000
13
0.015383
false
1,099,305
1
0
1
10
Python and Ruby are usually considered to be close cousins (though with quite different historical baggage) with similar expressiveness and power. But some have argued that the immense success of the Rails framework really has a great deal to do with the language it is built on: Ruby itself. So why would Ruby be more suitable for such a framework than Python?
Why is Ruby more suitable for Rails than Python?
1,104,198
15
91
14,973
0
python,ruby-on-rails,ruby,web-frameworks
The real answer is neither Python or Ruby are better/worse candidates for a web framework. If you want objectivity you need to write some code in both and see which fits your personal preference best, including community. Most people who argue for one or other have either never used the other language seriously or are 'voting' for their personal preference. I would guess most people settle on which ever they come in to contact with first because it teaches them something new (MVC, testing, generators etc.) or does something better (plugins, templating etc). I used to develop with PHP and came in to contact with RubyOnRails. If I had have known about MVC before finding Rails I would more than likely never left PHP behind. But once I started using Ruby I enjoyed the syntax, features etc. If I had have found Python and one of its MVC frameworks first I would more than likely be praising that language instead!
0
0
0
0
2009-07-08T16:55:00.000
13
1
false
1,099,305
1
0
1
10
Python and Ruby are usually considered to be close cousins (though with quite different historical baggage) with similar expressiveness and power. But some have argued that the immense success of the Rails framework really has a great deal to do with the language it is built on: Ruby itself. So why would Ruby be more suitable for such a framework than Python?
Why is Ruby more suitable for Rails than Python?
1,100,340
53
91
14,973
0
python,ruby-on-rails,ruby,web-frameworks
The python community believes that doing things the most simple and straight forward way possible is the highest form of elegance. The ruby community believes doing things in clever ways that allow for cool code is the highest form of elegance. Rails is all about if you follow certain conventions, loads of other things magically happen for you. That jives really well with the ruby way of looking at the world, but doesn't really follow the python way.
0
0
0
0
2009-07-08T16:55:00.000
13
1
false
1,099,305
1
0
1
10
Python and Ruby are usually considered to be close cousins (though with quite different historical baggage) with similar expressiveness and power. But some have argued that the immense success of the Rails framework really has a great deal to do with the language it is built on: Ruby itself. So why would Ruby be more suitable for such a framework than Python?
Why is Ruby more suitable for Rails than Python?
1,127,435
8
91
14,973
0
python,ruby-on-rails,ruby,web-frameworks
Because Rails is developed to take advantage of Rubys feature set. A similarly gormless question would be "Why is Python more suitable for Django than Ruby is?".
0
0
0
0
2009-07-08T16:55:00.000
13
1
false
1,099,305
1
0
1
10
Python and Ruby are usually considered to be close cousins (though with quite different historical baggage) with similar expressiveness and power. But some have argued that the immense success of the Rails framework really has a great deal to do with the language it is built on: Ruby itself. So why would Ruby be more suitable for such a framework than Python?
Why is Ruby more suitable for Rails than Python?
1,099,454
11
91
14,973
0
python,ruby-on-rails,ruby,web-frameworks
Python has a whole host of Rails-like frameworks. There are so many that a joke goes that during the typical talk at PyCon at least one web framework will see the light. The argument that Rubys meta programming would make it better suited is IMO incorrect. You don't need metaprogramming for frameworks like this. So I think we can conclude that Ruby are not better (and likely neither worse) than Python in this respect.
0
0
0
0
2009-07-08T16:55:00.000
13
1
false
1,099,305
1
0
1
10
Python and Ruby are usually considered to be close cousins (though with quite different historical baggage) with similar expressiveness and power. But some have argued that the immense success of the Rails framework really has a great deal to do with the language it is built on: Ruby itself. So why would Ruby be more suitable for such a framework than Python?
Why is Ruby more suitable for Rails than Python?
1,141,854
26
91
14,973
0
python,ruby-on-rails,ruby,web-frameworks
Is this debate a new "vim versus emacs" debate? I am a Python/Django programmer and thus far I've never found a problem in that language/framework that would lead me to switch to Ruby/Rails. I can imagine that it would be the same if I were experienced with Ruby/Rails. Both have similar philosophy and do the job in a fast and elegant way. The better choice is what you already know.
0
0
0
0
2009-07-08T16:55:00.000
13
1
false
1,099,305
1
0
1
10
Python and Ruby are usually considered to be close cousins (though with quite different historical baggage) with similar expressiveness and power. But some have argued that the immense success of the Rails framework really has a great deal to do with the language it is built on: Ruby itself. So why would Ruby be more suitable for such a framework than Python?
Best way to denormalize data in Django?
1,101,410
17
16
5,270
0
python,mysql,django
You have managers in Django. Use a customized manager to do creates and maintain the FK relationships. The manager can update the counts as the sets of children are updated. If you don't want to make customized managers, just extend the save method. Everything you want to do for denormalizing counts and sums can be done in save. You don't need signals. Just extend save.
0
0
0
0
2009-07-08T22:41:00.000
5
1.2
true
1,100,924
0
0
1
2
I'm developing a simple web app, and it makes a lot of sense to store some denormalized data. Imagine a blogging platform that keeps track of Comments, and the BlogEntry model has a "CommentCount" field that I'd like to keep up to date. One way of doing this would be to use Django signals. Another way of doing this would be to put hooks directly in my code that creates and destrys Comment objects to synchronously call some methods on BlogEntry to increment/decrement the comment count. I suppose there are other pythonic ways of accomplishing this with decorators or some other voodoo. What is the standard Design Pattern for denormalizing in Django? In practice, do you also have to write consistency checkers and data fixers in case of errors?
Best way to denormalize data in Django?
1,101,004
5
16
5,270
0
python,mysql,django
The first approach (signals) has the advantage to loose the coupling between models. However, signals are somehow more difficult to maintain, because dependencies are less explicit (at least, in my opinion). If the correctness of the comment count is not so important, you could also think of a cron job that will update it every n minutes. However, no matter the solution, denormalizing will make maintenance more difficult; for this reason I would try to avoid it as much as possible, resolving instead to using caches or other techniques -- for example, using with comments.count as cnt in templates may improve performance quite a lot. Then, if everything else fails, and only in that case, think about what could be the best approach for the specific problem.
0
0
0
0
2009-07-08T22:41:00.000
5
0.197375
false
1,100,924
0
0
1
2
I'm developing a simple web app, and it makes a lot of sense to store some denormalized data. Imagine a blogging platform that keeps track of Comments, and the BlogEntry model has a "CommentCount" field that I'd like to keep up to date. One way of doing this would be to use Django signals. Another way of doing this would be to put hooks directly in my code that creates and destrys Comment objects to synchronously call some methods on BlogEntry to increment/decrement the comment count. I suppose there are other pythonic ways of accomplishing this with decorators or some other voodoo. What is the standard Design Pattern for denormalizing in Django? In practice, do you also have to write consistency checkers and data fixers in case of errors?
Is there a way to plan and diagram an architecture for dynamic scripting languages like groovy or python?
1,102,219
3
1
359
0
python,architecture,groovy,uml,dynamic-languages
UML isn't too well equipped to handle such things, but you can still use it to communicate your design if you are willing to do some mental mapping. You can find an isomorphism between most dynamic concepts and UMLs static object-model. For example you can think of a closure as an object implementing a one method interface. It's probably useful to model such interfaces as something a bit more specific than interface Callable { call(args[0..*]: Object) : Object }. Duck typing can similarly though of as an interface. If you have a method that takes something that can quack, model it as taking an object that is a specialization of the interface _interface Quackable { quack() }. You can use your imagination for other concepts. Keep in mind that the purpose of design diagrams is to communicate ideas. So don't get overly pedantic about modeling everything 100%, think what do you want your diagrams to say, make sure that they say that and eliminate any extraneous detail that would dilute the message. And if you use some concepts that aren't obvious to your target audience, explain them. Also, if UML really can't handle what you want to say, try other ways to visualize your message. UML is only a good choice because it gives you a common vocabulary so you don't have to explain every concept on your diagram.
0
1
0
0
2009-07-09T06:23:00.000
2
0.291313
false
1,102,134
0
0
1
1
Say I want to write a large application in groovy, and take advantage of closures, categories and other concepts (that I regularly use to separate concerns). Is there a way to diagram or otherwise communicate in a simple way the architecture of some of this stuff? How do you detail (without verbose documentation) the things that a map of closures might do, for example? I understand that dynamic language features aren't usually recommended on a larger scale because they are seen as complex but does that have to be the case?
Can I detect if my code is running on cPython or Jython?
13,682,964
37
14
6,376
0
python,django,jython
The most clear-cut way is: import platform platform.python_implementation() 'CPython' By default, most of the time the underlying interpreter is CPython only which is also arguably the most efficient one :)
0
0
0
0
2009-07-09T12:19:00.000
5
1
false
1,103,487
0
0
1
2
I'm working on a small django project that will be deployed in a servlet container later. But development is much faster if I work with cPython instead of Jython. So what I want to do is test if my code is running on cPython or Jython in my settiings.py so I can tell it to use the appropriate db driver (postgresql_psycopg2 or doj.backends.zxjdbc.postgresql). Is there a simple way to do this?
Can I detect if my code is running on cPython or Jython?
1,103,680
3
14
6,376
0
python,django,jython
You'll have unique settings.py for every different environment. Your development settings.py should not be your QA/Test or production settings.py. What we do is this. We have a "master" settings.py that contains the installed apps and other items which don't change much. We have environment-specific files with names like settings_dev_win32.py and settings_qa_linux2.py and 'settings_co_linux2.py`, etc. Each of these environment-specific settings imports the "master" settings, and then overrides things like the DB driver. Since each settings file is unique to an environment, there are no if-statements and no detecting which environment we're running in. Production (in Apache, using mod_wsgi and mysql) uses the settings_prod_linux2.py file and no other. Development (in Windows using sqlite) uses the settings_dev_win32.py file.
0
0
0
0
2009-07-09T12:19:00.000
5
0.119427
false
1,103,487
0
0
1
2
I'm working on a small django project that will be deployed in a servlet container later. But development is much faster if I work with cPython instead of Jython. So what I want to do is test if my code is running on cPython or Jython in my settiings.py so I can tell it to use the appropriate db driver (postgresql_psycopg2 or doj.backends.zxjdbc.postgresql). Is there a simple way to do this?
storing uploaded photos and documents - filesystem vs database blob
1,105,534
1
11
7,730
1
python,postgresql,storage,photos,photo-management
a DB might be faster than a filesystem on some operations, but loading a well-identified chunk of data 100s of KB is not one of them. also, a good frontend webserver (like nginx) is way faster than any webapp layer you'd have to write to read the blob from the DB. in some tests nginx is roughly on par with memcached for raw data serving of medium-sized files (like big HTMLs or medium-sized images). go FS. no contest.
0
0
0
0
2009-07-09T17:39:00.000
6
0.033321
false
1,105,429
0
0
1
4
My specific situation Property management web site where users can upload photos and lease documents. For every apartment unit, there might be 4 photos, so there won't be an overwhelming number of photo in the system. For photos, there will be thumbnails of each. My question My #1 priority is performance. For the end user, I want to load pages and show the image as fast as possible. Should I store the images inside the database, or file system, or doesn't matter? Do I need to be caching anything? Thanks in advance!
storing uploaded photos and documents - filesystem vs database blob
1,105,444
9
11
7,730
1
python,postgresql,storage,photos,photo-management
File system. No contest. The data has to go through a lot more layers when you store it in the db. Edit on caching: If you want to cache the file while the user uploads it to ensure the operation finishes as soon as possible, dumping it straight to disk (i.e. file system) is about as quick as it gets. As long as the files aren't too big and you don't have too many concurrent users, you can 'cache' the file in memory, return to the user, then save to disk. To be honest, I wouldn't bother. If you are making the files available on the web after they have been uploaded and want to cache to improve the performance, file system is still the best option. You'll get caching for free (may have to adjust a setting or two) from your web server. You wont get this if the files are in the database. After all that it sounds like you should never store files in the database. Not the case, you just need a good reason to do so.
0
0
0
0
2009-07-09T17:39:00.000
6
1
false
1,105,429
0
0
1
4
My specific situation Property management web site where users can upload photos and lease documents. For every apartment unit, there might be 4 photos, so there won't be an overwhelming number of photo in the system. For photos, there will be thumbnails of each. My question My #1 priority is performance. For the end user, I want to load pages and show the image as fast as possible. Should I store the images inside the database, or file system, or doesn't matter? Do I need to be caching anything? Thanks in advance!
storing uploaded photos and documents - filesystem vs database blob
1,105,479
3
11
7,730
1
python,postgresql,storage,photos,photo-management
Definitely store your images on the filesystem. One concern that folks don't consider enough when considering these types of things is bloat; cramming images as binary blobs into your database is a really quick way to bloat your DB way up. With a large database comes higher hardware requirements, more difficult replication and backup requirements, etc. Sticking your images on a filesystem means you can back them up / replicate them with many existing tools easily and simply. Storage space is far easier to increase on filesystem than in database, as well.
0
0
0
0
2009-07-09T17:39:00.000
6
0.099668
false
1,105,429
0
0
1
4
My specific situation Property management web site where users can upload photos and lease documents. For every apartment unit, there might be 4 photos, so there won't be an overwhelming number of photo in the system. For photos, there will be thumbnails of each. My question My #1 priority is performance. For the end user, I want to load pages and show the image as fast as possible. Should I store the images inside the database, or file system, or doesn't matter? Do I need to be caching anything? Thanks in advance!
storing uploaded photos and documents - filesystem vs database blob
1,105,453
10
11
7,730
1
python,postgresql,storage,photos,photo-management
While there are exceptions to everything, the general case is that storing images in the file system is your best bet. You can easily provide caching services to the images, you don't need to worry about additional code to handle image processing, and you can easily do maintenance on the images if needed through standard image editing methods. It sounds like your business model fits nicely into this scenario.
0
0
0
0
2009-07-09T17:39:00.000
6
1
false
1,105,429
0
0
1
4
My specific situation Property management web site where users can upload photos and lease documents. For every apartment unit, there might be 4 photos, so there won't be an overwhelming number of photo in the system. For photos, there will be thumbnails of each. My question My #1 priority is performance. For the end user, I want to load pages and show the image as fast as possible. Should I store the images inside the database, or file system, or doesn't matter? Do I need to be caching anything? Thanks in advance!
Looking for testing/QA idea for Python Web Application Project
1,108,750
0
1
664
0
python,testing,integration-testing
Few things help as much as testing. These two quotes are really important. "how many unit tests you can afford to write." "From time to time embarrassing mistakes still occur," If mistakes occur, you haven't written enough tests. If you're still having mistakes, then you can afford to write more unit tests. It's that simple. Each embarrassing mistake is a direct result of not writing enough unit tests. Each management report that describes an embarrassing mistake should also describe what testing is required to prevent that mistake from ever happening again. A unit test is a permanent prevention of further problems.
0
0
0
1
2009-07-10T05:29:00.000
5
0
false
1,107,858
0
0
1
1
I have the 'luck' of develop and enhance a legacy python web application for almost 2 years. The major contribution I consider I made is the introduction of the use of unit test, nosestest, pychecker and CI server. Yes, that's right, there are still project out there that has no single unit test (To be fair, it has a few doctest, but are broken). Nonetheless, progress is slow, because literally the coverage is limited by how many unit tests you can afford to write. From time to time embarrassing mistakes still occur, and it does not look good on management reports. (e.g. even pychecker cannot catch certain "missing attribute" situation, and the program just blows up in run time) I just want to know if anyone has any suggestion about what additional thing I can do to improve the QA. The application uses WebWare 0.8.1, but I have expermentially ported it to cherrypy, so I can potentially take advantage of WSGI to conduct integration tests. Mixed language development and/or hiring an additional tester are also options I am thinking. Nothing is too wild, as long as it works.
Separation of ORM and validation
1,108,987
0
0
585
0
python,django,validation,architecture,django-models
I am not sure if this is best practise but what I do is that I tend to validate both client side and server side before pushing the data to the database. I know it requires a lot more effort but this can be done by setting some values before use and then maintaining them. You could also try push in size contraints with **kwargs into a validation function that is called before the put() call.
0
0
0
0
2009-07-10T11:09:00.000
5
0
false
1,108,967
0
0
1
4
I use django and I wonder in what cases where model validation should go. There are at least two variants: Validate in the model's save method and to raise IntegrityError or another exception if business rules were violated Validate data using forms and built-in clean_* facilities From one point of view, answer is obvious: one should use form-based validation. It is because ORM is ORM and validation is completely another concept. Take a look at CharField: forms.CharField allows min_length specification, but models.CharField does not. Ok cool, but what the hell all that validation features are doing in django.db.models? I can specify that CharField can't be blank, I can use EmailField, FileField, SlugField validation of which are performed here, in python, not on RDBMS. Furthermore there is the URLField which checks existance of url involving some really complex logic. From another side, if I have an entity I want to guarantee that it will not be saved in inconsistent state whether it came from a form or was modified/created by some internal algorithms. I have a model with name field, I expect it should be longer than one character. I have a min_age and a max_age fields also, it makes not much sense if min_age > max_age. So should I check such conditions in save method? What are the best practices of model validation?
Separation of ORM and validation
1,109,190
0
0
585
0
python,django,validation,architecture,django-models
Your two options are two different things. Form-based validation can be regarded as syntactic validation + convert HTTP request parameters from text to Python types. Model-based validation can be regarded as semantic validation, sometimes using context not available at the HTTP/form layer. And of course there is a third layer at the DB where constraints are enforced, and may not be checkable anywhere else because of concurrent requests updating the database (e.g. uniqueness constraints, optimistic locking).
0
0
0
0
2009-07-10T11:09:00.000
5
0
false
1,108,967
0
0
1
4
I use django and I wonder in what cases where model validation should go. There are at least two variants: Validate in the model's save method and to raise IntegrityError or another exception if business rules were violated Validate data using forms and built-in clean_* facilities From one point of view, answer is obvious: one should use form-based validation. It is because ORM is ORM and validation is completely another concept. Take a look at CharField: forms.CharField allows min_length specification, but models.CharField does not. Ok cool, but what the hell all that validation features are doing in django.db.models? I can specify that CharField can't be blank, I can use EmailField, FileField, SlugField validation of which are performed here, in python, not on RDBMS. Furthermore there is the URLField which checks existance of url involving some really complex logic. From another side, if I have an entity I want to guarantee that it will not be saved in inconsistent state whether it came from a form or was modified/created by some internal algorithms. I have a model with name field, I expect it should be longer than one character. I have a min_age and a max_age fields also, it makes not much sense if min_age > max_age. So should I check such conditions in save method? What are the best practices of model validation?
Separation of ORM and validation
1,109,327
0
0
585
0
python,django,validation,architecture,django-models
"but what the hell all that validation features are doing in django.db.models? " One word: Legacy. Early versions of Django had less robust forms and the validation was scattered. "So should I check such conditions in save method?" No, you should use a form for all validation. "What are the best practices of model validation?"* Use a form for all validation. "whether it came from a form or was modified/created by some internal algorithms" What? If your algorithms suffer from psychotic episodes or your programmers are sociopaths, then -- perhaps -- you have to validate internally-generated data. Otherwise, internally-generated data is -- by definition -- valid. Only user data can be invalid. If you don't trust your software, what's the point of writing it? Are your unit tests broken?
0
0
0
0
2009-07-10T11:09:00.000
5
0
false
1,108,967
0
0
1
4
I use django and I wonder in what cases where model validation should go. There are at least two variants: Validate in the model's save method and to raise IntegrityError or another exception if business rules were violated Validate data using forms and built-in clean_* facilities From one point of view, answer is obvious: one should use form-based validation. It is because ORM is ORM and validation is completely another concept. Take a look at CharField: forms.CharField allows min_length specification, but models.CharField does not. Ok cool, but what the hell all that validation features are doing in django.db.models? I can specify that CharField can't be blank, I can use EmailField, FileField, SlugField validation of which are performed here, in python, not on RDBMS. Furthermore there is the URLField which checks existance of url involving some really complex logic. From another side, if I have an entity I want to guarantee that it will not be saved in inconsistent state whether it came from a form or was modified/created by some internal algorithms. I have a model with name field, I expect it should be longer than one character. I have a min_age and a max_age fields also, it makes not much sense if min_age > max_age. So should I check such conditions in save method? What are the best practices of model validation?
Separation of ORM and validation
1,111,592
0
0
585
0
python,django,validation,architecture,django-models
DB/Model validation The data store in database must always be in a certain form/state. For example: required first name, last name, foreign key, unique constraint. This is where the logic of you app resides. No matter where you think the data comes from - it should be "validated" here and an exception raised if the requirements are not met. Form validation Data being entered should look right. It is ok if this data is entered differently through some other means (through admin or api calls). Examples: length of person's name, proper capitalization of the sentence... Example1: Object has a StartDate and an EndDate. StartDate must always be before EndDate. Where do you validate this? In the model of course! Consider a case when you might be importing data from some other system - you don't want this to go through. Example2: Password confirmation. You have a field for storing the password in the db. However you display two fields: password1 and password2 on your form. The form, and only the form, is responsible for comparing those two fields to see that they are the same. After form is valid you can safely store the password1 field into the db as the password.
0
0
0
0
2009-07-10T11:09:00.000
5
0
false
1,108,967
0
0
1
4
I use django and I wonder in what cases where model validation should go. There are at least two variants: Validate in the model's save method and to raise IntegrityError or another exception if business rules were violated Validate data using forms and built-in clean_* facilities From one point of view, answer is obvious: one should use form-based validation. It is because ORM is ORM and validation is completely another concept. Take a look at CharField: forms.CharField allows min_length specification, but models.CharField does not. Ok cool, but what the hell all that validation features are doing in django.db.models? I can specify that CharField can't be blank, I can use EmailField, FileField, SlugField validation of which are performed here, in python, not on RDBMS. Furthermore there is the URLField which checks existance of url involving some really complex logic. From another side, if I have an entity I want to guarantee that it will not be saved in inconsistent state whether it came from a form or was modified/created by some internal algorithms. I have a model with name field, I expect it should be longer than one character. I have a min_age and a max_age fields also, it makes not much sense if min_age > max_age. So should I check such conditions in save method? What are the best practices of model validation?
switch versions of python
1,109,305
1
16
26,273
0
python,development-environment,ubuntu-9.04
"Question1: How will i tell any framework that go and use version so and so pf python like day django to use 2.6 and say mjango to use 2.4?" You simply run them with the specific python version they need. Run mjango with /usr/bin/python2.4 and django with /usr/bin/python2.6. As easy as that. "Question2: Is there more elegant way to switch between version as my hack of symlinking was a virtual disaster?" Yes, see above. Have two separate installs of Python, and run explicitly with the different versions. "Question3: Can I download a deb for say hardy and make jaunty believe its for her?" That generally works. If it doesn't, it's because it has dependencies that exist in Hardy, and does not exist in Jaunty, and then you can't. And here is a Question 4 you didn't ask, but should have. ;) "Is there an easier way to download all those Python modules?" Yes, there is. Install setuptools, and use easy_install. It will not help you with library dependecies for those Python modules that have C code and need to be compiled. But it will help with all others. easy_install will download and install all the Python dependencies of the module in question in one go. That makes it a lot quicker to install Python modules.
0
0
0
0
2009-07-10T11:12:00.000
7
0.028564
false
1,108,974
1
0
1
2
Story: One of the app that i have works on python 2.4 and other on 2.6. I tried to do a sym link of python2.4 to python and things started to break loose on ubuntu jaunty. Now i am downloading every dependency of 2.4 and installing it using python2.4 setup.py install. The dependencies seem to be endless. Question1: How will i tell any framework that go and use version so and so pf python like day django to use 2.6 and say mjango to use 2.4? Something like we say use database databasename kinda syntax. Question2: Is there more elegant way to switch between version as my hack of symlinking was a virtual disaster? Question3: Can I download a deb for say hardy and make jaunty believe its for her?
switch versions of python
35,381,570
0
16
26,273
0
python,development-environment,ubuntu-9.04
Move to the project directory : Create an environment : virtualenv -p python2.7 --no-site-packages ~/env/twoseven Then activate your source : source ~/env/twoseven/bin/activate
0
0
0
0
2009-07-10T11:12:00.000
7
0
false
1,108,974
1
0
1
2
Story: One of the app that i have works on python 2.4 and other on 2.6. I tried to do a sym link of python2.4 to python and things started to break loose on ubuntu jaunty. Now i am downloading every dependency of 2.4 and installing it using python2.4 setup.py install. The dependencies seem to be endless. Question1: How will i tell any framework that go and use version so and so pf python like day django to use 2.6 and say mjango to use 2.4? Something like we say use database databasename kinda syntax. Question2: Is there more elegant way to switch between version as my hack of symlinking was a virtual disaster? Question3: Can I download a deb for say hardy and make jaunty believe its for her?
How to build an Ecommerce Shopping Cart in Django?
1,111,510
3
1
10,724
0
python,django,shopping-cart
Ingredients: one cup PayPal (or subsitute with other equivalent payment system) few cups html add css to taste add django if desired Cooking: Mix well. Bake for 1-2 month. Release as open source :-)
0
0
0
0
2009-07-10T18:22:00.000
3
0.197375
false
1,111,173
0
0
1
1
Is there a book or a tutorial which teaches how to build a shopping cart with django or any other python framework ?
What are the different possible values for __name__ in a Python script, and what do they mean?
1,112,223
6
9
1,833
0
python
__name__ is usually the module name, but it's changed to '__main__' when the module in question is executed directly instead of being imported by another one. I understand that other values can only be set directly by the code you're running.
0
0
0
0
2009-07-10T21:59:00.000
2
1
false
1,112,198
1
0
1
1
Checking to see if __name__ == '__main__' is a common idiom to run some code when the file is being called directly, rather than through a module. In the process of writing a custom command for Django's manage.py, I found myself needing to use code.InteractiveConsole, which gives the effect to the user of a standard python shell. In some test code I was doing, I found that in the script I'm trying to execute, I get that __name__ is __console__, which caused my code (dependent on __main__) to not run. I'm fairly certain that I have some things in my original implementation to change, but it got me wondering as to what different things __name__ could be. I couldn't find any documentation on the possible values, nor what they mean, so that's how I ended up here.
How to keep an App Engine/Java app running with deaf requests from a Java/Python web cron?
4,707,002
1
3
1,731
0
java,python,google-app-engine,httpwebrequest,keep-alive
App engine also has a new PAY feature where you can have it "always-on". Costs about $0.30 USD cents a day. Just go into your billing settings and enable it if you don't mind paying for the feature. I believe it guarantees you at least 3 instances always running. (I didn't realize hitting a /ping url which caused an instance to spin up would cause it to exceed the 30 sec limit!)
0
1
0
0
2009-07-11T06:02:00.000
4
0.049958
false
1,113,066
0
0
1
1
App Engine allows you 30 seconds to load your application My application takes around 30 seconds - sometimes more, sometimes less. I don't know how to fix this. If the app is idle (does not receive a request for a while), it needs to be re-loaded. So, to avoid the app needing to be reloaded, I want to simulate user activity by pinging the app every so often. But there's a catch . . . If I ping the app and it has already been unloaded by App Engine, my web request will be the first request to the app and the app will try to reload. This could take longer than 30 seconds and exceed the loading time limit. So my idea is to ping the app but not wait for the response. I have simulated this manually by going to the site from a browser, making the request and immediately closing the browser - it seems to keep the app alive. Any suggestions for a good way to do this in a Python or Java web cron (I'm assuming a Python solution will be simpler)?
Django Model Sync Table
1,117,089
0
4
6,973
0
python,database,django,django-models,synchronization
Just to throw in an extra opinion - dmigrations is pretty nice and clear to use, but I'd say South is your best bet. Again, it's easy to get into, but it's more powerful and also has support for more database backends than just MySQL. It even handles MSSQL, if that's your thing
0
0
0
0
2009-07-12T03:21:00.000
5
0
false
1,115,238
0
0
1
2
If I change a field in a Django model, how can I synchronize it with the database tables? Do I need to do it manually on the database or is there a tool that does helps with the process?
Django Model Sync Table
1,232,838
4
4
6,973
0
python,database,django,django-models,synchronization
Can't seem to be able to add a comment to the marked answer, probably because I haven't got enough rep (be nice if SO told me so though). Anyway, just wanted to add that in the answered post, I believe it is wrong about syncdb - syncdb does not touch tables once they have been created and have data in them. You should not lose data by calling it (otherwise, how could you add new tables for new apps?) I believe the poster was referring to the reset command instead, which does result in data loss - it will drop the table and recreate it and hence it'll have all the latest model changes.
0
0
0
0
2009-07-12T03:21:00.000
5
0.158649
false
1,115,238
0
0
1
2
If I change a field in a Django model, how can I synchronize it with the database tables? Do I need to do it manually on the database or is there a tool that does helps with the process?
Static methods and thread safety
1,115,427
8
3
3,314
0
python,django,thread-safety
Functions in a module are equivalent to static methods in a class. The issue of thread safety arises when multiple threads may be modifying shared data, or even one thread may be modifying such data while others are reading it; it's best avoided by making data be owned by ONE module (accessed via Queue.Queue from others), but when that's not feasible you have to resort to locking and other, more complex, synchronization primitives. This applies whether the access to shared data happens in module functions, static methods, or instance methods -- and the shared data is such whether it's instance variables, class ones, or global ones (scoping and thread safety are essentially disjoint, except that function-local data is, to a pont, intrinsically thread-safe -- no other thread will ever see the data inside a function instance, until and unless the function deliberately "shares" it through shared containers). If you use the multiprocessing module in Python's standard library, instead of the threading module, you may in fact not have to care about "thread safety" -- essentially because NO data is shared among processes... well, unless you go out of your way to change that, e.g. via mmapped files;-).
0
0
0
0
2009-07-12T06:32:00.000
2
1
false
1,115,420
1
0
1
1
In python with all this idea of "Everything is an object" where is thread-safety? I am developing django website with wsgi. Also it would work in linux, and as I know they use effective process management, so we could not think about thread-safety alot. I am not doubt in how module loads, and there functions are static or not? Every information would be helpfull.
Retrieve cookie created using javascript in python
1,116,535
3
2
2,627
0
python,cookies,urllib2,cookiejar
If all pages have the same JavaScript then maybe you could parse the HTML to find that piece of code, and from that get the value the cookie would be set to? That would make your scraping quite vulnerable to changes in the third party website, but that's most often the case while scraping. (Please bear in mind that the third-party website owner may not like that you're getting the content this way.)
0
0
0
0
2009-07-12T16:25:00.000
4
1.2
true
1,116,362
0
0
1
1
I've had a look at many tutorials regarding cookiejar, but my problem is that the webpage that i want to scape creates the cookie using javascript and I can't seem to retrieve the cookie. Does anybody have a solution to this problem?
Django Initialization
1,117,692
19
10
6,064
0
python,django
settings.py is for Django settings; it's fine to put your own settings in there, but using it for arbitrary non-configuration data structures isn't good practice. Just put it in the module it logically belongs to, and it'll be run just once per instance. If you want to guarantee that the module is loaded on startup and not on first use later on, import that module from your top-level __init__.py to force it to be loaded immediately.
0
0
0
0
2009-07-12T21:19:00.000
2
1
false
1,116,948
1
0
1
2
I have a big array, that I would like to load into memory only once when django starts up and then treat it as a read only global variable. What is the best place to put the code for the initialization of that array? If I put it in settings.py it will be reinitialized every time the settings module is imported, correct?
Django Initialization
1,117,100
9
10
6,064
0
python,django
settings.py is the right place for that. Settings.py is, like any other module, loaded once. There is still the problem of the fact that a module must be imported once for each process, so a respawning style of web server (like apache) will reload it once for each instance in question. For mod_python this will be once per process. for mod_wsgi, this is likely to be just one time, unless you have to restart. tl;dr modules are imported once, even if multiple import statements are used. put it in settings.py
0
0
0
0
2009-07-12T21:19:00.000
2
1.2
true
1,116,948
1
0
1
2
I have a big array, that I would like to load into memory only once when django starts up and then treat it as a read only global variable. What is the best place to put the code for the initialization of that array? If I put it in settings.py it will be reinitialized every time the settings module is imported, correct?
Turbogears 2 vs Django - any advice on choosing replacement for Turbogears 1?
51,161,118
-1
12
20,511
0
python,django,google-app-engine,turbogears,turbogears2
Django ORM uses the active record implementation – you’ll see this implementation in most ORMs. Basically what it means is that each row in the database is directly mapped to an object in the code and vice versa. ORM frameworks such as Django won’t require predefining the schema to use the properties in the code. You just use them, as the framework can ‘understand’ the structure by looking at the database schema. Also, you can just save the record to the database, as it’s mapped to a specific row in the table. SQLAlchemy uses the Data Mapper implementation – When using this kind of implementation, there is a separation between the database structure and the objects structure (they are not 1:1 as in the Active Record implementation). In most cases, you’ll have to use another persistence layer to keep interact with the database (for example, to save the object). So you can’t just call the save() method as you can when using the Active Record implementation (which is a con) but on the other hand, you code doesn’t have to know the entire relational structure in the database to function, as there is no direct relationship between the code and the database. So which of them wins this battle? None. It depends on what you’re trying to accomplish. It’s my believe that if your application is a mostly a CRUD (Create, Read, Update, Delete) application which no hard and complex rules to apply on the relationships between the different data entities, you should use the Active Record implementation (Django). It will allow you to easily and quickly set up an MVP for your product, without any hassle. If you have a lot of “business rules” and restrictions in your applications, you might be better with the Data Mapper model, as it won’t tie you up and force you to think strictly as Active Record does.
0
0
0
0
2009-07-13T07:49:00.000
7
-0.028564
false
1,118,163
0
0
1
4
I have been using Turbogears 1 for prototyping small sites for the last couple of years and it is getting a little long in the tooth. Any suggestions on making the call between upgrading to Turbogears 2 or switching to something like Django? I'm torn between the familiarity of the TG community who are pretty responsive and do pretty good documentation vs the far larger community using Django. I am quite tempted by the built-in CMS features and the Google AppEngine support. Any advice?
Turbogears 2 vs Django - any advice on choosing replacement for Turbogears 1?
1,584,576
-1
12
20,511
0
python,django,google-app-engine,turbogears,turbogears2
Ive only got one question...is the app you are developing directed towards social networking or customized business logic? I personally find Django is good for social networking and pylons/turbogears if you really want the flexibility and no boundaries... just my 2c
0
0
0
0
2009-07-13T07:49:00.000
7
-0.028564
false
1,118,163
0
0
1
4
I have been using Turbogears 1 for prototyping small sites for the last couple of years and it is getting a little long in the tooth. Any suggestions on making the call between upgrading to Turbogears 2 or switching to something like Django? I'm torn between the familiarity of the TG community who are pretty responsive and do pretty good documentation vs the far larger community using Django. I am quite tempted by the built-in CMS features and the Google AppEngine support. Any advice?
Turbogears 2 vs Django - any advice on choosing replacement for Turbogears 1?
1,118,237
4
12
20,511
0
python,django,google-app-engine,turbogears,turbogears2
I have been using Django for a year now and when I started I had no experience of Python or Django and found it very intuitive to use. I have created a number of hobbyist Google App Engine apps using Django with the latest one being a CMS for my site. Using Django has meant that I have been able to code a lot quicker and with a lot less bugs.
0
0
0
0
2009-07-13T07:49:00.000
7
0.113791
false
1,118,163
0
0
1
4
I have been using Turbogears 1 for prototyping small sites for the last couple of years and it is getting a little long in the tooth. Any suggestions on making the call between upgrading to Turbogears 2 or switching to something like Django? I'm torn between the familiarity of the TG community who are pretty responsive and do pretty good documentation vs the far larger community using Django. I am quite tempted by the built-in CMS features and the Google AppEngine support. Any advice?
Turbogears 2 vs Django - any advice on choosing replacement for Turbogears 1?
1,118,670
11
12
20,511
0
python,django,google-app-engine,turbogears,turbogears2
I have experience with both Django and TG1.1. IMO, TurboGears strong point is it's ORM: SQLAlchemy. I prefer TurboGears when the database side of things is non-trivial. Django's ORM is just not that flexible and powerful. That being said, I prefer Django. If the database schema is a good fit with Django's ORM I would go with Django. In my experience, it is simply less hassle to use Django compared with TurboGears.
0
0
0
0
2009-07-13T07:49:00.000
7
1.2
true
1,118,163
0
0
1
4
I have been using Turbogears 1 for prototyping small sites for the last couple of years and it is getting a little long in the tooth. Any suggestions on making the call between upgrading to Turbogears 2 or switching to something like Django? I'm torn between the familiarity of the TG community who are pretty responsive and do pretty good documentation vs the far larger community using Django. I am quite tempted by the built-in CMS features and the Google AppEngine support. Any advice?
Migrating Django Application to Google App Engine?
1,118,790
1
9
1,845
1
python,django,google-app-engine
There are a few things that you can't do on the App Engine that you can do on your own server like uploading of files. On the App Engine you kinda have to upload it and store the datastore which can cause a few problems. Other than that it should be fine from the Presentation part. There are a number of other little things that are better on your own dedicated server but I think eventually a lot of those things will be in the App Engine
0
1
0
0
2009-07-13T10:40:00.000
4
0.049958
false
1,118,761
0
0
1
2
I'm developing a web application and considering Django, Google App Engine, and several other options. I wondered what kind of "penalty" I will incur if I develop a complete Django application assuming it runs on a dedicated server, and then later want to migrate it to Google App Engine. I have a basic understanding of Google's data store, so please assume I will choose a column based database for my "stand-alone" Django application rather than a relational database, so that the schema could remain mostly the same and will not be a major factor. Also, please assume my application does not maintain a huge amount of data, so that migration of tens of gigabytes is not required. I'm mainly interested in the effects on the code and software architecture. Thanks
Migrating Django Application to Google App Engine?
1,119,377
8
9
1,845
1
python,django,google-app-engine
Most (all?) of Django is available in GAE, so your main task is to avoid basing your designs around a reliance on anything from Django or the Python standard libraries which is not available on GAE. You've identified the glaring difference, which is the database, so I'll assume you're on top of that. Another difference is the tie-in to Google Accounts and hence that if you want, you can do a fair amount of access control through the app.yaml file rather than in code. You don't have to use any of that, though, so if you don't envisage switching to Google Accounts when you switch to GAE, no problem. I think the differences in the standard libraries can mostly be deduced from the fact that GAE has no I/O and no C-accelerated libraries unless explicitly stated, and my experience so far is that things I've expected to be there, have been there. I don't know Django and haven't used it on GAE (apart from templates), so I can't comment on that. Personally I probably wouldn't target LAMP (where P = Django) with the intention of migrating to GAE later. I'd develop for both together, and try to ensure if possible that the differences are kept to the very top (configuration) and the very bottom (data model). The GAE version doesn't necessarily have to be perfect, as long as you know how to make it perfect should you need it. It's not guaranteed that this is faster than writing and then porting, but my guess is it normally will be. The easiest way to spot any differences is to run the code, rather than relying on not missing anything in the GAE docs, so you'll likely save some mistakes that need to be unpicked. The Python SDK is a fairly good approximation to the real App Engine, so all or most of your tests can be run locally most of the time. Of course if you eventually decide not to port then you've done unnecessary work, so you have to think about the probability of that happening, and whether you'd consider the GAE development to be a waste of your time if it's not needed.
0
1
0
0
2009-07-13T10:40:00.000
4
1.2
true
1,118,761
0
0
1
2
I'm developing a web application and considering Django, Google App Engine, and several other options. I wondered what kind of "penalty" I will incur if I develop a complete Django application assuming it runs on a dedicated server, and then later want to migrate it to Google App Engine. I have a basic understanding of Google's data store, so please assume I will choose a column based database for my "stand-alone" Django application rather than a relational database, so that the schema could remain mostly the same and will not be a major factor. Also, please assume my application does not maintain a huge amount of data, so that migration of tens of gigabytes is not required. I'm mainly interested in the effects on the code and software architecture. Thanks
Java Python Integration
58,624,426
7
57
81,995
0
java,python,integration
The best solutions, is to use Python programs throw REST API. You define your services and call them. You perhaps need to learn some new modules. But you will be more flexible for futures changes. Here a small list of use full modules for this purpose: Python modules Flask Flask-SQLAlchemy Flask-Restful SQlite3 Jsonify Java modules (for calling rest api) Jersey or Apache CXF You will need a small Learning curve, but later you will get more productivity and modularity and even elasticity...
0
0
0
0
2009-07-13T14:15:00.000
12
1
false
1,119,696
1
0
1
1
I have a Java app that needs to integrate with a 3rd party library. The library is written in Python, and I don't have any say over that. I'm trying to figure out the best way to integrate with it. I'm trying out JEPP (Java Embedded Python) - has anyone used that before? My other thought is to use JNI to communicate with the C bindings for Python. Any thoughts on the best way to do this would be appreciated. Thanks.
Platform for developing all things google?
1,121,377
0
4
263
0
java,python,android,platform
I'd throw down another vote for Eclipse. I've been using it on the mac and I find it to be very buggy. Not sure if that's just the nature of the beast... My experiences with it on XP have been more stable. Haven't had time to check it out on Ubuntu.
0
1
0
0
2009-07-13T15:48:00.000
3
0
false
1,120,297
0
0
1
2
I am interested in developing things for google apps and android using python and java. I am new to both and was wondering if a environment set in windows or linux would be more productive for these tasks?
Platform for developing all things google?
1,122,211
0
4
263
0
java,python,android,platform
Internally, I believe Google uses Eclipse running on Ubuntu for Android development, so that'd be your best bet if you're completely paranoid about avoiding all potential issues. Of course, this is impossible, and really you should just use whatever you're comfortable in.
0
1
0
0
2009-07-13T15:48:00.000
3
0
false
1,120,297
0
0
1
2
I am interested in developing things for google apps and android using python and java. I am new to both and was wondering if a environment set in windows or linux would be more productive for these tasks?
Django templates: adding sections conditionally
1,120,987
1
0
235
0
python,django,django-templates
The answer to this depends a lot on how you've structured your data, which you don't say - are the extra bits of information in separate related tables, subclassed models, individual fields on the same model...? In general, this sounds like a job for a template tag. I would probably write a custom tag that took your parent object as a parameter, and inspected the data to determine what to output. Each choice could potentially be rendered by a different sub-template, called by the tag itself.
0
0
0
0
2009-07-13T17:31:00.000
2
0.099668
false
1,120,914
0
0
1
1
I just started using django for development. At the moment, I have the following issue: I have to write a page template able to represent different categories of data. For example, suppose I have a medical record of a patient. The represented information about this patient are, for example: name, surname and similar data data about current treatments ..and beyond: specific data about any other analysis (eg. TAC, NMR, heart, blood, whatever) Suppose that for each entry at point 3, I need to present a specific section. The template for this page would probably look like a long series of if statements, one for each data entry, which will be used only if that information is present. This would result in a very long template. One possible solution is to use the include directive in the template, and then fragment the main template so that instead of a list of if's i have a list of includes, one for each if. Just out of curiosity, I was wondering if someone know an alternative strategy for this kind of pattern, either at the template level or at the view level.
Eliminating certain Django Session Calls
1,121,363
1
0
208
0
python,django,session
Sessions are lazily loaded: if you don't use the session during a request, Django won't load it. This includes request.user: if you access it, it accesses the session to find the user. (It loads lazily, too--if you don't access request.user, it won't access the session, either.) So, figure out what's accessing the session and eliminate it--and if you can't, at least you'll know why the session is being pulled in.
0
0
0
0
2009-07-13T18:40:00.000
1
1.2
true
1,121,299
0
0
1
1
I was wondering if I could eliminate django session calls for specific views. For example, if I have a password reset form I don't want a call to the DB to check for a session or not. Thanks!
creating non-reloading dynamic webapps using Django
1,129,395
1
0
823
0
python,ajax,django
Maybe a few iFrames and some Comet/long-polling? Have the comment submission in an iFrame (so the whole page doesn't reload), and then show the result in the long-polled iFrame... Having said that, it's a pretty bad design idea, and you probably don't want to be doing this. AJAX/JavaScript is pretty much the way to go for things like this. I have heard it's possible with AJAX...but I was wondering if it was possible to do with Django. There's no reason you can't use both - specifically, AJAX within a Django web application. Django provides your organization and framework needs (and a page that will respond to AJAX requests) and then use some JavaScript on the client side to make AJAX calls to your Django-backed page that will respond correctly. I suggest you go find a basic jQuery tutorial which should explain enough basic JavaScript to get this working.
0
0
0
0
2009-07-15T03:15:00.000
4
0.049958
false
1,129,210
0
0
1
2
As far as I know, for a new request coming from a webapp, you need to reload the page to process and respond to that request. For example, if you want to show a comment on a post, you need to reload the page, process the comment, and then show it. What I want, however, is I want to be able to add comments (something like facebook, where the comment gets added and shown without having to reload the whole page, for example) without having to reload the web-page. Is it possible to do with only Django and Python with no Javascript/AJAX knowledge? I have heard it's possible with AJAX (I don't know how), but I was wondering if it was possible to do with Django. Thanks,
creating non-reloading dynamic webapps using Django
1,129,222
8
0
823
0
python,ajax,django
You want to do that with out any client side code (javascript and ajax are just examples) and with out reloading your page (or at least part of it)? If that is your question, then the answer unfortunately is you can't. You need to either have client side code or reload your page. Think about it, once the client get's the page it will not change unless The client requests the same page from the server and the server returns and updated one the page has some client side code (eg: javascript) that updates the page. I can not imagine a third possibility. I have not coded in Django for more than 30 mins and this is clearly obvious to me. If I am wrong plz down vote :D
0
0
0
0
2009-07-15T03:15:00.000
4
1.2
true
1,129,210
0
0
1
2
As far as I know, for a new request coming from a webapp, you need to reload the page to process and respond to that request. For example, if you want to show a comment on a post, you need to reload the page, process the comment, and then show it. What I want, however, is I want to be able to add comments (something like facebook, where the comment gets added and shown without having to reload the whole page, for example) without having to reload the web-page. Is it possible to do with only Django and Python with no Javascript/AJAX knowledge? I have heard it's possible with AJAX (I don't know how), but I was wondering if it was possible to do with Django. Thanks,
Jython or JRuby?
1,130,727
1
4
5,421
0
python,ruby,jruby,jython
The compatibility in either case is at the source-code level; with necessary changes where the Python or Ruby code invokes packages that involve native code (especially, standard Python packages like ctypes are not present in Jython).
0
0
0
1
2009-07-15T10:50:00.000
5
0.039979
false
1,130,697
0
0
1
3
It's a high level conceptual question. I have two separate code bases that serve the same purpose, one built in Python and the other in Ruby. I need to develop something that will run on JVM. So I have two choices: convert the Python code to Jython or convert the Ruby to JRuby. Since I don't know any of them, I was wondering if anyone can give me some guidance. Like which one runs faster, or more importantly which one has tools available for easy code migration(.pyc to .jar files)?
Jython or JRuby?
1,140,847
1
4
5,421
0
python,ruby,jruby,jython
Anything you can do in one, you can do in the other. Learn enough of both to realise which one appeals to your coding sensibilities. There is no right or wrong answer here.
0
0
0
1
2009-07-15T10:50:00.000
5
0.039979
false
1,130,697
0
0
1
3
It's a high level conceptual question. I have two separate code bases that serve the same purpose, one built in Python and the other in Ruby. I need to develop something that will run on JVM. So I have two choices: convert the Python code to Jython or convert the Ruby to JRuby. Since I don't know any of them, I was wondering if anyone can give me some guidance. Like which one runs faster, or more importantly which one has tools available for easy code migration(.pyc to .jar files)?
Jython or JRuby?
1,130,722
5
4
5,421
0
python,ruby,jruby,jython
In both cases, most of the code should Just Work™. I don't know of a really compelling reason to choose Jython over JRuby or vice versa if you'll be learning either from scratch. Python places a heavy emphasis on readability and not using "magic", but Ruby tends to give you a little more rope to do fancy things, e.g., define your own DSL. The main difference is in the community, and largely revolves around the different focus mentioned above.
0
0
0
1
2009-07-15T10:50:00.000
5
0.197375
false
1,130,697
0
0
1
3
It's a high level conceptual question. I have two separate code bases that serve the same purpose, one built in Python and the other in Ruby. I need to develop something that will run on JVM. So I have two choices: convert the Python code to Jython or convert the Ruby to JRuby. Since I don't know any of them, I was wondering if anyone can give me some guidance. Like which one runs faster, or more importantly which one has tools available for easy code migration(.pyc to .jar files)?
Count lines of code in a Django Project
1,133,417
1
11
6,904
0
python,django
Check out the wc command on unix.
0
0
0
0
2009-07-15T19:17:00.000
5
0.039979
false
1,133,391
0
0
1
1
Is there an easy way to count the lines of code you have written for your django project? Edit: The shell stuff is cool, but how about on Windows?
Keep ConfigParser output files sorted
1,134,323
-1
7
6,931
0
python,configuration,configparser
ConfigParser is based on the ini file format, who in it's design is supposed to NOT be sensitive to order. If your config file format is sensitive to order, you can't use ConfigParser. It may also confuse people if you have an ini-type format that is sensitive to the order of the statements...
0
0
0
0
2009-07-15T21:03:00.000
4
-0.049958
false
1,134,071
1
0
1
1
I've noticed with my source control that the content of the output files generated with ConfigParser is never in the same order. Sometimes sections will change place or options inside sections even without any modifications to the values. Is there a way to keep things sorted in the configuration file so that I don't have to commit trivial changes every time I launch my application?
Google App engine template unicode decoding problem
1,140,751
2
2
2,383
0
python,django,google-app-engine,unicode
Are you using Django 0.96 or Django 1.0? You can check by looking at your main.py and seeing if it contains the following: from google.appengine.dist import use_library use_library('django', '1.0') If you're using Django 1.0, both FILE_CHARSET and DEFAULT_CHARSET should default to 'utf-8'. If your template is saved under a different encoding, just set FILE_CHARSET to whatever that is. If you're using Django 0.96, you might want to try directly reading the template from the disk and then manually handling the encoding. e.g., replace template.render( templatepath , template_values) with Template(unicode(template_fh.read(), 'utf-8')).render(template_values)
0
1
0
0
2009-07-16T17:40:00.000
3
0.132549
false
1,139,151
0
0
1
3
When trying to render a Django template file in Google App Engine from google.appengine.ext.webapp import template templatepath = os.path.join(os.path.dirname(file), 'template.html') self.response.out.write (template.render( templatepath , template_values)) I come across the following error: <type 'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xe2 in position 17692: ordinal not in range(128) args = ('ascii', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Str...07/a-beautiful-method-to-find-peace-of-mind/ --> ', 17692, 17693, 'ordinal not in range(128)') encoding = 'ascii' end = 17693 message = '' object = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Str...07/a-beautiful-method-to-find-peace-of-mind/ --> reason = 'ordinal not in range(128)' start = 17692 It seems that the underlying django template engine has assumed the "ascii" encoding, which should have been "utf-8". Anyone who knows what might have caused the trouble and how to solve it? Thanks.
Google App engine template unicode decoding problem
1,139,534
1
2
2,383
0
python,django,google-app-engine,unicode
Did you check in your text editor that the template is encoded in utf-8?
0
1
0
0
2009-07-16T17:40:00.000
3
0.066568
false
1,139,151
0
0
1
3
When trying to render a Django template file in Google App Engine from google.appengine.ext.webapp import template templatepath = os.path.join(os.path.dirname(file), 'template.html') self.response.out.write (template.render( templatepath , template_values)) I come across the following error: <type 'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xe2 in position 17692: ordinal not in range(128) args = ('ascii', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Str...07/a-beautiful-method-to-find-peace-of-mind/ --> ', 17692, 17693, 'ordinal not in range(128)') encoding = 'ascii' end = 17693 message = '' object = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Str...07/a-beautiful-method-to-find-peace-of-mind/ --> reason = 'ordinal not in range(128)' start = 17692 It seems that the underlying django template engine has assumed the "ascii" encoding, which should have been "utf-8". Anyone who knows what might have caused the trouble and how to solve it? Thanks.
Google App engine template unicode decoding problem
1,141,420
6
2
2,383
0
python,django,google-app-engine,unicode
Well, turns out the rendered results returned by the template needs to be decoded first: self.response.out.write (template.render( templatepath , template_values).decode('utf-8') ) A silly mistake, but thanks for everyone's answers anyway. :)
0
1
0
0
2009-07-16T17:40:00.000
3
1.2
true
1,139,151
0
0
1
3
When trying to render a Django template file in Google App Engine from google.appengine.ext.webapp import template templatepath = os.path.join(os.path.dirname(file), 'template.html') self.response.out.write (template.render( templatepath , template_values)) I come across the following error: <type 'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xe2 in position 17692: ordinal not in range(128) args = ('ascii', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Str...07/a-beautiful-method-to-find-peace-of-mind/ --> ', 17692, 17693, 'ordinal not in range(128)') encoding = 'ascii' end = 17693 message = '' object = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Str...07/a-beautiful-method-to-find-peace-of-mind/ --> reason = 'ordinal not in range(128)' start = 17692 It seems that the underlying django template engine has assumed the "ascii" encoding, which should have been "utf-8". Anyone who knows what might have caused the trouble and how to solve it? Thanks.
What are the best books and resources for learning to develop, deploy and/or host Django?
1,152,601
2
15
2,869
0
python,django,apache
Found Python Web Development with Django by Forcier, Bissex and Chun a great start. 50 pages on python to get you going and all the basics of Django.
0
0
0
0
2009-07-17T20:06:00.000
8
0.049958
false
1,145,414
0
0
1
1
I'm a newbie on the Django scene coming from an ASP.NET C# background. I'm looking for some good resources to help me learn the ins and outs of Django/Python. Any recommendations?
How to make easy_install expand a package into directories rather than a single egg file?
1,145,611
5
3
1,188
0
python,django,setuptools,easy-install,egg
You add zip_safe = False as an option to setup(). I don't think it has to do with directories. Setuptools will happily eggify packages with loads of directories in it. Then of course it's another problem that this part of Django doesn't find the package even though it's zipped. It should.
0
0
0
0
2009-07-17T20:29:00.000
1
1.2
true
1,145,524
1
0
1
1
How exactly do I configure my setup.py file so that when someone runs easy_install the package gets expanded into \site-packages\ as a directory, rather than remaining inside an egg. The issue I'm encountering is that one of the django apps I've created won't auto-detect if it resides inside an egg. EDIT: For example, if I type easy_install photologue it simply installs a \photologue\ directory into site-packages. This the the behaviour I'd like, but it seems that in order to make that happen, there needs to be at least one directory/module within the directory being packaged.
Possible to access gdata api when using Java App Engine?
1,149,886
0
0
802
0
java,python,google-app-engine,gdata-api
I'm having a look into the google data api protocol which seems to solve the problem.
0
0
1
0
2009-07-18T18:08:00.000
3
1.2
true
1,148,165
0
0
1
1
I have a dilemma where I want to create an application that manipulates google contacts information. The problem comes down to the fact that Python only supports version 1.0 of the api whilst Java supports 3.0. I also want it to be web-based so I'm having a look at google app engine, but it seems that only the python version of app engine supports the import of gdata apis whilst java does not. So its either web based and version 1.0 of the api or non-web based and version 3.0 of the api. I actually need version 3.0 to get access to the extra fields provided by google contacts. So my question is, is there a way to get access to the gdata api under Google App Engine using Java? If not is there an ETA on when version 3.0 of the gdata api will be released for python? Cheers.
Using Task Queues to schedule the fetching/parsing of a number of feeds in App Engine (Python)
1,148,720
2
0
365
0
python,google-app-engine,feed
2 fetches per task? 3?
0
1
0
0
2009-07-18T22:04:00.000
3
0.132549
false
1,148,709
0
0
1
2
Say I had over 10,000 feeds that I wanted to periodically fetch/parse. If the period were say 1h that would be 24x10000 = 240,000 fetches. The current 10k limit of the labs Task Queue API would preclude one from setting up one task per fetch. How then would one do this? Update: RE: Fetching nurls per task - Given the 30second timeout per request at some point this would hit a ceiling. Is there anyway to parallelize it so each task queue initiates a bunch of async parallel fetches each of which would take less than 30sec to finish but the lot together may take more than that.
Using Task Queues to schedule the fetching/parsing of a number of feeds in App Engine (Python)
1,148,729
0
0
365
0
python,google-app-engine,feed
Group up the fetches, so instead of queuing 1 fetch you queue up, say, a work unit that does 10 fetches.
0
1
0
0
2009-07-18T22:04:00.000
3
0
false
1,148,709
0
0
1
2
Say I had over 10,000 feeds that I wanted to periodically fetch/parse. If the period were say 1h that would be 24x10000 = 240,000 fetches. The current 10k limit of the labs Task Queue API would preclude one from setting up one task per fetch. How then would one do this? Update: RE: Fetching nurls per task - Given the 30second timeout per request at some point this would hit a ceiling. Is there anyway to parallelize it so each task queue initiates a bunch of async parallel fetches each of which would take less than 30sec to finish but the lot together may take more than that.
Rendering common session information in every view
1,148,886
0
0
157
0
python,django,session,templates
Are you trying to make certain areas of your site only accessible when logged on? Or certain areas of a particular page? If you want to block off access to a whole URL you can use the @login_required decorator in your functions in your view to block certain access. Also, you can use includes to keep the common parts of your site that require user login in a separate html that gets included, that way you're only writing your if statements once.
0
0
0
0
2009-07-18T23:18:00.000
3
0
false
1,148,854
0
0
1
1
I'd like to output some information that depends on session data in Django. Let's take a "Login" / "Logged in as | Logout" fragment for example. It depends on my request.session['user']. Of course I can put a user object in the context every time I render a page and then switch on {% if user %}, but that seems to break DRY idea - I would have to add user to every context in every view. How can I extract a fragment like that and make it more common?
SQLAlchemy and django, is it production ready?
1,308,718
4
23
12,511
1
python,database,django,sqlalchemy
Jacob Kaplan-Moss admitted to typing "import sqlalchemy" from time to time. I may write a queryset adapter for sqlalchemy results in the not too distant future.
0
0
0
0
2009-07-20T15:44:00.000
5
0.158649
false
1,154,331
0
0
1
3
Has anyone used SQLAlchemy in addition to Django's ORM? I'd like to use Django's ORM for object manipulation and SQLalchemy for complex queries (like those that require left outer joins). Is it possible? Note: I'm aware about django-sqlalchemy but the project doesn't seem to be production ready.
SQLAlchemy and django, is it production ready?
1,155,407
19
23
12,511
1
python,database,django,sqlalchemy
What I would do, Define the schema in Django orm, let it write the db via syncdb. You get the admin interface. In view1 you need a complex join def view1(request): import sqlalchemy data = sqlalchemy.complex_join_magic(...) ... payload = {'data': data, ...} return render_to_response('template', payload, ...)
0
0
0
0
2009-07-20T15:44:00.000
5
1.2
true
1,154,331
0
0
1
3
Has anyone used SQLAlchemy in addition to Django's ORM? I'd like to use Django's ORM for object manipulation and SQLalchemy for complex queries (like those that require left outer joins). Is it possible? Note: I'm aware about django-sqlalchemy but the project doesn't seem to be production ready.
SQLAlchemy and django, is it production ready?
3,555,602
7
23
12,511
1
python,database,django,sqlalchemy
I've done it before and it's fine. Use the SQLAlchemy feature where it can read in the schema so you don't need to declare your fields twice. You can grab the connection settings from the settings, the only problem is stuff like the different flavours of postgres driver (e.g. with psyco and without). It's worth it as the SQLAlchemy stuff is just so much nicer for stuff like joins.
0
0
0
0
2009-07-20T15:44:00.000
5
1
false
1,154,331
0
0
1
3
Has anyone used SQLAlchemy in addition to Django's ORM? I'd like to use Django's ORM for object manipulation and SQLalchemy for complex queries (like those that require left outer joins). Is it possible? Note: I'm aware about django-sqlalchemy but the project doesn't seem to be production ready.
Django, how to make a view atomic?
1,155,531
-1
1
2,233
0
python,database,django,locking,atomic
Wrap the DB queries that read and the ones that update in a transaction. The syntax depends on what ORM you are using.
0
0
0
0
2009-07-20T19:38:00.000
3
-0.066568
false
1,155,513
0
0
1
1
I have a simple django app to simulate a stock market, users come in and buy/sell. When they choose to trade, the market price is read, and based on the buy/sell order the market price is increased/decreased. I'm not sure how this works in django, but is there a way to make the view atomic? i.e. I'm concerned that user A's actions may read the price but before it's updated because of his order, user B's action reads the price. Couldn't find a simple, clean solution for this online. Thanks.
Seeding random in django
1,156,541
3
4
2,315
0
python,django,random,django-views
Call random.seed() rarely if at all. To be random, you must allow the random number generator to run without touching the seed. The sequence of numbers is what's random. If you change the seed, you start a new sequence. The seed values may not be very random, leading to problems. Depending on how many numbers you need, you can consider resetting the seed from /dev/random periodically. You should try to reset the seed just before you've used up the previous seed. You don't get the full 32 bits of randomness, so you might want to reset the seed after generating 2**28 numbers.
0
0
0
0
2009-07-20T23:26:00.000
3
1.2
true
1,156,511
0
0
1
3
In a view in django I use random.random(). How often do I have to call random.seed()? One time for every request? One time for every season? One time while the webserver is running?