python

Django MVC pattern for non database driven models?

I'm just working my way through Django, and really liking it so far, but I have an issue and I'm not sure what the typical way to solve it. Suppose I have a View which is supposed to be updated when some complex Python object is updated, but this object is not driven by the database, say it is driven by AJAX calls or directly by the use...

Python capture output from wget?

Is it possible to capture output from wget and other command line programs that use curses? Here is what I have right now: p = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=0) for line in p.stdout: print "a" This works fine for programs that have simple output, but not for wget and other programs that use curses. ...

Phonon VideoWidget error: "the video widget could not be initialized correctly"

I asked this question on the PyQt mailing list, and didn't get any responses, so I'll try my luck here. I've encountered a frustrating issue (on Windows only): when trying to create a VideoWidget instance, I'm getting the error message "the video widget could not be initialized correctly". Oddly, this just surfaced in the code after sev...

Checking for group membership (Many to Many in Django)

I have two models in Django: groups and entries. Groups has a many-to-many field that connects it to entries. I want to select all entries that have a group (as not all do!) and be able to access their group.title field. I've tried something along the lines of: t = Entries.objects.select_related().exclude(group=None) and while this ...

Abstraction and client/server architecture questions for Python game program

Here is where I am at presently. I am designing a card game with the aim of utilizing major components for future work. The part that is hanging me up is creating a layer of abstraction between the server and the client(s). A server is started, and then one or more clients can connect (locally or remotely). I am designing a thick client ...

Confused by Django's claim to MVC, what is it exactly?

So what exactly is Django implementing? Seems like there are Models Views Templates Models = Database mappings Views = Grab relevant data from the models and formats it via templates Templates = Display HTML depending on data given by Views EDIT: S. Lott cleared a lot up with this in an edit to a previous post, but I...

When I catch an exception, how do I get the type, file, and line number of the previous frame?

From this question, I'm now doing error handling one level down. That is, I call a function which calls another larger function, and I want where it failed in that larger function, not in the smaller function. Specific example. Code is: import sys, os def workerFunc(): return 4/0 def runTest(): try: print workerFunc() ...

Django : get entries of today and SplitDateTime Widget ?!

hello I used : SplitDateTimeWidget to split DateTime field , appointment = forms.DateTimeField(widget=forms.SplitDateTimeWidget) In the template side i manage to use datePicker and TimePicker for each field , using jQuery . When i try to filter the entries regarding to today date as in this code : d = datetime.date.today() entries...

microcrontroller output to python cgi script

I bought this temperature sensor logger kit: http://quozl.netrek.org/ts/. It works great with the supplied C code, I like to use python because of its simplicity, so I wrote a script in python that displays the output from the microcontroller. I only have one temperature sensor hooked up to the kit. I want the temperature to be displayed...

How can I tell whether my Django application is running on development server or not?

How can I be certain that my application is running on development server or not? I suppose I could check value of settings.DEBUG and assume if DEBUG is True then it's running on development server, but I'd prefer to know for sure than relying on convention. ...

Django ImageField validation & PIL

Hello On sunday, I had problems with python modules, when I installed stackless python. Now I have compiled and installed : setuptools & python-mysqldb and i got my django project up and running again. (i also reinstalled django-1.1), Then I compiled and installed, jpeg, freetype2 and PIL. I also started using mod_wsgi instead of ...

Is there a quick way to tell if an app is in Django's installed_apps?

I'm writing a quick Django module and want to check for another module. Is there's a shortcut to check if another module is in the installed_apps list in Django's settings? ...

Is it possible to filter on a related item in Django annotations?

I have the following 2 models: class Job(models.Model): title = models.CharField(_('title'), max_length=50) description = models.TextField(_('description')) category = models.ForeignKey(JobCategory, related_name='jobs') created_date = models.DateTimeField(auto_now_add=True) class JobCategory(models.Model): title = m...

google python data example: pizza party

hey i started learning python and am quite confused as how the google data library works. google has a pizza party example over at this link can anyone here please take the time to explain how it is being done. i would be so grateful. WHAT I UNDERSTAND: <entry xmlns='http://www.w3.org/2005/Atom' xmlns:p='http://example.com/pizza/1.0'&...

How does Python for loop work?

I am used to the C++ way of for loops, but the Python loops have left me confused. for party in feed.entry: print party.location.address.text Here party in feed.entry. What does it signify and how does it actually work? ...

How to open a file and find the longest length of a line and then print it out

Here's is what I have done so far but the length function isn't working. import string def main(): print " This program reads from a file and then prints out the" print " line with the longest length the line ,or with the highest sum" print " of ASCII values , or the line with the greatest number of words" infile = open(...

How to automate browsing using python?

Hi, suppose, I need to perform a set of procedure on a particular website say, fill some forms, click submit button, send the data back to server, receive the response, again do something based on the response and send the data back to the server of the website. I know there is a webbrowser module in python, but I want to do this without...

Renaming objects with Wing IDE

I am just transitioning from Eclipse to Wing IDE for my Python code. In Eclipse I had an option to "rename" objects. I could take any object defined in my code, it could be a variable or a function or a method or whatever, and I could rename it automatically in all the files that referenced it. Is there a similar feature in Wing IDE? ...

Display Django form inputs on thanks page

I'm attempting to take 4-5 fields from a large django form and display them on the thanks page. I want to disply the values with a good degree of control, as i'll be building an iFrame with parameterd querystrings based on the form inputs. Currently I have: forms.py ---- -*- encoding: utf-8 -*- from django import forms from django.fo...

Storing dynamically generated code as string or as code object ?

I'm hacking a little template engine. I've a class (pompously named the template compiler) that produce a string of dynamically generated code. for instance : def dynamic_function(arg): #statement return rendered_template At rendering time, I call the built-in function exec against this code, with a custom globals dictionary (in ...