Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle mutliple urls.py #114

Open
peterfication opened this issue Nov 2, 2013 · 5 comments
Open

Handle mutliple urls.py #114

peterfication opened this issue Nov 2, 2013 · 5 comments

Comments

@peterfication
Copy link

Hey there,

I'm using django-subdomains and django-sitetree in the same project. Therefore, I have 2 differenet urls.py. Eg. one for www.example.com (here is also admin) and one for subdomain.example.com. On both, I have included a sitetree, but different ones.

If I start the server, everything works fine. But if I change the sitetree in django admin, only the sitetree on the site with admin works fine and the urls are resolved. On the subdomain the sitetree shows up but the urls aren't resolved. If the server reloads, eg. due to changes in the code, the sitetree on the subdomain works again.

I tried to figure out how what happens on a reload, but I couldn't. Could you give me hint, what I can do to fix my problem?

Best wishes

@peterfication
Copy link
Author

Finally, I figured out where the caching problem is. Somehow the cache isn't really cleared.

If I change in sitetree.cache_init

cache_ = cache.get('sitetrees')

to

cache_ = None

it works fine.

Do you have an idea, how to fix this Problem?

@peterfication
Copy link
Author

Ok I was wrong. The caching works fine :)

But I figured out where the caching problem is. After saving in Admin, the sitetree gets initiated, but in the Admin. Therefore, the urls.py of subdomains aren't recognized.

I solved this issue by disabling the caching in the Admin.

@idlesign
Copy link
Owner

idlesign commented Nov 3, 2013

Hi,

Unfortunatelly I have no clue on how does your initial problem relate to the given solution.
The problem, most probably, lays within multiple processes spawned not sharing cache data.
What cache type do you use? https://docs.djangoproject.com/en/dev/topics/cache/

@peterfication
Copy link
Author

I'm using the default cache ('BACKEND': 'django.core.cache.backends.locmem.LocMemCache',)

I think the problem lays somewhere in the Admin. After a server restart, if the first load of the sitetree is in the Admin (which is located under the main site) eg. for editing the sitetree the sitetreeapp looks for the urls.py of the main site to resolve the patterns. But there are none because they are all in the subdomains urls.py which is not loaded. If I then go to the subdomains site, the sitetree is already cached with unresolved urls. If the sitetree doesn't get cached in the Admin, it gets reloaded on the first load of the subdomains with the correct urls.py and therefore the urls are resolved.

My problem was, that I was changing a sitetree item of the subdomains sitetree in the Admin and then I was redirected to the overview of this sitetree in the Admin. After saving, the cache was cleared but because I was redirected to this overview, the sitetree gets cached immediately but with the wrong urls.py.

Therefore I disabled caching in the Admin.

@idlesign
Copy link
Owner

idlesign commented Nov 3, 2013

I see your point. I should take a closer look into django-subdomains before taking a decision on pull request.
Thank you for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants