-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[WIP] New project layout #1265
[WIP] New project layout #1265
Conversation
Awesome Alex. What do you mean by "Django-compatible format", or more specifically, is there anything preventing the local_settings file from continuing to use the ".template" suffix, other than the fact we'd need to extend the command a bit further to rename the file once it's been copied over? Personally (in the literal sense) I'd like to keep the name as is - it's very convenient to be able to treat the project template dir as a local site during development. I keep a "local_settings.py" file in there that never gets checked into source control. Otherwise I and anyone else working on Mezzanine will need an actual separate project to test with - I assume a lot of people contributing do that already, but I've never had to. |
By "Django-compatible", I mean a project template that can be fed directly to Django's startproject (with the right parameters) and generate a correct project without having to run any extra code. But now that I think about it, I think we can actually pass parameters that make startproject rename |
Good find :-) |
Hmm nope, I read it wrong. The only thing that gets replaced in paths is the string "project_name" with the project's actual name. We can replace the file in our management command, but we'll have to duplicate the code that Django uses to ascertain the target directory. That code (and the names of various arguments) differs between 1.7 and 1.8, which is rather annoying. I'll get back to you :) |
Maybe there's another way we can treat the project template as a local site and somehow have it use uncommitted local settings, possibly outside of local_settings.py I'll have a think too. |
OK I think the latest commit should do it. Creates a correct project structure in 1.7 and 1.8. In the deploy directory, is there any reason for the inconsistency in the ".template" naming? All the files are templates, but only the .py files are named as such. Can we either add it to all or drop it entirely? |
Cool! I vaguely recall it would prevent the pep8/pyflakes tests from trying to validate those files, which would fail since they contain placeholder strings in them and therefore aren't valid Python files. But making them all .template files seems fine. |
Ah, that makes sense. Speaking of pyflakes - what do you think about running flake8 and isort over the codebase with the same configuration as Django? The biggest implication there is increasing the max line length to 119. Overall I think we should aim to reduce friction as much as possible for people familiar with Django. Edit: I mean run them as part of test runs on Travis. |
Definitely - the code currently supporting pep8/pyflakes is really bad and I was looking forward to throwing it out in favour of flake8, you can see I started some of the configuration in https://github.com/stephenmcd/mezzanine/blob/master/setup.cfg Just never got around to finishing it. |
Excellent :) On Mon, Apr 13, 2015 at 1:27 PM, Stephen McDonald [email protected]
|
will be merged in new release? |
Possibly, can't say for certain - if not, certainly the next release after that. |
c8ee25e
to
0c60e99
Compare
Ok, fabric is working, I think. Needs a bit more testing but I wanted to get these changes up. |
Phew, OK. I think we just need an audit of the default |
Seems nice. You may want to change settings.SITE_ID and settings.BASE_DIR according to https://github.com/django/django/blob/1.7.1/django/core/checks/compatibility/django_1_6_0.py in order to be closer to pure django projects. |
Yes, we should go through the settings file with the goal of making it minimally different from Django's default settings. Fabric support in this branch is solid now. |
Can we squash these into a single commit? |
I've tested this against fabric with a new VM and all works fine. Had a couple minor issues - I can commit fixes once this is merged, or Alex you could include it in the squashed commit, neither here nor there. Fixes a unicode error I get with
Error is the same as https://code.djangoproject.com/ticket/18091 - I guess we regressed it somehow by overriding that method, but the above fixes it. I also found it difficult to develop Mezzanine from within itself (eg using "project_template/project_name" dir as the actual project), with So I think we could live without fixing that if there wasn't an easy fix, but I think it would be easy enough to just create a function (say in
Then in manage.py etc, we just do |
Ah yeah. I ran into that bug as well, but I fixed it in my local Django and proceeded to forget about it. I think it's a legitimate separate bug in Django, triggered by unicode file names rather than content as in that Trac ticket. Your fix looks fine to me. When I have some more time I'll submit a patch to Django as well. Second problem: approach sounds fine, but I think the utility function should just return a string, rather than actually setting the env var, and then we simply use that wherever we would have used |
Nice - let's do that |
OK I've added that function and used it everywhere I think it's necessary, and committed that unicode fix. Sorry for the noise, I'm editing from the web. @stephenmcd if you can test those things again I'll squash when I'm back on my dev machine. |
Looks good - unicode fix is better than my one :-) |
I've added That should be enough to merge, but I think the settings file could still use a bit more attention. |
Glad this is merged. I was gonna squash this and #1326 before merging – too late now they're in master? |
Yeah I totally forgot about squashing, but this really forces us to start
|
Alex, what's the replacement for the -a option in mezzanine-project? (e.g. before we would do mezzanine-project -a cartridge, how is that done now? Does cartridge still need to be updated to the new format and its doc changed?) |
Yep. |
First attempt at this here. Haven't gone over settings or fabfile in detail yet, so I'm sure some things won't work. I also want to update settings to their current defaults in Django, where relevant.
In order to put the project_template in a Django-compatible format, I've renamed
local_settings.py.template
to justlocal_settings.py
in the project app directory (deploy/local_settings.py.template
remains).This means that
.template
files are exclusively for the use of the fabfile, which I think is nice. But it changes how tests work, so you'll have to have a look over that and see what you think.