1. Chris Moffitt
  2. satchmo
Issue #522 open

problem with configuration

Anonymous created an issue

Ive stumbled on a problem, can't save configuration and configuration is not read from the database.BR After some time, it looks like django's reporting that it's internal cache is not ready (line: loading.app_cache_ready() in satchmo/configuration.models.py:find_setting).BR Theoretically fixing this simple "if" will resolve this issue.BR I've started digging what is root cause of such a behavior.

There is an internal flag in django "nesting_level", you can get it:

{{{ from django.db.models import loading

print loading.cache.nesting_level }}}

if it is > 0, there are circular referrences between modules. Attached patch is moving dependencies between modules, so nesting_level =0.

Reported by jerzyk

Comments (4)

  1. Anonymous

    patch removes (I suppose) most of the circular referencies, so movig e.g. OrderPayment to payment module, removes circular dependency between sachmo.shop.modules and satchmo.payment.modules. Core changes are pretty small, but moving classes, requres to change imports everywhere where referenced.

    ragarding nesting_level, it is being built when django is loading all applications and their modules. it affects directly loading.app_cache_ready(), which is used in satchmos's cache.

    As I said before, the quick and dirty is to change cache, but those circular referencies are bad, so I took some time in hope to resolve them.

  2. Anonymous

    additionaly, order of applications in INSTALLED_APS is important:

        'satchmo.caching',
        'satchmo.configuration',
        'satchmo.l10n',
        'satchmo.thumbnail',
        'satchmo.tax',
        'satchmo.contact',
        'satchmo.product',
        'satchmo.shipping',
        'satchmo.shop',
        'satchmo.payment',    
        'satchmo.giftcertificate',
        'satchmo.discount',
        'satchmo.supplier',
    
  3. Chris Moffitt repo owner

    I've never heard of this nesting function before. How exactly do you use it? This looks like a good idea but the patch seems pretty broad. I want to understand it a little bit more before I apply it.

    Having circular imports is obviously bad, I just want to make sure this is well understood.

  4. Hynek Cernoch
    • changed status to open
    • marked as proposal
    • changed version to 0.9
    • changed milestone to dev

    These are rather chain dependencies or tree dependencies not exactly circular dependencies. A circular dependency can easy arise by adding some import, but this does not depend on the apps order. The stability, clarity and readability of code is also an important aspect in contrast with that.

    (I know nesting level internals.)

  5. Log in to comment