amitu / importd

django based mini framework inspired from sinatra. fully compatible with django.
http://amitu.com/importd/
BSD 3-Clause "New" or "Revised" License
510 stars 30 forks source link

Add something like flask blueprint #44

Closed if1live closed 10 years ago

if1live commented 10 years ago

This pull request is #37.

I make something like flask blueprint. concept: Lazy adding view.

  1. use blueprint object instead of d inside view.
  2. register blueprint to d appliction
  3. create urlpatterns object from blueprint
  4. register urlpatterns with namespace at do(), or wsgi.
amitu commented 10 years ago

I find this very interesting. Let me play with it a bit. Never used flask-blueprint before.

santagada commented 10 years ago

I think that it would be more interesting to integrate better django apps with importd, not having its own method of extension.

amitu commented 10 years ago

I sort of agree with @santagada. I would prefer importd projects to be as close, conceptually, to vanilla django projects as possible.

if1live commented 10 years ago

I want to use namespace that feature of django. But, current importd doesn't support it. It is hard to manage many url with importd. So, I suggest blueprint.

Question 1. Do you agree concept of blueprint?

Question 2. If below code is possible, is it acceptable?

d(
...
mounts={
    "app2": "/app2/",
    "app3": {
        'url_prefix': 'app3/',
        'blueprint': 'app3.views.bp',
    }
}
)
amitu commented 10 years ago

Hmm.

importd indeed places a limitation which is not there in vanilla django projects: https://github.com/amitu/importd/issues/37#issuecomment-59171155.

I think I like blueprint too. I am confused.

Can you, please, merge master into it and I will merge it.

Also, if possible, please add some docs in README, ChangeLog and in docs :-). A tutorial would be most helpful as many people in django would not know about blueprint, and we can not really refer them to flask/blueprint docs as that could be confusing/incompatible.

amitu commented 10 years ago

Hey @if1live,

Please merge my master into this branch. I can not auto merge it, and tho I can manually fix it, I would much rather have the change come from you as you did the hard work and I want git to reflect that.

if1live commented 10 years ago

Could you wait 4-5 day? I'm on midterm-exam.

amitu commented 10 years ago

Sure, no problems. Best of luck for exams :-)

if1live commented 10 years ago

Writing document with english is hard to me. And writing document will consume long time.

  1. I will write document to wiki.
  2. Please verify my document.
  3. Include document to repository.

If you suggest some good interface to integrate blueprint into importd, I will apply it.

amitu commented 10 years ago

Thanks a lot for fixing the pull request.

Regarding 1: I would prefer if you updated docs folder instead of wiki, so everything can remain in git.

amitu commented 10 years ago

There is one problem with this approach. In django one can typically use the same app more than once on different URLs.

Can "blueprint" apps too be used more than once?

Though its a thin useless I still want to be sure.