Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

starting new isisdm example: using multitextproerty

  • Loading branch information...
commit 406169e74b89d983e2ba4736abf3acc52821e66c 1 parent 227273a
@alvesjnr alvesjnr authored gustavofonseca committed
View
54 examples/bibitex/bibitex.py
@@ -0,0 +1,54 @@
+from pyramid.config import Configurator
+from pyramid.response import Response
+from pyramid.view import view_config
+from pyramid.renderers import render_to_response
+
+from paste.httpserver import serve
+from models import Bibitex
+from forms import BibitexForm
+
+import deform
+import couchdbkit
+
+
+
+def hello_world(request):
+ return Response('Hello world!')
+
+def goodbye_world(request):
+ return Response('Goodbye world!')
+
+
+def new_entry(request):
+ bibitex_form = BibitexForm.get_form()
+ if 'submit' in request.POST:
+ return Response('OK')
+ else:
+ return render_to_response('bibitex:template.pt',
+ {'content': bibitex_form.render()},
+ )
+
+def list_all(request):
+ pass
+
+def view_entry(request):
+ pass
+
+
+if __name__ == '__main__':
+ config = Configurator()
+
+ """Configuring couchdb"""
+ server = couchdbkit.Server()
+ db = server.get_or_create_db('bibitex')
+
+ """Adding static views"""
+ config.add_static_view('deform_static', 'deform:static')
+
+ """Adding views"""
+ config.add_view(list_all)
+ config.add_view(new_entry, name="new_entry")
+ config.add_view(view_entry, name="view_entry")
+
+ app = config.make_wsgi_app()
+ serve(app, host='0.0.0.0')
View
12 examples/bibitex/forms.py
@@ -0,0 +1,12 @@
+from models import Bibitex
+
+import deform
+import colander
+
+class BibitexForm():
+
+ base_schema = Bibitex.get_schema()
+ base_schema['review'].widget = deform.widget.TextAreaWidget(cols=80, rows=15)
+ @classmethod
+ def get_form(cls):
+ return deform.Form(cls.base_schema, buttons=('submit',))
View
17 examples/bibitex/models.py
@@ -0,0 +1,17 @@
+from isis import model
+import deform
+
+choices = ['article', 'book', 'booklet', 'conference', 'inbook', 'incollection', 'inproceedings',
+ 'manual', 'mastersthesis', 'misc', 'phdthesis', 'proceedings', 'techreport', 'unpublished', ]
+
+class Bibitex(model.CouchdbDocument):
+ entry_type = model.TextProperty(choices=[(entry,entry) for entry in choices],)
+ reference_name = model.TextProperty(required=True)
+ title = model.TextProperty(required=True)
+ authors = model.MultiCompositeTextProperty(required=True, subkeys=['name', 'lastname'])
+ publisher = model.TextProperty()
+ year = model.TextProperty()
+ address = model.TextProperty()
+ review = model.TextProperty()
+
+
View
15 examples/bibitex/template.pt
@@ -0,0 +1,15 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <script type="text/javascript" src="/deform_static/scripts/deform.js"></script>
+ <script type="text/javascript">
+ deform.load()
+ </script>
+ </head>
+ <body>
+ <div>
+ <span tal:replace="structure content"></span>
+ </div>
+ </body>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.