python

Django Deploy trouble

Well, i've walking around this for a couples of days now... I think is time to ask for some help, i think my installation is ok... Server OS: Centos 5 Python -v 2.6.5 Django -v (1, 1, 1, 'final', 0) my apache conf: <VirtualHost *:80> DocumentRoot /opt/workshop ServerName taller.antell.com.py WSGIScriptAlias / /opt/workshop/...

Google app engine How to count SUM from datestore?

Hey, Im wondering, how can i get a SUM of a rating entity i get from the datastore (python)? should i: ratingsum = 0 for rating in ratings: ratingsum + rating print ratingsum ? ...

Conditional row coloring in a PocketPyGUI table (PythonCE)

I'm working on a an PythonCE application, using the PocketPyGUI toolkit. I'm using the gui.Table control to display a large list of choices (addresses, codes and data associated), and I want to assign a different color to the rows that have been completed. Is there any way to colorize the rows given certain conditions? TIA, Pablo ...

Encoding in python with lxml - complex solution

Hi, I need to download and parse webpage with lxml and build UTF-8 xml output. I thing schema in pseudocode is more illustrative: from lxml import etree webfile = urllib2.urlopen(url) root = etree.parse(webfile.read(), parser=etree.HTMLParser(recover=True)) txt = my_process_text(etree.tostring(root.xpath('/html/body'), encoding=utf8)...

Google App Engine says "Must authenticate first." while trying to deploy any app

Google App Engine says "Must authenticate first." while trying to deploy any app: me@myhost /opt/google_appengine $ python appcfg.py update ~/sda2/workspace/lyapapam/ Application: lyapapam; version: 1. Server: appengine.google.com. Scanning files on local disk. Scanned 500 files. Scanned 1000 files. Initiating update. Email: <email_her...

python multiprocessing server connections

I wish to get a list of connections to a manager. I can get last_accepted from the servers' listener, but I want all connections. There HAS to be a method I am missing somewhere to return all connections to a server or manager Please help!! ...

Mako template depending on object class?

whats a clean way to use different templates depending on an object class? other than buncha if statements ...

Django: How can I get a block from a template?

Suppose my template has in it something like {% block subject %}my subject{% endblock %} and I load this template with tmpl = loader.get_template('mytemplate.html'), how can I extract "my subject"? ...

json KeyError with json.loads

my apologies in advance for a python and json nubie question. json seems to be hiccuping on the following statements: {"delete":{"status":{"id":12600579001,"user_id":55389449}}} code snippet: temp = json.loads(line) text = temp['text'] I get the following error output when the above code snippet encounters lines similar to the abov...

Problem with recognizing "\t" for vim in python output.

I have a python code something like this file_out.write(str(i).strip()+"\t"+str(dict1[i]).strip()+"\n") But when i try to recognize this with vim by saying on the file that was written. :%s/\t/|/g But it does not recognize the \t ...

Writing a blocking wrapper around twisted's IRC client

I'm trying to write a dead-simple interface for an IRC library, like so: import simpleirc connection = simpleirc.Connect('irc.freenode.net', 6667) channel = connection.join('foo') find_command = re.compile(r'google ([a-z]+)').findall for msg in channel: for t in find_command(msg): channel.say("http://google.com/search?q=%s...

Django-admin.py not working (-bash:django-admin.py: command not found)

I'm having trouble getting django-admin.py to work... it's in this first location: /Users/mycomp/bin/ but I think I need it in another location for the terminal to recognize it, no? Noob, Please help. Thanks!! my-computer:~/Django-1.1.1 mycomp$ sudo ln -s /Users/mycomp/bin/django-admin.py /Users/mycomp/django-1.1.1/django-admin.py Pas...

Copy an entity in Google App Engine datastore in Python without knowing property names at 'compile' time

In a Python Google App Engine app I'm writing, I have an entity stored in the datastore that I need to retrieve, make an exact copy of it (with the exception of the key), and then put this entity back in. How should I do this? In particular, are there any caveats or tricks I need to be aware of when doing this so that I get a copy of t...

Python hash() can't handle long integer?

I defined a class: class A: ''' hash test class >>> a = A(9, 1196833379, 1, 1773396906) >>> hash(a) -340004569 This is weird, 12544897317L expected. ''' def __init__(self, a, b, c, d): self.a = a self.b = b self.c = c self.d = d def __hash__(self): return self.a ...

Can't get python.manage.py syncdb to work

I just created my first django app, initialized variables DATABASE_ENGINE and DATABASE_NAME in settings.py, but now when I run python manage.py syncdb, I get the following error Can somebody help? Does this have to do with having two python versions installed? I'm a django/python noob, please help. thanks!! my-computer:~/Django-1.1.1 m...

Django: Serving Media Behind Custom URL

So I of course know that serving static files through Django will send you straight to hell but I am confused on how to use a custom url to mask the true location of the file using Django. http://stackoverflow.com/questions/2681338/django-serving-a-download-in-a-generic-view but the answer I accepted seems to be the "wrong" way of doing...

how to print chinese word in my code.. using python

this is my code: print '哈哈'.decode('gb2312').encode('utf-8') and it print : SyntaxError: Non-ASCII character '\xe5' in file D:\zjm_code\a.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details how to print '哈哈' thanks updated when i use this: #!/usr/bin/python # -*- coding: utf-8 -*- ...

Iphone Question: Multi-colored Textbox

Hello I'm stuck at this: How to implement a multi-colored textbox without using a WebView Obj? I want the textcolor updated in each key event and if I use a WebView The app will surely lag a little(touch 1g). I'm finishing up a app that teaches basic english, everything is up and running perfectly, but then I realized that a multi-color...

How to iterate over the first n elements of a list?

Say I want I've got a list and I want to iterate over the first n of them. What's the most concise way to write this in Python? ...

does python have any service like jndi?

Hello, I wanted to know if python had any service like Java's JNDI. More specifically, I want a service where providers can register themselves and then consumers can ask fro where certain provider end-points are. For example, assume that I want to implement a mailbox for all my friends. Each of them have their own end-point, so friend...