def create_object(self, data): name = site.decode_value(data['name']) new_obj = site.create_user('student', name) site.students.append(new_obj) new_obj.mark_as_new() UnitOfWork.get_current().commit()
from datetime import date from lo_framework.lo_templator import render from patterns.behavioral import BaseSerializer, CreateView, EMAILNotifier, SMSNotifier, ListView from patterns.creational import Engine, Logger, MapperRegistry from patterns.structural import RouteDecorator, DebugDecorator from patterns.unit_of_work import UnitOfWork site = Engine() logger = Logger('main') email_notifier = EMAILNotifier() sms_notifier = SMSNotifier() UnitOfWork.new_current() UnitOfWork.get_current().set_mapper_registry(MapperRegistry) routes = {} @RouteDecorator(routes=routes, url='/') class Index: @DebugDecorator(name='Index') def __call__(self, request): return '200 OK', render('index.html', object_list=site.categories) # return '200 OK', render('index.html', data=request.get('data', None)) @RouteDecorator(routes=routes, url='/about/') class About: @DebugDecorator(name='About') def __call__(self, request): return '200 OK', render('about.html', data=request.get('data', None))