def _update(self, key):
		user = self.user()
		doc = self._postdata()
		if not key:
			info("adding new text")
			text = Text(owner=user)
			try:
				del doc['old_content']
			except KeyError: pass
		else:
			info("updating text with key=%r, title=%s" % (key,doc.get('title', None)))
			text = Text.find(owner=user, key=key)

		if text is None:
			raise HttpError(404, "no such textarea to edit!")
		try:
			if doc['old_content'] != text.content:
				raise HttpError(409, "existing content does not match datastore")
			logging.info("old_content matched datastore")
		except KeyError:
			logging.info("no old_content given - assuming no conflict")
		text.content = doc['content']
		text.title = doc['title']
		text.expanded = doc.get('expanded', True)
		text.save()
		return text
	def delete(self, key):
		text = Text.find(owner=self.user(), key=key)
		if text:
			text.delete()
			self._render()
		else:
			info("could not find text" % (key,))
			raise HttpError(404, "could not find text")
	def get(self, key):
		self._render(Text.find(self.user(), key))