pylons

How to use OpenID in RESTful API?

て烟熏妆下的殇ゞ 提交于 2019-12-03 03:06:37
问题 I'm building Pylons-based web application with RESTful API, which currently lacks any authentication. So I'm going to implement that and in order to avoid all the trouble and caution with storing user passwords, I'd like to use OpenID for authentication. What would be the best way to do this? Are these two things compatible? Are there existing REST APIs that use OpenID that I can take inspiration from? 回答1: I've now spent some time researching the options and would like to summarize the

Ruby LESS gem equivalent in Python

纵然是瞬间 提交于 2019-12-03 00:22:43
The Ruby LESS gem looks awesome - and I am working on a Python/Pylons web project where it would be highly useful. CSS is, as someone we're all familiar with recently wrote about , clunky in some important ways. So I'd like to make it easier on myself. Is there an existing Python module or library that provides parallel functionality? I have need for a Python lesscss compiler too, so have started work on one here: http://code.google.com/p/lesscss-python/ Version 0.0.1 has been released, with no support for namespaces/accessors. It is probably riddled with bugs too. Please feel free to chip in

How can I redirect after POST in Pyramid?

核能气质少年 提交于 2019-12-02 22:29:23
I'm trying to have my form submit to a route which will validate the data then redirect back to the original route. For example: User loads the page website.com/post Form POSTs the data to website.com/post-save User gets redirected back to website.com/post Pyramid is giving me some troubles doing this. Here's my slimmed down views.py def _get_link_form(post_data): """ Returns the initialised form object """ return LinkForm(post_data) def home_page(request): form = _get_link_form(request.POST) return {'form' : form} def save_post(request): """ form data is submitted here """" form = _get_link

How to get column names from SQLAlchemy result (declarative syntax)

风格不统一 提交于 2019-12-02 21:54:59
I am working in a pyramid project and I've the table in SQLAlchemy in declarative syntax """models.py""" class Projects(Base): __tablename__ = 'projects' __table_args__ = {'autoload': True} I get the results by using """"views.py""" session = DBSession() row_data = session.query(Projects).filter_by(id=1).one() How can I get the column names from this result. PS: I am unable to use this method since I am using the declarative syntax. zzzeek The difference is between ORM and non-ORM, not declarative, which is just a helper for the ORM. Query has a method column_descriptions() that was added for

How to use OpenID in RESTful API?

▼魔方 西西 提交于 2019-12-02 17:40:08
I'm building Pylons-based web application with RESTful API, which currently lacks any authentication. So I'm going to implement that and in order to avoid all the trouble and caution with storing user passwords, I'd like to use OpenID for authentication. What would be the best way to do this? Are these two things compatible? Are there existing REST APIs that use OpenID that I can take inspiration from? Pēteris Caune I've now spent some time researching the options and would like to summarize the findings. First, a little bit more context -- I develop and control both the service and API

How do I run a single test with Nose in Pylons

你离开我真会死。 提交于 2019-12-02 15:47:45
I have a Pylons 1.0 app with a bunch of tests in the test/functional directory. I'm getting weird test results and I want to just run a single test. The nose documentation says I should be able to pass in a test name at the command line but I get ImportErrors no matter what I do For example: nosetests -x -s sometestname Gives: Traceback (most recent call last): File "/home/ben/.virtualenvs/tsq/lib/python2.6/site-packages/nose-0.11.4-py2.6.egg/nose/loader.py", line 371, in loadTestsFromName module = resolve_name(addr.module) File "/home/ben/.virtualenvs/tsq/lib/python2.6/site-packages/nose-0.11

Routing subdomains in Pyramid

Deadly 提交于 2019-12-01 18:39:13
问题 In Pylons 1.0 I could go into config/routing.py and add map.connect('/', controller='index', conditions=dict(sub_domain=False)) map.connect('/', controller='mobileindex', conditions=dict(sub_domain='m')) to route m.mydomain.com to a different controller, but still use the same app. Can I do the same in Pyramid? 回答1: Theoretically, this is covered by add_route() with a pregenerator argument. 回答2: An example of what @syrion is referring to is available here: Multiple domains and subdomains on a

Insert not working for SQLAlchemy database session

五迷三道 提交于 2019-12-01 16:41:34
问题 Why isn't a record being inserted? There is an id returned but when I check the database there is no new record. From models.py from zope.sqlalchemy import ZopeTransactionExtension DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) And views.py DBSession.execute(text('INSERT INTO (a,b,c) VALUES (\'a\',\'b\',\'c\') RETURNING id'), params=dict(a=a,b=b,c=c)) I've tried committing with transaction.commit() which doesn't get an error but doesn't insert a record. result

Python MySQLdb placeholders syntax

允我心安 提交于 2019-12-01 09:30:09
I'd like to use placeholders as seen in this example: cursor.execute (""" UPDATE animal SET name = %s WHERE name = %s """, ("snake", "turtle")) Except I'd like to have the query be its own variable as I need to insert a query into multiple databases, as in: query = """UPDATE animal SET name = %s WHERE name = %s """, ("snake", "turtle")) cursor.execute(query) cursor2.execute(query) cursor3.execute(query) What would be the proper syntax for doing something like this? query = """UPDATE animal SET name = %s WHERE name = %s """ values = ("snake", "turtle") cursor.execute(query, values) cursor2

Python MySQLdb placeholders syntax

你。 提交于 2019-12-01 07:31:24
问题 I'd like to use placeholders as seen in this example: cursor.execute (""" UPDATE animal SET name = %s WHERE name = %s """, ("snake", "turtle")) Except I'd like to have the query be its own variable as I need to insert a query into multiple databases, as in: query = """UPDATE animal SET name = %s WHERE name = %s """, ("snake", "turtle")) cursor.execute(query) cursor2.execute(query) cursor3.execute(query) What would be the proper syntax for doing something like this? 回答1: query = """UPDATE