User Authentication in Pylons + AuthKit - python

I am trying to create a web application using Pylons and the resources on the web point to the PylonsBook page which isn't of much help. I want authentication and authorisation and is there anyway to setup Authkit to work easily with Pylons?
I tried downloading the SimpleSiteTemplate from the cheeseshop but wasn't able to run the setup-app command. It throws up an error:
File "/home/cnu/env/lib/python2.5/site-packages/SQLAlchemy-0.4.7-py2.5.egg/sqlalchemy/schema.py", line 96, in __call__
table = metadata.tables[key]
AttributeError: 'module' object has no attribute 'tables'
I use Pylons 0.9.7rc1, SQLAlchemy 0.4.7, Authkit 0.4.

Ok, another update on the subject. It seems that the cheeseshop template is broken. I've followed the chapter you linked in the post and it seems that authkit is working fine. There are some caveats:
sqlalchemy has to be in 0.5 version
authkit has to be the dev version from svn (easy_install authkit==dev)
I managed to get it working fine.

I gave up on authkit and rolled my own:
http://tonylandis.com/openid-db-authentication-in-pylons-is-easy-with-rpx/

I don't think AuthKit is actively maintained anymore. It does use the Paste (http://pythonpaste.org) libs though for things like HTTP Basic/Digest authentication. I would probably go ahead and take a look at the source for some inspiration and then use the Paste tools if you want to use HTTP authentication.
There is also OpenID which is very easy to setup. The python-openid libs have an excellent example that is easy to translate to WSGI for wrapping a Pylons app. You can look at an example:
http://ionrock.org/hg/brightcontent-main/file/d87b7dcc606c/brightcontent/plugins/openidauth.py

This actually got me interested:Check out this mailing on the pylons list. So AuthKit is being developed, and I will follow the book and get back on the results.

Related

confused about Solr Django and Haystack installation

I'm following the tutorial in the Haystack for using solr in django. I download haystack ad it to my installed apps, and I like to check my development to make sure my apps still working. So when I go to my my localhost it says
A server error occurred. Please contact the administrator.
and in my terminal it says
raise MissingDependency("The 'solr' backend requires the installation of 'pysolr'. Please refer to the documentation.")
and when I go to the pysolr documentation it seems as if it's to be used without haystack. There is no mention pysolr in haystack docs and no mention of haystack in pysolr docs. Not only that, but pysolr gives an example that says
# If on Python 2.X
Im using python 3. I understand theres a learning curve but is there anything that has all the resources in one post? Or must I just trial and error it out? and also can it be Kind of up to date? 2.x to 3.5 is a big gap. There are surprisingly no google videos or vimeo videos on this. any and all help is welcome. I know anything worth having or knowing isn't easy to come by but sheesh? the few sites Ive seen also have the url like this in urls.py
(r'^search/', include('haystack.urls')),
but if I do it like that I get an error
regex_pattern = pattern.regex.pattern
AttributeError: 'tuple' object has no attribute 'regex'
this may seem like nothing to someone experienced, but to the untrained this can lead to a lot of confusion to the proper syntax.
Haystack uses different adapters to talk to different backend services, such as ElasticSearch or Solr.
The Solr adapter uses pysolr:
You’ll also need a Solr binding, pysolr. The official pysolr package, distributed via PyPI, is the best version to use (2.1.0+). Place pysolr.py somewhere on your PYTHONPATH.
You shouldn't have to do anything with pysolr yourself, as that is only used inside the haystack Solr adapter. Be sure to follow the tutorial for setting up the schema and getting the indexing running.
just pip install pysolr and move about your day.
Personally, I used(in my virtual env):
python3 -m pip install pysolr

How do I initialise my Satchmo website?

As an experienced PHP programmer I tend to avoid things like Python. However we all must play with the cards we have been dealt with and I now have to work with a Satchmo website.
I have very little python, django and satchmo so I need some help. I'm ok with setting up a development server but I cannot get my website to work on a production server.
I've seen the use of "python manage.py runserver", this solution is even on Stack Overflow. However, when I see this solution there is usually someone saying "I hope you're not using that on production" so I assume this is a very incorrect way to do it. To my frustration the people that seem to know that this command line is insecure, also have no desire to share with the rest of us, just how excatly does one initiate their Satchmo Production server?
Many thanks.
To deploy a Django website on a production server, you have to serve it either with Apache+mod_wsgi, nginx+gunicorn, nginx+uwsgi, or any other server supporting WSGI. The Django documentation has a page on deploying Django on Apache with mod_wsgi, for the other solutions, there are plenty of useful documentation around the web.
runserver is just for development/testing. It won't handle high load, security, etc.
Python.org has docs on how to set up a proper webserver to serve Python code:
http://docs.python.org/howto/webservers.html
Satchmo seems like a django derivative. Setting up django on production is quite easy if your deployment environment is linux with apache then use mod_wsgi which is well documented here if its windows then you can use the pyisapie module and follow the documentation here
Hope that helps

Python Web Framework with best Mongo support

I'm looking to write a small web app to utilise a dataset I already have stored in a MongoDB collection. I've been writing more Python than other languages lately and would like to broaden my repertoire and write a Python web app.
It seems however that most if not all of the current popular Python web development frameworks favour MySQL and others with no mention given to MongoDB.
I am aware that there are more than likely plugins written to allow Mongo be used with existing frameworks but so far have found little as to documentation that compares and contrasts them.
I was wondering what in people's experience is the Python web development framework with the best MongoDB support?
Many thanks in advance,
Patrick
I have not tried MongoKit although it has been around for a while and retains a good reputation. I personally prefer MongoEngine and feel very comfortable with it (maybe because I like its nice homepage and good documentation). There is also a very good opensource project named Mumblr which demonstrates a Django-MongoEngine-MongoDB combination, which I think a very good starter for any project. I'm developing a CMS for my own company using this app.
I've used MongoKit with Pylons before and it worked out good.
You might want to refer to this post though: MongoDB ORM for Python?
There is no stable support for mongodb using django framework. I tried using mongoengine, but unlike models, provided for admin in django framework, there is no support for mongoengine.
Correct if I am wrong.
Flask is the best framework to use with MongoDB. It has a mongodb library called flask-pymongo
Make sure you run the following commands before starting your project.
$ pip3 install Flask
$ pip3 install Flask-PyMongo

How do I set up a basic website with registration in Python on Dreamhost?

I need to write a basic website on Dreamhost. It needs to be done in Python.
I discovered Dreamhost permits me to write .py files, and read them.
Example:
#!/usr/bin/python
print "Content-type: text/html\n\n"
print "hello world"
So now I am looking for a basic framework, or a set of files that has already programmed the whole registration to be able to kick-off the project in a simple way.
By registration I mean the files to register a new account, log in, check the email (sending a mail), and edit the user information. All this possibly using MySQL.
Let me share my own experience with django. My prerequisits:
average knowledge of python
very weak idea of how web works (no js skills, just a bit of css)
my day job is filled with coding in C and I just wanted to try something different,
so there certainly was a passion to learn (I think this is the most important one)
Why I've chosen django:
I've already knew bits and pieces of python
django has excelent documentation, including tutorial, which explained everything
in very clear and simple manner
It is worth to read complete manual first (it took me two or three weekends. I remember I could not remember/understand everything at first pass, but it helped me to learn where
the information can be found when needed. There is also another source of documentaion
called djangobook. Djangobook contains same information as manual, but things are explained more in detail. It's worth to read it also, it helps to catch up with MVC concept, if you have not tried that before.
And finally to answer your question best: there are already also OpenId modules ready for you. I'm considering to use django-authopenid for my new project. It supports OpenId, while providing fallback to locally managed users.
There is certain learning curve if you are going learn django. The more you know about the web and python the steeper the curve is. I had to also learn bits and pieces of javascript and it took me also some time. If you are able to spend full time learning django, then
you can expect you'll be able to deliver first results within 4-6 weeks. It took me 6 months, since I was doing my django studies in free time.
There are several blog entries &c pointing out some problems with Python on Dreamhost and how to work around them to run several web frameworks that could suit you. (Most of the posts are over a year old so it may be that dreamhost has fixed some of the issues since then, of course, but the only way to really find out is to try!-).
Start with this page, dreamhost's own wikipage about Python -- at least you know it's quite current (was last updated earlier today!-). It gives instructions on using virtual env, building a custom Python &c if you absolutely need that, and running WSGI apps -- WSGI is the common underpinning of all modern Python web frameworks, including Django which everybody's recommending but also Pylons &c.
Some notes on running Pylons on Dreamhost are here (but it does look like Dreamhost has since fixed some issues, e.g. flup is now the dreamhost-recommended FCGI layer for WSGI as you'll see at the previously mentioned URL) and links therefrom. If you do go with Pylons, here is the best place to start considering how best to do auth (authentication and authorization) with it. I'm trying to play devil's advocate since everybody else's recommending django, but for a beginner django may in fact be better than pylons (still, spending a day or so lightly researching each main alternative, before you commit to one, is a good investment of your time!-).
For Django, again there's an official dreamhost wiki page and it's pretty thorough -- be sure to read through it and briefly to the other URLs it points to. The contributed auth module is no doubt the best way to do authentication and authorization if you do decide to go with Django.
And, whichever way you do choose -- best of luck!
django framework
You can try starting with django-registration.
EDIT: You can probably hack something up on your own faster than learning Django. However, learning a framework will serve you better. You'll be able to easily ask a large community when you have problems, and build on work that's already been done. And of course, if you're doing something new in the future, your knowledge of the framework can be more easily reapplied.
Django is the way to go. You can try it locally on your PC and see do you like it. It is very nice framework and allows you to quickly build your applications.
If you want to give Django quick go to see how it feels you can download Portable Python where everything is preinstalled and ready to use.
You can also do what you are trying to do with apache module mod_python (which is also used to run Django) but it would require more coding. Your code snippet would work with mod_python (http://www.modpython.org/) right away. I think mod_python comes pre-installed on Dreamhost so you can try it.
For a more complete basic setup (with lots of preprogrammed features) I would point you at Pinax which is a web site on top of Django (which I praise of course, see the dedicated page on dreamhost Wiki at http://wiki.dreamhost.com/Django)
The introduction on the project's web site (pinaxproject.com) :
Pinax is an open-source platform built on the Django Web Framework.
By integrating numerous reusable
Django apps to take care of the things
that many sites have in common, it
lets you focus on what makes your site
different.
There you will have a complete web site to customize and add features to.
I've noticed that a lot of people recommend Django. If you're running on a shared host on Dreamhost, the performance will not be satisfactory.
This is a known issue with Dreamhost shared hosting. I have installed web2py on my Dreamhost shared account and it seems to work okay; search the google groups for an install FAQ.
Later edit: google Dreamhost Django performance for an idea of what I mean.
Another voice to the choir.
Go for django. It's very good and easy to use.

Lightweight python wiki engine with pluggable auth system

I need to add wiki to my Tornado webapp. i'm new to python so i would like it not too intimidating to be learned and integrated and can use my existing authentication system, hence the lightweight. it would be better if can use mongodb backend.
I already take a look at moin-moin and it seems too complex(?). any other alternative?
Have a look at Hatta. Overwrite WikiRequest.get_author() method to plug your authentication system. But it uses mercurial repository to store the data.
Skeletonz is a very nice lightweight Python cms that might be worth a look...

Categories