MCPcopy Index your code
hub / github.com/clips/pattern / Products

Class Products

test/test_db.py:798–813  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

796 def test_view(self):
797
798 class Products(db.View):
799 def __init__(self, database):
800 db.View.__init__(self, database, "products", schema=[
801 db.pk(),
802 db.field("name", db.STRING),
803 db.field("price", db.FLOAT)
804 ])
805 self.setup()
806 self.table.insert(name="pizza", price=15.0)
807 def render(self, query, **kwargs):
808 q = self.table.search(fields=["name", "price"], filters=[("name", "*%s*" % query)])
809 s = []
810 for row in q.rows():
811 s.append("<tr>%s</tr>" % "".join(
812 ["<td class=\"%s\">%s</td>" % f for f in zip(q.fields, row)]))
813 return "<table>" + "".join(s) + "</table>"
814
815 # Assert View with automatic Table creation.
816 v = Products(self.db)

Callers 1

test_viewMethod · 0.70

Calls

no outgoing calls

Tested by 1

test_viewMethod · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…