-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.txt
59 lines (37 loc) · 1.34 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
rebecca.form
====================
`pyramid <http://pypi.python.org/pyramid>`_ view components based on `FormAlchemy <http://pypi.python.org/Formalchemy>`_ .
Components
-------------------
- FormView
- AddFormView
- EditFormView
- DisplayView
Examples
--------------------
Model for Example ::
class Item(Base):
__tablename__ = 'items'
id = sa.Column(sa.Integer, primary_key=True)
name = sa.Column(sa.Unicode(255), nullable=False)
value = sa.Column(sa.Integer, nullable=False)
def __unicode__(self):
return u"Item id={id}, name={name}, value={value}".format(id=self.id, name=self.name, value=self.value)
AddFormView ::
class AddItemView(AddFormView):
__x_model__ = Item
__x_session__ = DBSession
EditFormView ::
class EditItemView(EditFormView):
__x_factory__ = item_finder
DisplayView ::
class DisplayItemView(DisplayView):
__x_factory__ = item_finder
`__x_factory__` is callable to find model from request.
Utilities
----------------------
`MatchDictFinder` queries for specified Model with conditions from `Request.matchdict`.
For example, create finder for ::
item_finder = MatchDictFinder(Item, DBSession, [(Item.id, 'item_id')])
item_finder executes like this ::
DBSession.query(Item).filter(Item.id==request.matchdict['item_id']).one()