Skip to content

Instantly share code, notes, and snippets.

@buriy
Created July 5, 2009 11:30
Show Gist options
  • Save buriy/140945 to your computer and use it in GitHub Desktop.
Save buriy/140945 to your computer and use it in GitHub Desktop.
class BlogApp(Controller):
urls = { # will be deduced automatically
/ -> show list of users and blogs
/create/blog/ -> add a blog
/create/user/ -> add an user
/blog/:name/ -> connects to a blog page
/user/:name/ -> connects to an user page
}
ancestors = [ # these two controllers are subobjects
UserController,
BlogController,
]
class UserController(Controller):
urls = {
/ -> show blog info and list of blog entries
/edit/ -> edit current user
}
model = Author
lists = [ # what lists are referenced
BlogController,
]
class BlogController(Controller):
urls = {
/ -> show blog info and list of blog entries
/edit/ -> edit current entry
/create/entry/ -> add an entry to a blog
/entry/:name/ -> connects to an entry page
}
model = Blog # will contain blog options
ancestors = [
EntryController,
]
elements = [ # also just an idea of what can happen
sidebar,
last comments,
last entries,
categories,
months,
friends,
menu
]
list_filters = [
author,
name
]
class EntryController(DateController):
model = Entry # will create add form, view form and edit form for you.
add_form = EntryForm # we'll customize it a bit
edit_form = EntryForm
urls = {
/ -> show blog info and list of blog entries
/edit/ -> edit current entry
/create/comment/ -> add a comment to an entry
}
ancestors = [
Comment
]
elements = [
best_comments,
]
list_filters = [
authors,
categories,
date,
drafts,
]
filters = [
authors,
]
class CommentsController(ItemController):
add_form = AddForm
urlpatterns = patterns('',
('/', BlogApp.urls)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment