• Archive
  • RSS
  • Ask me anything

Fauzism

May The Fauz Be With You - Kunal

Shiv - A wrapper over Django

I joined LazyZach as the first hire back in 2009. I was already in love with Python by then and when it came to deciding which technology to use, the answer was quite obviously, Django.

While Django does speed up development, I wanted something a bit more streamlined to my thought process. Having my “views” all over the place was definitely not the way I wanted to go. Plus, there was a need for a more clear separation of back end and front end tasks (I was, and still am, a bit weary of all the html and css stuff that goes around). All this and some more made me develop Shiv, a thin wrapper over Django.

For all those Django noobs out there, one thing I wish to say is that “Django is Python”. Realize this, and life will be so much simpler for you. And yes, do not go about learning Django, learn Python and you will know Django inside out.

In this post, I will discuss the basic idea behind Shiv. Other key features and benefits like AJAX handling, Widgets, auto JS/CSS minimization, will be discussed in later posts.

Coming from a non-web dev background, the way I saw a web site was that it has a bunch of pages. Each page contains a bunch of boxes. Each box in-turn will consist of other boxes.

Its sort of container containing container model with each container having an associated view.

The idea of Shiv is to take this abstract container, and add specific behavior to it.

While the higher level containers will mostly have other lower level containers, a low level container will have some specific data.

Based on the needs of LazyZach, I came up with the following containers:

1. Page

This is the parent level item. A URL will call the show() method of this container. It consists of a bunch of boxes and template to show them, along with other media requirements. While rendering, it calls the show method of each box.

2. Box

There are 3 kinds of boxes.

  • Vanilla Box - Consists of many types of Tab Boxes
  • Tab Box - Consists of a single type of Element. Its basically a list of that type of Element
  • Widget Box - Same as Vanilla Box except that instead of a Page including it as a property, it itself defines the Pages it wants to be a part of

3. Element

This is the lowest level container. Most of the action happens here. An Element’s direct parent box will have only one type of Element in it.

Each container listed above has a corresponding Media class. A media class will define the template that the container needs plus any other JS/CSS/Images that it may require. All Media classes are defined separately. So if you have separate people writing your back end and front end code, the front end guy will be responsible for handling the Media file.

I will show some sample code for creating the various containers and some more internals of Shiv in the next installment. The project will be open sourced as soon as I am able to remove some of the coupling that it has with LazyZach’s codebase.

After LazyZach, I used Shiv for my side project too (CinEight, I have not worked on it for quite a while now). 

Note: I am not too good at writing posts, so if this post is confusing or if you have any questions, feel free to leave a comment below or contact me. My HN ID is yousuffauzan.

Part 2 | Part 3

    • #Django
    • #Shiv
  • 8 months ago
  • 1
  • Comments
  • Permalink
  • Share
    Tweet

1 Notes/ Hide

  1. fauzism posted this

Recent comments

Blog comments powered by Disqus
← Next • Previous →

About

Avatar This and That. Mostly that.
  • Resume

Twitter

loading tweets…

  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr