Getting started


LangDev source code is available at the GitHub repository. Checkout this:

$ hg clone langdev
$ cd langdev/

It depends on several Python library packages. You can resolve all of dependencies at once like:

langdev$ python develop

It also adds your working directory into Python site-packages as develepment mode.

See also

Installing Python Modules
This document describes the Python Distribution Utilities (“Distutils”) from the end-user’s point-of-view, describing how to extend the capabilities of a standard Python installation by building and installing third-party Python modules and extensions.

“Development Mode”

Distribute (setuptools)’s development mode.


It probably is that virtualenv could be useful for your development. It isolates Python site-package environments from global site-packages.

$ virtualenv --distribute langdev-env
$ cd langdev-env
langdev-env$ source bin/activate

Packages that installed in the virtualenv don’t belong to global site-packages. Instead, they are in langdev-env/site-packages/ (in the above example).

See also

A tool to create isolated Python environments.

Configuration file

If you checkout the source code, there might be program. It helps you to make a configuration, initialize a database, or run a web server.

LangDev supports multiple instances, and instances’ metadata that are stored in the configuration file. From here, we assume that our configuration filename is instance.cfg. (Of course, there’s no such file currently.) You can name it freely like dev.cfg or prod.cfg.

You can pass a filename that doesn’t exist into --config option, and the script will confirm would you want to create a such configuration file.

$ shell --config instance.cfg
instance.cfg doesn't exist yet; would you create it? [y]

There’s some fields to be set like database URL:


The database to be used. By default it uses SQLite with a database file (db.sqlite) located in the current directory.

Database URL [sqlite:////home/dahlia/Desktop/langdev-env/db.sqlite]:

See also

SQLAlchemy — Database Urls

Secret key for secure session (SECRET_KEY)

The HMAC secret key. The default key is randomly generated, so skip this if you don’t know about HMAC or secure session.

Secret key for secure cookies [ab03199d87db101aa07fd18e3dc2599a]:

See also

Flask — Sessions
Flask provdes client-side secure sessions.
Class flask.session
The session object works pretty much like an ordinary dict, with the difference that it keeps track on modifications.
RFC 2104 — HMAC: Keyed-Hashing for Message Authentication
This document describes HMAC, a mechanism for message authentication using cryptographic hash functions. HMAC can be used with any iterative cryptographic hash function, e.g., MD5, SHA-1, in combination with a secret shared key. The cryptographic strength of HMAC depends on the properties of the underlying hash function.

See also

Flask — Configuration Handling

Database initialization

What you have to do next is creating tables into your relational database. There are to recommended relational databases:

SQLite 3+
SQLite is a small and powerful file-based relational database. It is recommended for development-purpose.
PostgreSQL 8.3+
PostgreSQL is a powerful object-relational database system. We recommend it for production-use.

You make a decision, and then, initialize the database via initdb command:

$ initdb --config instance.cfg

No news is good news. It doesn’t print anything unless errors happen.


If you would use SQLite, the data file will be automatically created. But if you would use PostgreSQL, the database to be used have to be created first. Create a database via the createdb command PostgreSQL provides:

$ createdb -U postgres -E utf8 -T postgres langdev_db

Web server

We finished configuring an instance. Now we can run the development web server from command line:

$ runserver --config instance.cfg

How to serve on WSGI servers


It explains advanced details. If you don’t know about WSGI, skip this section and follow Web server section.

LangDev web application is WSGI-compliant, so it can be served on WSGI servers. For example, in order to serve it on Meinheld server, make a script:

import langdev.web
import meinheld.server

app = langdev.web.create_app(config_filename='instance.cfg')
meinheld.server.listen(('', 8080))

Let’s cut to the chase. langdev.web.create_app() makes a WSGI application and returns it. It takes a config_filename optionally (and it have to be passed by keyword, not positional). And then, pass the created WSGI application into your favorite WSGI server.

Project Versions

Table Of Contents

Previous topic


Next topic


This Page