This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
345 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -5,3 +5,8 @@ dist/ | ||
*.egg-info/ | *.egg-info/ | ||
.idea | .idea | ||
.idea/* | .idea/* | ||
bin/ | |||
build/ | |||
examples/ | |||
include/ | |||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,6 +1,12 @@ | |||
0.2.0 | |||
* Added CompositeTextProperty | |||
* Added MultiCompositeTextProperty | |||
* Added IsisCompositeTextProperty | |||
* Added MultiIsisCompositeTextProperty | |||
|
|||
0.1.1 | 0.1.1 | ||
--- | --- | ||
* Added FileProperty datatype | * Added FileProperty datatype | ||
* Added BooleanProperty datatype | * Added BooleanProperty datatype | ||
* Embedded _rev and _id in automatic generated forms (couchdb api) | * Embedded _rev and _id in automatic generated forms (couchdb api) | ||
* Fixed bug that changes the _id attr of a persistent document | * Fixed bug that changes the _id attr of a persistent document |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,66 @@ | |||
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 new(request): | |||
bibitex_form = BibitexForm.get_form() | |||
|
|||
if 'submit' in request.POST: | |||
controls = request.POST.items() | |||
try: | |||
appstruct = bibitex_form.validate(controls) | |||
except deform.ValidationFailure, e: | |||
return render_to_response('bibitex:form.pt', | |||
{'content': e.render()}) | |||
|
|||
bibitex = Bibitex.from_python(appstruct) | |||
bibitex.save(db) | |||
|
|||
return Response('Saved under id: %s' % bibitex._id) | |||
else: | |||
|
|||
if 'id' in request.matchdict: #edit | |||
bibitex = Bibitex.get(db, request.matchdict['id']) | |||
|
|||
return render_to_response('bibitex:form.pt', | |||
{'content': bibitex_form.render(bibitex.to_python())}) | |||
|
|||
return render_to_response('bibitex:form.pt', | |||
{'content': bibitex_form.render()}) | |||
|
|||
|
|||
def index(request): | |||
records = db.view('_all_docs', include_docs=True) | |||
|
|||
return render_to_response('bibitex:index.pt', | |||
{'records':records}) | |||
|
|||
|
|||
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') | |||
|
|||
"""Registering views and routes""" | |||
config.add_view(view=index, route_name='index') | |||
config.add_view(view=new, route_name='new') | |||
config.add_view(view=new, route_name='edit') | |||
config.add_route('index', '/') | |||
config.add_route('new', '/new') | |||
config.add_route('edit', '/edit/{id}') | |||
|
|||
app = config.make_wsgi_app() | |||
serve(app, host='0.0.0.0:6543') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
<!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> | |||
<link rel="stylesheet" href="/deform_static/css/form.css" type="text/css"></link> | |||
<link rel="stylesheet" href="/deform_static/css/theme.css" type="text/css"></link> | |||
<script type="text/javascript" src="/deform_static/scripts/jquery-1.4.2.min.js"></script> | |||
<script type="text/javascript" src="/deform_static/scripts/deform.js"></script> | |||
<script type="text/javascript"> | |||
deform.load() | |||
</script> | |||
</head> | |||
<body> | |||
<div> | |||
<h1><a href="http://github.com/bireme/isisdm">ISISDM Sample Application</a></h1> | |||
<span tal:replace="structure content"></span> | |||
</div> | |||
</body> | |||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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',)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,26 @@ | |||
<!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> | |||
<link rel="stylesheet" href="/deform_static/css/theme.css" type="text/css"></link> | |||
</head> | |||
<body> | |||
<div> | |||
<h1><a href="http://github.com/bireme/isisdm">ISISDM Sample Application</a></h1> | |||
<p><a href="/new">add</a></p> | |||
<table> | |||
<tr> | |||
<th>Entry type</th> | |||
<th>Reference name</th> | |||
<th>Title</th> | |||
</tr> | |||
<tr tal:repeat="record records"> | |||
<td tal:content="record.doc.entry_type"></td> | |||
<td tal:content="record.doc.reference_name"></td> | |||
<td tal:content="record.doc.title"></td> | |||
<td><a href="/edit/${record.id}">edit</a></td> | |||
</tr> | |||
</table> | |||
</div> | |||
</body> | |||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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() | |||
|
|||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,6 +1,7 @@ | |||
# package | # package | ||
from .mapper import Document | from .mapper import Document | ||
from .mapper import TextProperty, MultiTextProperty | from .mapper import TextProperty, MultiTextProperty | ||
from .mapper import CompositeTextProperty, MultiCompositeTextProperty | from .mapper import CompositeTextProperty, IsisCompositeTextProperty | ||
from .mapper import MultiIsisCompositeTextProperty, MultiCompositeTextProperty | |||
from .mapper import ReferenceProperty, FileProperty, BooleanProperty | from .mapper import ReferenceProperty, FileProperty, BooleanProperty | ||
from .couchdb import CouchdbDocument | from .couchdb import CouchdbDocument |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.