Development

Tools

restlib uses what is becoming a pretty standard and a quite simple toolset.

Required Tools

  1. python - The python programming language
  2. distutils - Python building and packaging library
  3. git - Source code management
  4. an editor or ide that doesn’t suck

Optional Tools

  1. rpm-build - Should be packaged in your RPM distribution

Source

You can clone the repo over http via git through the following command::

$ git clone git://gitorious.org/restlib/mainline.git

Style

PEP 0008 is used as the base for the style in this project. Above and beyond the standard style guide the following is required:

  1. file names housing python code are always lowercase
  2. classes are always CamelCase or, if it is an acronym, all UPPERCASE
  3. Every file containing code has the standard copyright information at the top
  4. Every file containing code has docstrings at the top, class, and method/function levels
  5. Classes and functions have two empty newlines in between them
  6. methods have one empty newline between them
  7. Place imports in the scope they belong in
  8. Try to avoid * imports
  9. variables at the global scope must be in ALLCAPS

Git

Excludes

I recommend the following in your .git/info/exclude:

*.pyc
*.pyo
*.pidaproject
MANIFEST
apidocs
dist
*.swp

Branching

The best way to develop on restlib is to branch feature sets. For instance, if you were to add xml deserialization you would want to branch locally and work on that branch.:

$  git branch
* master
$ git status
# On branch master
nothing to commit (working directory clean)
$ git branch xmldeserialization
$ git checkout xmldeserialization

Now we pretend you are all finished and have done at least one commit to the xmldeserialization branch.:

$ git-format-patch master
0001-created-initial-classes.patch
0002-added-in-documentation.patch
$

You now have patch sets which you can send in for perusal and acceptance. You can submit them via email. If you are interested in working directly on the project then submitting a few patches is the place to start. If, for some reason, you are unable to attach patches to the ticket system you can email the patches to

the user steve at the domain restlib dot(.) org.

Running Unit Tests

The tests for restlib require twisted packages to be installed. If you are missing a package it will let you know like so::

$ ./setup.py test
running test
cannot import name server

You seem to be missing one ore more required dependencies.
Please install twisted.web.server, twisted.web.resource and
twisted.internet.reactor.

Please note that these dependencies are only needed in testing.
$

Running the test suite is as simple as running setup.py test. The results look like::

$ ./setup.py test
running test
test_logger_level (tests.test_logger.TestGetRestlibLogger) ... ok
test_logger_name (tests.test_logger.TestGetRestlibLogger) ... ok
test_rest__do_allowed_types (tests.test_rest.TestREST) ... 2008-06-11 22:40:13,728 ERROR    REST: BREAK was not in the list of valid type.
ok
test_rest_http_delete (tests.test_rest.TestREST) ... ok
test_rest_http_delete_with_params (tests.test_rest.TestREST) ... ok
test_rest_http_get (tests.test_rest.TestREST) ... ok
test_rest_http_get_with_params (tests.test_rest.TestREST) ... ok
test_rest_http_post (tests.test_rest.TestREST) ... ok
test_rest_http_post_with_params (tests.test_rest.TestREST) ... ok
test_rest_http_put (tests.test_rest.TestREST) ... ok
test_rest_http_put_with_params (tests.test_rest.TestREST) ... ok
test_rest_init (tests.test_rest.TestREST) ... ok
----------------------------------------------------------------------
Ran 12 tests in 0.049s

OK
$

Table Of Contents

Previous topic

Examples

Next topic

Code

This Page

Quick search