Ticket #61 (closed difetto: sistemata)

Opened 4 years ago

Last modified 4 years ago

Avoid init code in __init__.py and in general at "module level"

Reported by: fero Owned by:
Priority: bloccante Milestone: ACQUISTIAMO - L'utente può ordinare
Component: sviluppo Keywords:
Cc:

Description

That's why we have to avoid code in init.py

Code is executed at import-time.

The following error arises when you perform a syncdb with a clean db. It tries to register roles from auth/init.py but tables are not created yet

  File "/home/fero/src/gasistafelice/gasistafelice/../gasistafelice/supplier/models.py", line 18, in <module>
    from gasistafelice.auth import SUPPLIER_REFERRER
  File "/home/fero/src/gasistafelice/gasistafelice/../gasistafelice/auth/__init__.py", line 63, in <module>
    roles_dict[name] = register_role(name)
  File "/home/fero/.virtualenvs/desmacerata/lib/python2.6/site-packages/permissions/utils.py", line 503, in register_role
    role = Role.objects.create(name=name)

Change History

comment:1 Changed 4 years ago by fero

  • Status changed from new to closed
  • Resolution set to sistemata
  • Summary changed from Avoid code in __init__.py to Avoid init code in __init__.py and in general at "module level"

Fixed for auth application and for base/workflows.py

note: I had to rename workflows.py to fix "import workflows" statement

Note: See TracTickets for help on using tickets.