コード例 #1
0
ファイル: tag.py プロジェクト: manumilou/chezwam
    def create(self):
		# Add the new tag to the database
    	tag = model.Tag()
    	for k, v in self.form_result.items():
        	setattr(tag, k, v)
    	meta.Session.add(tag)
    	meta.Session.commit()
    	# Issue an HTTP redirect
    	response.status_int = 302
    	response.headers['location'] = h.url_for(controller='tag',
        	action='view', id=tag.id)
    	return "Moved temporarily"
コード例 #2
0
ファイル: tag.py プロジェクト: manumilou/chezwam
    def save(self, id=None):
    	tag_q = meta.Session.query(model.Tag)
    	tag = tag_q.filter_by(id=id).first()
    	if tag is None:
        	abort(404)
    	for k,v in self.form_result.items():
        	if getattr(tag, k) != v:
				setattr(tag, k, v)
    	meta.Session.commit()
		# Flash message and session
    	session['flash'] = 'Tag successfully updated.'
    	session.save()
    	# Issue an HTTP redirect
    	response.status_int = 302
    	response.headers['location'] = h.url_for(controller='tag', action='view',
        	id=tag.id)
    	return "Moved temporarily"
コード例 #3
0
ファイル: section.py プロジェクト: manumilou/chezwam
    def save(self, id=None):
		section_q = meta.Session.query(model.Section)
		section = section_q.filter_by(id=id).first()
		if section is None:
			abort(404)
		if not(section.section == self.form_result['section'] and \
        	section.before == self.form_result['before']):
			model.Nav.remove_navigation_node(section)
			model.Nav.add_navigation_node(section, self.form_result['section'],
				self.form_result['before'])
		for k,v in self.form_result.items():
			if getattr(section, k) != v:
				setattr(section, k, v)
		meta.Session.commit()
		session['flash'] = 'Section successfully updated.'
		session.save()
		# Issue an HTTP redirect	
		response.status_int = 302
		response.headers['location'] = h.url_for('path',
        	id=section.id)
		return "Moved temporarily"
コード例 #4
0
ファイル: section.py プロジェクト: manumilou/chezwam
    def create(self):
		# Add the new section to the database
		section = model.Section()
		for k, v in self.form_result.items():
			setattr(section, k, v)
		meta.Session.add(section)
		model.Nav.add_navigation_node(section, self.form_result['section'],
			self.form_result['before'])
		# Flush the data to get the session ID.
		meta.Session.flush()
		index_page = model.Page()
		index_page.section = section.id
		index_page.path = 'index'
		index_page.title = 'Section Index'
		index_page.name = 'Section Index'
		index_page.content = 'This is the index page for this section.'
		meta.Session.add(index_page)
		meta.Session.commit()
		# Issue an HTTP redirect
		response.status_int = 302
		response.headers['location'] = h.url_for('path',
        	id=section.id)
		return "Moved temporarily"