Esempio n. 1
0
 def add_document(self):
     schema = DocumentSchema()
     form = Form(schema, buttons=('submit', ))
     if 'submit' in self.request.POST:
         # Make a new Document
         title = self.request.POST['title']
         content = self.request.POST['content']
         name = str(randint(0, 999999))
         new_document = Document(title, content)
         new_document.__name__ = name
         new_document.__parent__ = self.context
         self.context[name] = new_document
         # Redirect to the new document
         url = self.request.resource_url(new_document)
         return HTTPFound(location=url)
     return {"form": form.render()}
Esempio n. 2
0
 def add_document(self):
     schema = DocumentSchema()
     form = Form(schema, buttons=('submit',))
     if 'submit' in self.request.POST:
         # Make a new Document
         title = self.request.POST['title']
         content = self.request.POST['content']
         name = str(randint(0,999999))
         new_document = Document(title, content)
         new_document.__name__ = name
         new_document.__parent__ = self.context
         self.context[name] = new_document
         # Redirect to the new document
         url = self.request.resource_url(new_document)
         return HTTPFound(location=url)
     return {"form": form.render()}
Esempio n. 3
0
 def add_document(self):
     schema = DocumentSchema()
     form = Form(schema, buttons=('submit', ))
     if 'submit' in self.request.POST:
         # Make a new Document
         title = self.request.POST['title']
         content = self.request.POST['content']
         doc_id = self.document_map.new_docid()
         name = "document%s" % doc_id
         new_document = Document(title, content)
         new_document.__name__ = name
         new_document.__parent__ = self.context
         self.context[name] = new_document
         # map object path to catalog id
         path = resource_path(new_document)
         self.document_map.add(path, doc_id)
         # index new folder
         self.catalog.index_doc(doc_id, new_document)
         # Redirect to the new document
         url = self.request.resource_url(new_document)
         return HTTPFound(location=url)
     return {"form": form.render()}
Esempio n. 4
0
 def add_document(self):
     schema = DocumentSchema()
     form = Form(schema, buttons=('submit',))
     if 'submit' in self.request.POST:
         # Make a new Document
         title = self.request.POST['title']
         content = self.request.POST['content']
         doc_id = self.document_map.new_docid()
         name = "document%s" % doc_id
         new_document = Document(title, content)
         new_document.__name__ = name
         new_document.__parent__ = self.context
         self.context[name] = new_document
         # map object path to catalog id
         path = resource_path(new_document)
         self.document_map.add(path, doc_id) 
         # index new folder
         self.catalog.index_doc(doc_id, new_document)
         # Redirect to the new document
         url = self.request.resource_url(new_document)
         return HTTPFound(location=url)
     return {"form": form.render()}