pylons

python list to newline separated value

hi, Im trying to get data in pylon to use in jquery autocomplete, the librarary i'm using for autocomplete it requires this format abc pqr xyz and in python i have data in this format [["abc"], ["pqr"],["xyz"] How do i convert this list to the above one. Edit: I trying to use these for a autocompete and i'm using pylons, in ...

Modifying The Template For New Pylons Controllers

I'm at a point in my Pylons projects where I end up creating and deleting controllers often (probably more often than I should). I grow tired of adding my own imports and tweaks to the top of every controller. There was a recent question about modifying the new controller template that got me part-way to not having to do that - but I do...

Why do I get an error on the last line of installing Pylons 1.0 with easy_install and Python 2.7 in Windows Vista 64?

I tried to install Pylons 1.0 with Python 2.7 using the easy_install command in Windows Vista 64 but got the error: raise ValueError(str(list(result.keys()))) ValueError: [u'path'] Here is the link to the whole installation process from command prompt http://pastie.org/1190341 Why do I get this error? How do I solve it? Will P...

How come Pylons is not recognized when I run 'import pylons' in Windows Vista command prompt?

When I try to import pylons in the virtual python environment I get the error C:\env\Scripts>python Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (A MD64)] on win32 Type "help", "copyright", "credits" or "license" for more informati on. >>> import pylons Traceback (most recent call last): File "<stdin>", line 1, in ...

Pylons - url.current() incorrect, for '/test' shows '/test/test'?

I've got a pylons setup, using flup with nginx, and url.current() always returns totally wrong. I have a route: map.connect('testpage', '/test', controller='Main', action='test') And in that controller, I do url.current() and I get /test/test' instead of '/test'. I've tried changingSCRIPT_NAME` as various posts about using uwsgi sug...

How come I can not activate my Virtual Python Environment with 'source env/bin/activate' command?

I am trying to activate my Virtual Python Environment to use with Pylons but I think I am executing the commands wrong. jem@jem-laptop:~$ source env/bin/activate bash: env/bin/activate: No such file or directory What am I doing wrong? How should I do it right? ...

Routes/Pylons Fails Before Touching My Code

I am very puzzled over this error. In a previously functional Pylons app (running on apache/mod_wsgi), Routes has exploded. When I attempt to access my application, no matter what URL I use, I get the Apache "Internal server error" page and the following traceback in /var/log/apache2/error.log. [Sat Oct 02 2010] WSGI Variables [Sat ...

How do I specify a default parameter value for a Pylons action?

I have an action which looks like this: class ArticleController(BaseController): def all(self, page, pagesize): I want to be able to access /article/all/{page}/{pagesize}, with default values for page and pagesize. I tried setting the default values in the action method, but then apparently both page and pagesize get set to the d...

Pylons + Mako -- Access POST data from templates

How can I access my request.params post data from my Mako template with Pylons? ...

Strip whitespace from Mako template output (Pylons)

Hi guys, I'm using Mako + Pylons and I've noticed a horrendous amount of whitespace in my HTML output. How would I go about getting rid of it? Reddit manage to do it. ...

Pylons - Handling GET and POST requests

Hi. What's the best way to handle form POST data in my Pylons app? I've tried: Having a seperate GET method and a POST method with a rest.restrict('post') decorator. Problem -- if there were validation errors then you can't redisplay the form with the data which the user entered because you have to redirect back to the GET method OR y...

Proper way to do session handling in Python + Pylons for a php programmer

I'm a php programmer who's just getting started with Python. I'm trying to get Python to handle login/logout via database-stored sessions. Things work, but seem inconsistent. For example, sometimes a user isn't logged out. Sometimes users "switch" logins. I'm guessing this has something to do with thread-safety, but I'm just not sur...

In Python + Pylons, simple way to copy uploaded file to disk

How can I copy a posted file to disk? Can I do something like: file = '/uploaded_files/test.txt' shutil.copy2(request.POST['file'],file) Thanks. ...

Error "AttributeError: 'unicode' object has no attribute 'read'" on file upload

I'm using Pylons to upload an image and store it to disk: <form method="post"> <input type="file" name="picture" enctype="multipart/form-data" /> </form> Then in my controller: if 'picture' in request.POST: i = ImageHandler() #Returns full path of image file picture_file = i.makePath() shutil.copyfileobj(re...

What's the easiest way to add commas to an integer in Python?

For example: >> print numberFormat(1234) >> 1,234 Or is there a built-in function in Python that does this? Thanks! ...

Truncate a string in mako template

I'd like to find a way to get a title to truncate if too long, like this: 'this is a title' 'this is a very long title that ...' Is there a way to print a string in mako, and automatically truncate with "..." if greater than a certain number of characters? Thanks. ...

How should I host multiple Pylons websites on the one server?

I currently have one Pylons website running on my server that is setup using nginx as a proxy to Paster. In the near future, I plan to host another Pylons site on the same server. If I were to go the same route and use nginx+Paster, it would mean running two paster instances on different ports and then using the one nginx server as a pr...

Condition mako base template from inheriting one

I have a base.mako template with a if statement to include or not jQuery <head> % if getattr(c, 'includeJQuery', False): <script type="text/javascript" src="jquery.js"></script> % endif ... Several templates inherit from base.mako, someone needs jQuery, someone don't. At the moment I have to set the attribute in the controller be...

FormEncode validate: words divided by a comma

Hi everyone ! How to validate words divided by a comma by FormEncode ? Something like this: "foo1, foo2, foo3" -> ["foo1", "foo2", "foo3"] ...

How can I generate an absolute url for a Pylons controller?

I need to generate a URL for use as a callback in an external system in my pylons application. This requires me to provide both the pylons-app-relative controller path (as generated by the url method: >>> relative_url = url(controller='my_cont', action='callback', id=generated_id) >>> print relative_url /my_cont/callback/1234 However,...