Utils

Utilities and helpers for django-projector.

Return to API Reference.

Basic

projector.utils.abspath

Returns absolute path for given *paths.

projector.utils.str2obj

projector.utils.str2obj(text)

Returns object pointed by the string. In example:

>>> from projector.models import Project
>>> point = 'projector.models.Project'
>>> obj = str2obj(point)
>>> obj is Project
True

projector.utils.using_projector_profile

projector.utils.using_projector_profile()

Returns True if AUTH_PROFILE_MODULE is set to projector.UserProfile and False otherwise.

Email

projector.utils.email.extract_emails(text)

Returns list of emails founded in a given text.

Helpers

projector.utils.helpers.get_homedir

projector.utils.helpers.get_homedir(project)

Returns unique home directory path for each project. Returned path should be relative to PROJECTOR_PROJECTS_ROOT_DIR.

Parameters:

Note

This is simplest possible implementation but on the other hand returned value depends solely on the primary key of the given project. It is important not to use other fields as they may change. Primary key should never be changed while even creation date (created_at field) may be edited.

For tests however, this is not acceptable as test runner rollbacks queries which should normally be committed. Rollbacks make ID value not stable - as we run more and more tests we always got projects with same id (starting with 1 for each test). That said, test runner must use other project homedir generator.

Implementation:

return str(project.pk)

Table Of Contents

Previous topic

Models

Next topic

Signals

This Page