本文整理汇总了Python中models.Note.put方法的典型用法代码示例。如果您正苦于以下问题:Python Note.put方法的具体用法?Python Note.put怎么用?Python Note.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Note
的用法示例。
在下文中一共展示了Note.put方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_note
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import put [as 别名]
def _create_note(self, user, file_name, file_path):
note = Note(parent=ndb.Key("User", user.nickname()),
title=self.request.get('title'),
content=self.request.get('content'))
note.put()
# Retrieve csv representing checklist items
item_titles = self.request.get('checklist_items').split(',')
for item_title in item_titles:
if not item_title:
continue
# create a checklist instance
item = CheckListItem(parent = note.key, title = item_title)
# store each checklist
item.put()
# after storing it, we can access the key to append it to the note
note.checklist_items.append(item.key)
if file_name and file_path:
url, thumbnail_url = self._get_urls_for(file_name)
f = NoteFile(parent=note.key, name=file_name,
url=url, thumbnail_url=thumbnail_url,
full_path=file_path)
f.put()
note.files.append(f.key)
# update the note entity with the checklist items
note.put()
示例2: _create_note
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import put [as 别名]
def _create_note(self, user, file_name, file_path):
note = Note(parent=ndb.Key("User", user.nickname()),
title=self.request.get('title'),
content=self.request.get('content'))
#note.put()
item_titles = self.request.get('checklist_items').split(',')
for item_title in item_titles:
if not item_title:
continue
item = CheckListItem(title=item_title)
#item.put()
#note.checklist_items.append(item.key)
note.checklist_items.append(item)
#item = CheckListItemObject(title=item_title)
#note.checklist_items.append(item)
if file_name and file_path:
url, thumbnail_url = self._get_urls_for(file_name)
f = NoteFile(parent=note.key, name=file_name,
url=url, thumbnail_url=thumbnail_url,
full_path=file_path)
f.put()
note.files.append(f.key)
note.put()
示例3: note_insert
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import put [as 别名]
def note_insert(self, note):
if note.from_datastore:
note_with_parent = note
else:
note_with_parent = Note(parent=main.get_parent_key(endpoints.get_current_user()),
note = note.note, company_entity_key = note.company_entity_key)
note_with_parent.put()
return note_with_parent
示例4: create
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import put [as 别名]
def create(self):
if not users.get_current_user():
webapp2.abort(401)
form = NoteForm(self.get_locale(), self.request.POST, None)
if self.request.POST and form.validate():
note = Note(author=users.get_current_user(), **form.data)
note.date = datetime.now()
note.put()
return self.redirect('/note/list')
self.render_template('form.html', {'title': _('Note'), 'form': form, 'name': 'note'})
示例5: get
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import put [as 别名]
def get(self):
if 'X-AppEngine-Cron' not in self.request.headers:
self.error(403)
przedszkole = iPrzedszkole('<nazwa przedszkola>', '<uzytkownik>', '<haslo>')
menu = przedszkole.jadlospis()
if menu is None:
menu = "Weekend :)"
note = Note(id='jadlospis')
note.kindergartenMenu = menu
note.put()
memcache.set(key='jadlospis', value=note.kindergartenMenu, time=expirationTime)
示例6: post
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import put [as 别名]
def post(self):
user = users.get_current_user()
if user is None:
self.error(401)
self._create_note(user)
note = Note(title = self.request.get('title'),content = self.request.get('content'))
note.put()
note = Note(parent=ndb.Key("User", user.nickname()), title=self.request.get('title'), content=self.request.get('content'))
note.put()
item_titles = self.request.get('checklist_items').split(',')
for item_title in item_titles:
item = CheckListItem(parent=note.key, title=item_title)
item.put()
note.checklist_items.append(item.key)
note.put()
logout_url = users.create_logout_url(self.request.uri)
template_context = {
'user': user.nickname(),
'logout_url': logout_url,
}
self.response.out.write(template.render(template_context))
def _render_template(self, template_name, context=None):
if context is None:
context = {}
user = users.get_current_user()
ancestor_key = ndb.Key("User", user.nickname())
qry = Note.owner_query(ancestor_key)
context['notes'] = qry.fetch()
template = jinja_env,get_template(template_name)
return template.render(context)
self.response.out.write(self._render_template('main.html', template_context))
@ndb.transactional
def _create_note(self, user):
note = Note(parent=ndb.Key("User", user.nickname()), title=self.request.get('title'), content=self.request.get('content'))
note.put()
item_titles = self.request.get('checklist_items').split(',')
for item_title in item_titles:
item = CheckListItem(parent=note.key, title=item_title)
item.put()
note.checklist_items.append(item.key)
note.put()
示例7: _create_note
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import put [as 别名]
def _create_note(self,user):
note = Note(parent=ndb.Key("User",user.nickname()),
title=self.request.get('title'),
content=self.request.get('content'))
note.put()
item_titles = self.request.get('checklist_items').split(',')
for item_title in item_titles:
item = CheckListItem(parent=note.key,title=item_title)
item.put()
note.checklist_items.append(item.key)
note.put()
示例8: POST
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import put [as 别名]
def POST(self):
user = users.get_current_user()
form = form_add_note()
object = {}
if form.validates():
object["success"] = True
object["response"] = form.d.note
note = Note(author=user, name=form.d.note, tags=form.d.ntag_list.split(","))
note.put()
object["message"] = "New note has been created"
else:
object["success"] = False
object["errors"] = form.get_errors()
object["message"] = "Note has not been created"
return simplejson.dumps(object)
示例9: post
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import put [as 别名]
def post(self):
user = self.user
if user:
content = self.request.get('note')
note = Note()
note.content = content
note.user = user.key
note.put()
# show confirma tion of successful post creation
template_values = {
'message': 'Note created successfully'
}
templates.render_page("notes/created", template_values, self)
else:
# error about login
return
return
示例10: list_notes
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import put [as 别名]
def list_notes():
notes = Note.query()
# Convert body of each note to marked-up markdown
for note in notes:
note.body = Markup(markdown.markdown(note.body))
form = NoteForm()
if form.validate_on_submit():
note = Note(title=form.note_title.data,
slug=slugify(form.note_title.data),
body=form.note_body.data,
author=users.get_current_user())
try:
note.put()
note_id = note.key.id()
flash(u'Note %s saved.' % note_id, 'success')
return redirect(url_for('list_notes'))
except CapabilityDisabledError:
flash(u'Datastore is in read-only mode.', 'info')
return redirect(url_for('list_notes'))
return render_template('dynamic_notes.html', notes=notes, form=form)
示例11: post
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import put [as 别名]
def post(self):
user = users.get_current_user()
if user is None:
self.error(401)
note = Note(parent=ndb.Key("User", user.nickname()),
title=self.request.get('title'),
content=self.request.get('content'))
note.put()
item_titles = self.request.get('checklist_items').split(',')
for item_title in item_titles:
item = CheckListItem(parent=note.key, title=item_title)
item.put()
note.checklist_items.append(item.key)
note.put()
logout_url = users.create_logout_url(self.request.uri)
template_context = {
'user': user.nickname(),
'logout_url': logout_url,
}
self.response.out.write(self._render_template('main.html', template_context))
示例12: createNote
# 需要导入模块: from models import Note [as 别名]
# 或者: from models.Note import put [as 别名]
def createNote(self, data):
note = Note(author=users.get_current_user(), date=datetime.now(), **data)
note.put()
return note