python

The fastest best language to develop a fully featured web app.

Hi, I consider myself as skilled programmer and know a large number of languages. Eg Fortran, C, Ruby, Python, PHP, VB, Obj-C, C# etc. I want to build a fully featured piece of Web Based software that would have the following modules. 1. Calendaring System for managing bookings. 2. Record keeping and notes system to record details abou...

django: trying to access my robots.txt: "TypeError at /robots.txt 'str' object is not callable"

Exception Type: TypeError at /robots.txt Exception Value: 'str' object is not callable What gives? Views: ROBOTS_PATH = os.path.join(CURRENT_PATH, 'robots.txt') def robots(request): """ view for robots.txt file """ return HttpResponse(open(ROBOTS_PATH).read(), 'text/plain') Settings: CURRENT_PATH = os.path.abspath(os.path.dirnam...

Does Lua support Decorators?

I come from a Python background and really like the power of Python Decorators. Does Lua support Decorators? I've read the following link but it's unclear to me: http://lua-users.org/wiki/DecoratorsAndDocstrings UPDATE Would you also mind given an example how how to implement it in Lua if it's possible. ...

Alternative to Passing Global Variables Around to Classes and Functions

I'm new to python, and I've been reading that using global to pass variables to other functions is considered noobie, as well as a bad practice. I would like to move away from using global variables, but I'm not sure what to do instead. Right now I have a UI I've created in wxPython as its own separate class, and I have another class th...

POST multiple checkbox value tornado

I am messing around with a tornado web app with which I need a bit of help. I have multiple checkboxes with the same name and I would like to POST the values of the selected one. <input id=DB_BASED_ID name="activity" value=DB_BASED_ID type="checkbox"/> <input id=DB_BASED_ID name="activity" value=DB_BASED_ID type="checkbox"/> <input id=...

Computing greatest common denominator in python

If you have a list of integers in python, say L = [4,8,12,24], how can you compute their greatest common denominator/divisor (4 in this case)? ...

CherryPy How to respond with JSON?

In my controller/request-handler, I have the following code: def monkey(self, **kwargs): cherrypy.response.headers['Content-Type'] = "application/json" message = {"message" : "Hello World!" } return message monkey.exposed = True And, in my view, I've got this javascript: $(function() { var body = document.getElementsByTagNa...

Automatic spam filtering or flagging for Django or Python?

I'm working on a Django-based site that consists mostly of user- generated content: reviews, comments, tweet-like posts, etc. I'm concerned about spam. Are there any spam filters available for Django/Python? If not, what types of algorithms can be used for automatic spam filtering or flagging? On a more general note, does anyone k...

Query filtering in Django with sqlite

I've tried the following query with Django, def search(search_text): q = Info.objects.filter(title__contains=str(search_text)) print q.query The query that get printed is SELECT "d"."id", "d"."foo" FROM "d_info" WHERE "d_info"."title" LIKE %hello% ESCAPE '\' The query fails because the text after LIKE doesn't have quotes ...

How to efficiently filter a string against a long list of words in Python/Django?

Stackoverflow implemented its "Related Questions" feature by taking the title of the current question being asked and removing from it the 10,000 most common English words according to Google. The remaining words are then submitted as a fulltext search to find related questions. I want to do something similar in my Django site. What is ...

Python: using downloaded modules

Hello, I am new to Python and mostly used my own code. But so now I downloaded a package that I need for some problem I have. Example structure: root\ externals\ __init__.py cowfactory\ __init__.py cow.py milk.py kittens.py Now the cowfactory's __init__.py does from cowfac...

Boost.Python function pointers as class constructor argument

I have a C++ class that requires a function pointer in it's constructor (float(*myfunction)(vector<float>*)) I've already exposed some function pointers to Python. The ideal way to use this class is something like this: import mymodule mymodule.some_class(mymodule.some_function) So I tell Boost about this class like so: class_<Some...

django user model and custom primary key field

Django by default makes a primary key field on each model named "id", with a type of AutoField. On my models, I'm overriding this to use a custom UUIDField as the primary key by using the "primary_key" attribute. I would also like the User model in django.contrib.auth to have a UUIDField as the primary key, but this doesn't seem to be po...

Google App Engine: Including external packages.

Hello, I understand that if you want to include external packages you have to include them in your project. So I was wondering how do you do this? Do people use one general script that auto imports them from a location. Maybe some kind of config file that lists all the external packages? Do you always zip the packages and use zipimpor...

Postfix hangs when sending email

If I try to send an email as follows, the process hangs and nothing happens: >>> from django.core.management import setup_environ >>> from cube import settings >>> setup_environ(settings) 'cube' >>> from django.core.mail import send_mail >>> send_mail('Subject', 'Message', '[email protected]', ['[email protected]'], fail_silently=Fal...

Django "for" loop and python dictionary problems

Hi all, I'm having a couple of issues getting django templating for loop tag to go through this dictionary: It is definitely being passed to the page ok as if I just do: {% for event in events %} {{ event }} {% endfor %} it writes 1,2,3 but when I try and do {{ event.start }} it just doesn't output anything... evs = { ...

Using python "with" statement with try-except block

Is this the right way to use the python "with" statement in combination with a try-except block?: try: with open("file", "r") as f: line = f.readline() except IOError: <whatever> If it is, then considering the old way of doing things: try: f = open("file", "r") line = f.readline() except IOError: <whatever...

How to get byte offset in a file in python

hello, I am making a inverted index using hadoop and python. I want to know how can I include the byte offset of a line/word in python. I need something like this hello hello.txt@1124 I need the locations for making a full inverted index. Please help. ...

Python pickling error when using sessions

In my django app I was creating an extended user profile using session vars. But when registration form was saved and user was about to create, I got following error : Traceback (most recent call last): File "\Python26\Lib\site-packages\django\core\servers\basehttp.py", line 279, in run self.result = application(self.environ, sel...

Does python have a safe, user editable script markup for templates like RoR's liquid?

I'm looking for a templating language, that end users can safely edit to customize their html/theme of a web application. Something to how http://www.liquidmarkup.org/ works. ...