fix file writing: check_conflict call didn't close file handle

the check_conflict call has to do different things when it
checks a folder or file.

A typical python error came in checking:
    if not file_handle
for finding out that something is a directory
(opening it as a file failed), instead of checking:
    if file_handle is not None

Incidentally, a working file_handle evaluates False ...
remove unnecessary flask.g import from irodsstorage
fix connection release if api function raises exception

the connections were not released correctly when
the function raised an exception. fix this by interception
each raise in the get_connection decorator, release the
connection, and re-raise the exception.
add more elaborate connection checking

check for more atributes of the irods connection that
can indicate an error. since I couldn't find any documentation,
the bhaviour I am checking for is guessed.
already destroy bad connections on release()
fix logic error in connection checking
add a test to test invalid byte range headers
add checks to the byte range header processing

Add two levels of checks:
1. validate the format of the whole byte range header value
    with a regular expression
2. Only set the storage.START and END constant if the
    value of a range field is ''
fix byte range behaviour; support correct -500

Support the missing start and numerical end value that means
getting n byte from the end of the file.

Rewrite the range parsing function in the cdmi.py and introduce
and new constant BACKWARDS to signal this case.

Rewrite the functions in storage that parse the constants and
convert them into offsets and move them to storage_common.py.
add debug messages for irods connection handling
adjust test for correct byte range interpretation
refactor the test structure

integration tests can now inherit from the TestApi class,
which provides the app instantiation and a open_with_auth function.
expect a 403 error instead of a 401 on wrong credentials
add integration tests for the CDMI api

for now there are only tests for GETting a file or container
and the cdmi json structures are now checked for formal correctness.

this is still enough for the tests to fail.
use the abort() call in auth to allow use of errorhandlers
fix/refactor requests functions

- make cdmi match both -object and -container
- add convenience request_wants_cdmi function
- fix line lengths
many fixes to cdmi output

- add output buffering (experimental)
- add cdmi version recognition support
- change to adjust to changed request_wants functions
- add get_config_parameter function to get CDMI params
- add function to immediately reject a non-conform cdmi request
- immediately disallow cdmi requests with multi range
- fix valuerange parameter for range request
- return 403 (not 401) if credentials are wrong
- return correct cdmi version and content_type on GET functions
- fix line lengths
- use json.dumps() to prepare values for json output wherever possible
- add missing cdmi values
- add 403 error handler
fix ?parentURI and objectName in cdmi output
add deferred evaluation to listings on localstorage

replace the map(), which puts the listing in the correct
format, with a itertools.imap call.
This especially helps cdmi requests, because the listing
is never created when it is not requested by the client.

Conflicts:
	eudat_http_api/http_storage/localstorage.py
conditionally only load parts of the app

New configuration parameters decide whether:
the registration component should be loaded,
the storage should be provide read functions,
or the storage should provide write and delete functions.

This enables the app to be deployed distributed, with
each machine having different responsibilites.

The split of the storage interface into read and write
makes is easy to expose a storage read-only by not allowing
any requests that can make modifications.

Conflicts:
	eudat_http_api/__init__.py