Initial user login now trigger logging and indexing

* Previously, `Person` objects were automatically created on login, but
  not fulltext-indexed or logged via `log_eventi`.  Now both are done.
  `session.flush` is used to confer an ID to the new user, such that it
  can issue its own `Event` and `Revision` entries.
* Also, some `import` lines were moved into functions to avoid
  import-order issues.  Probably this should be done better.
Merge pull request #355 from reciprocity/feature/log-user-creation

Initial user login now trigger logging and indexing