示例#1
0
文件: models.py 项目: rjweir/warp
import pytz

from storm.locals import *

from warp.runtime import expose


class Person(Storm):
    __storm_table__ = "person"

    id = Int(primary=True)
    name = Unicode()
    birthdate = DateTime(tzinfo=pytz.UTC)
    note = Unicode()
    rating = Int()
    alive = Bool()

expose(Person)
示例#2
0
文件: people.py 项目: ubolonton/warp
class CrudPerson(CrudModel):

    model = Person

    listColumns = ("id", "name", "birthdate", "rating")
    crudColumns = ("name", "birthdate", "note", "rating", "alive")

    listAttrs = {
        'id': {'width': 50, 'align': 'center'},
        'name': {'width': 200},
        'birthdate': {'width': 150, 'align': 'center'},
        'rating': {'width': 50, 'align': 'center'},
    }

    def render_list_name(self, request):
        return link(
            self.obj.name,
            getNode("people"), 
            "view", [self.obj.id])

    def render_proxy_note(self, request):
        return colproxy.AreaProxy(self.obj, "note")

    def name(self, request):
        return self.obj.name


expose(Person, CrudPerson)

renderer = render.CrudRenderer(Person)
示例#3
0
文件: widgets.py 项目: bhomnick/warp
from warp.runtime import expose

from models import Widget


def linkAsParent(request):
    return link("Widgets", getNode("widgets"), "index")


class CrudWidget(CrudModel):

    listColumns = ("id", "name")

    crudColumns = ("name", "created", "description", "image", "is_available")

    listAttrs = {"id": {"width": 50, "align": "center"}, "name": {"width": 200}}

    def render_list_name(self, request):
        return link(self.name(request), getNode("widgets"), "view", [self.obj.id])

    def name(self, request):
        return self.obj.name

    def parentCrumb(self, request):
        return getNode("widgets")


expose(Widget, CrudWidget)

renderer = render.CrudRenderer(Widget)