[Checkins] SVN: grok/branches/luciano-tutorial/doc/groktut/crud/ firt version of CRUD in Pebbles

Luciano Ramalho luciano at ramalho.org
Fri Jul 13 15:46:14 EDT 2007


Log message for revision 77881:
  firt version of CRUD in Pebbles
  

Changed:
  A   grok/branches/luciano-tutorial/doc/groktut/crud/
  U   grok/branches/luciano-tutorial/doc/groktut/crud/setup.py
  A   grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/
  D   grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app.py
  A   grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app.py
  D   grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app_templates/giftindex.pt
  D   grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app_templates/index.pt
  A   grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app_templates/index.pt
  A   grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app_templates/mammothdetails.pt
  D   grok/branches/luciano-tutorial/doc/groktut/crud/src/sample/

-=-
Copied: grok/branches/luciano-tutorial/doc/groktut/crud (from rev 77786, grok/branches/luciano-tutorial/doc/groktut/containers)

Modified: grok/branches/luciano-tutorial/doc/groktut/crud/setup.py
===================================================================
--- grok/branches/luciano-tutorial/doc/groktut/containers/setup.py	2007-07-12 19:41:41 UTC (rev 77786)
+++ grok/branches/luciano-tutorial/doc/groktut/crud/setup.py	2007-07-13 19:46:14 UTC (rev 77881)
@@ -2,7 +2,7 @@
 
 version = 0.0
 
-setup(name='Sample',
+setup(name='Pebbles',
       version=version,
       description="",
       long_description="""\

Copied: grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles (from rev 77789, grok/branches/luciano-tutorial/doc/groktut/containers/src/pebbles)

Deleted: grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app.py
===================================================================
--- grok/branches/luciano-tutorial/doc/groktut/containers/src/pebbles/app.py	2007-07-13 01:53:36 UTC (rev 77789)
+++ grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app.py	2007-07-13 19:46:14 UTC (rev 77881)
@@ -1,26 +0,0 @@
-import grok
-
-class Pebbles(grok.Application, grok.Container):
-
-    def receive(self, source, quantity):
-        self[source] = Entry(source, quantity)
-    
-        
-class Index(grok.View):
-    grok.context(Pebbles)
-
-    def update(self, source=None, quantity=0):
-        if description is None:
-            return
-        self.context.receive(source, quantity)
-        self.redirect(self.url('index'))
-
-
-class Gift(grok.Model):
-    def __init__(self, source, quantity):
-        self.source = source
-        self.quantity = quantity
-
-class GiftIndex(grok.View):
-    grok.context(Gift)
-    grok.name('index')

Copied: grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app.py (from rev 77880, grok/branches/luciano-tutorial/doc/groktut/containers/src/pebbles/app.py)
===================================================================
--- grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app.py	                        (rev 0)
+++ grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app.py	2007-07-13 19:46:14 UTC (rev 77881)
@@ -0,0 +1,45 @@
+import grok
+from zope import interface, schema
+
+class Pebbles(grok.Application, grok.Container):
+
+    def addMammoth(self, name, weight):
+        self[name] = Mammoth(name, weight)
+
+    def eatMammoth(self, name):
+        del self[name]    
+        
+class Index(grok.View):
+    grok.context(Pebbles)
+
+    def update(self, name=None, weight=0):
+        if name is None:
+            return
+        self.context.addMammoth(name, weight)
+        self.redirect(self.url('index'))
+        
+class Eat(grok.View):
+    grok.context(Pebbles)
+    def render(self, names):
+        for name in names:
+            self.context.eatMammoth(name)
+        self.redirect(self.url('index'))
+
+class IMammoth(interface.Interface):
+    name = schema.TextLine(title=u"Name", required=True)
+    weight = schema.Int(title=u'Weight', min=0)
+
+class Mammoth(grok.Model):
+    #implements(IMammoth)
+    def __init__(self, name, weight):
+        self.name = name
+        self.weight = weight
+
+class MammothDetails(grok.View):
+    grok.context(Mammoth)
+    grok.name('index')
+    
+class Edit(grok.EditForm):
+    grok.context(Mammoth)
+    pass
+

Deleted: grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app_templates/giftindex.pt
===================================================================
--- grok/branches/luciano-tutorial/doc/groktut/containers/src/pebbles/app_templates/giftindex.pt	2007-07-13 01:53:36 UTC (rev 77789)
+++ grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app_templates/giftindex.pt	2007-07-13 19:46:14 UTC (rev 77881)
@@ -1,8 +0,0 @@
-<html>
-<head>
-</head>
-<body>
-  <h2>Gift from <span tal:replace="python:context.__name__"></span></h2>
-  <p><span tal:replace="context/quantity">999</span> stones.</p>
-</body>
-</html>

Deleted: grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app_templates/index.pt
===================================================================
--- grok/branches/luciano-tutorial/doc/groktut/containers/src/pebbles/app_templates/index.pt	2007-07-13 01:53:36 UTC (rev 77789)
+++ grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app_templates/index.pt	2007-07-13 19:46:14 UTC (rev 77881)
@@ -1,21 +0,0 @@
-<html>
-<head>
-</head>
-<body>
-  <h2>Existing gifts</h2>
-  <ul>
-    <li tal:repeat="key context/keys">
-      <a tal:attributes="href python:view.url(key)" 
-         tal:content="key"></a>
-    </li>
-  </ul>
- 
-  <h2>Receive a gift</h2>
-  <form tal:attributes="action view/url" method="POST">
-    Name: <input type="text" name="source" value="" /><br />
-    Text: <input type="text" name="quantity" value="" /><br />
-    <input type="submit" value="Add gift" />
-  </form>
-
-</body>
-</html>

Copied: grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app_templates/index.pt (from rev 77880, grok/branches/luciano-tutorial/doc/groktut/containers/src/pebbles/app_templates/index.pt)
===================================================================
--- grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app_templates/index.pt	                        (rev 0)
+++ grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app_templates/index.pt	2007-07-13 19:46:14 UTC (rev 77881)
@@ -0,0 +1,25 @@
+<html>
+<head>
+</head>
+<body>
+  <h2>Mammoths</h2>
+  
+  <form tal:attributes="action python:view.url('eat')" method="POST">
+  <ul>
+    <li tal:repeat="key context/keys">
+       <input type="checkbox" name="names:list" tal:attributes="value key">
+       <a tal:attributes="href python:view.url(key)" 
+         tal:content="key"></a>
+    </li>
+  </ul>
+  <input type="submit" value="Eat">
+  </form>
+  <h2>New mammoth</h2>
+  <form tal:attributes="action view/url" method="POST">
+    Name: <input type="text" name="name" value="" /><br />
+    Weight: <input type="text" name="weight" value="" /><br />
+    <input type="submit" value="Add mammoth" />
+  </form>
+
+</body>
+</html>

Copied: grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app_templates/mammothdetails.pt (from rev 77880, grok/branches/luciano-tutorial/doc/groktut/containers/src/pebbles/app_templates/mammothdetails.pt)
===================================================================
--- grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app_templates/mammothdetails.pt	                        (rev 0)
+++ grok/branches/luciano-tutorial/doc/groktut/crud/src/pebbles/app_templates/mammothdetails.pt	2007-07-13 19:46:14 UTC (rev 77881)
@@ -0,0 +1,8 @@
+<html>
+<head>
+</head>
+<body>
+  <h2>Mammoth "<span tal:replace="python:context.name"></span>"</h2>
+  <p>Weight: <span tal:replace="context/weight">999</span> stones.</p>
+</body>
+</html>



More information about the Checkins mailing list