(One of the summaries of a talk at the 2014 djangocon.eu.)
The goal is to provide single sign on (SSO) to an internal application within your company network.
You can use ksktutil
to create a keytab. You then need to configure apache
to look at that keytab. And you need to tell it to require a valid user.
Django has support for such an externally set user that’s send as a
REMOTE_USER
in the header. See
https://docs.djangoproject.com/en/1.7/howto/auth-remote-user/
You next need to check if your browser works out-of-the-box or whether you need to do some more configuration
There’s more data in his notes: https://gist.github.com/aaugustin/10715655
He hopes to get a pycon off the ground in sub-saharan Africa (not South Africa, as there’s already a conference there).
The goal: sustainability. They have to be able to build up skills locally. Skills shouldn’t have to be imported.
The only way forward is to use open source products.
Through his university, he has some contacts. Nothing is fixed. There is much work to be done. And you cannot rush it: if you blow it, you could set the process back 10 years.
They need people to help, especially with contacts and ideas. See http://pycons-in-africa.readthedocs.org/
Loads is a tool to run load tests. Does your site break under pressure? How far can you push your server architecture?
You can write a test for loads, just like a regular unittest. You normally deploy a cluster of loads machines to do the actual checks.
In the future they want to remove some bottlenecks in the architecture. And they are trying to build a load-runner interface for other languages.
Cricket is a tool he has written. He wrote it with the unix philosophy in the back of his mind. Every tool does one thing and one thing only.
The collary is that the only allowed user interface is the command line. That leads to horrid output if you run the django test suite.
pip install cricket
Then run cricket django
(or whatever project) and you get a nice proper
GUI that shows the test results and gives nice feedback of how many tests have
already been run. And you can check the output of the failed tests even when
the other tests are still running*.
And you can re-run specific test cases or the whole test suite.
Also look at BeeWare, that’s supposed to become a suite of similar smaller tools/IDEs.
django-parler is a simple django model translator. There are a couple of existing apps that try to do the same, but he didn’t like any one of them.
He did some quick hacks that worked quite well. He packaged it up as https://pypi.python.org/pypi/django-parler
It is quite simple to use, so he tried getting it to work with the “oscar” CMS and it was quick and straightforward to get it running. He showed a quick demo.
Diecutter is a tool for generating files. A bit like django’s “startproject”. You generate files using templates and data.
You can implement it as a service. See http://diecutter.io/ and http://diecutter.readthedocs.org/
Render templates against data whereever the template is and whatever the engine. It currently uses the jinja2 template engine and it reads templates from github.
For an example template, see https://github.com/diecutter/python-startproject
This is a good way to share best practices!
Concurrency and synchronization: finding a way.
Concurrency isn’t parallelism and it isn’t distributed. Basically: threads within a single process. A problem: correctness is hard to get right. There are a couple of requirements.
He wrote something in Go to show how it works. See https://github.com/alex-moon/ariadne
How to run the same tests on both low and high levels.
Often you can have isolated component tests that are all green. But in production, something somewhere is broken. Doing a full stack test including apache and database setup and so takes way too much time. How to solve this?
Solution: one set of tests that can be run by different drivers. A developer can run the tests locally with an in-memory database. A specific test server runs the whole stack.
The tests need to be more generic and functional-like. The test is a description of what the state is and what has to be done and what should be the end state.
He is 95% done with a proof-of-concept. If you’re interested: talk to him.
Django village will be the “first” django conference in Orvietto, Italy. 13-15 June.
Look at http://12factor.net, great site. It is quite close to a standard. A set of best practices for deployment.
A quick glance at some of those 12 factors.
Config: store config in the environment. You can split your config files. And you can use environment variables by using “envdir”. See https://pypi.python.org/pypi/envdir .
Dependencies. You should explicitly declare your dependencies. Use requirement files and virtualenv.
You should also package and version your internal apps.
Use your own pypi server (localshop/devpi)
Build, release, run: separate these states. You can build your releases beforehand. Virtualenv, packages, static assets: grab them beforehand.
Python is like poetry. So French people like to work with it.
Javascript is different. You’re not going to seduce someone with that…
In javascript you don’t need to create classes, you just create an object. It isn’t as polite as python, where you first create a proper class.
What are classes? Basically something that creates an object and that has methods attached to it.
In javascript, you could make a function that returns an object. This makes it already behave a bit as a class, right?
Every object in javascript has a “prototype” when you make it with the new
keyword. So new function_that_returns_an_object()
. This attaches the
object to its prototype. This allows you to attach a method to the object.
So… you can get something working in javascript.
Something surprising: if you define a variable at the top level of a javascript file, it is automatically a global thoughout your code instead of only inside that single file. You can work around this by putting all the code inside a function…
Best practice is actually to use a so-called anonymous function.
bpython is a fancy python interface. It shows you the available completions for what you’re typing at the moment.
With F2
you can call up the docstring for whatever you’re working on now.
See http://bpython-interpreter.org/
He demoed it with https://github.com/rfk/playitagainsam . It looked like he was typing live. Pretty quick. While holding the mike in his left hand. So people started to wonder how he did it. Playitagainsam allowed him to pre-record the keystrokes and play it back later.
Very nice effect!
https://botbot.me/ is an IRC logger. Currently it logs 250 channels. IRC means real-time.
It uses redis and postgresql and django. It actually uses three different redis channels for various purposes.
My name is Reinout van Rees and I program in Python, I live in the Netherlands, I cycle recumbent bikes and I have a model railway.
Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):