示例#1
0
文件: main.py 项目: Russ93/dpw
	def get(self):
		#self.response.write('Hello world!')
		#calling the method "click".. which returns fills lbl
#		button = Button()
		#printing out lbl
#		lbl = button.label
#		self.response.write(button.label)
		
		page = Page() #creates an instance of the imported page
		
#		title = "Welcome!"
		self.response.write(page.open())
		
#		p = p.format(**locals())
		
		if self.request.GET:
			self.response.write(self.request.GET['login'])
		else:
			form = '''
			<form method='GET'>
				<label>login</label><input type='text' name='login' />
				<label>email</label><input type='text' name='email' />
				<button>Submit</button>
			</form>
			'''
		
#		self.response.write(p)
			self.response.write(form)
		self.response.write(page.close())
示例#2
0
def edit_page_create():
    for char in request.form['to_create']:
        if char not in string.ascii_letters + string.digits + ' ':
            return edit_failure('/edit/')
    if request.form['to_create'] and 'edit' not in request.form[
            'to_create'] and 'static' not in request.form['to_create']:
        try:
            site.add(Page(site.name + request.form['to_create'].lower()))
        except:
            return edit_failure('/edit/')
    return edit_success('/edit/')
示例#3
0
	def __init__( self, name):
		try:
			if not os.path.isdir( name):
				os.mkdir( name)
		except:
			raise SiteError( 'Could not create a directory with that name')
		self.name = name
		self.tree = {}
		page_list = os.listdir( self.name)
		page_dict = {}
		for page in page_list:
			page_dict[self.name + '/' + page] = os.listdir( self.name + '/' + page)
		for page_name in page_dict:
			page = Page( page_name)
			for element in page_dict[page_name]:
				try:
					ele_file = open( page_name + '/' + element)
					ele_content = ele_file.read()
					ele_file.close()
					ele_to_load = Element( 'text')
					ele_to_load.load( json.loads( ele_content))
					if element == ele_to_load.render()['id']:
						page.add( ele_to_load, old = True)
					else:
						print( 'Element to load to page is non-natively generated: ' + element)
				except IsADirectoryError:
					pass
				except:
					print( 'Element to load to page is non-natively generated: ' + element)
			self.tree[page_name] = page
		if name + '/index' not in page_dict:
			self.tree[name + '/index'] = Page( name + '/index')
		if name + '/events' not in page_dict:
			self.tree[name + '/events'] = Page( name + '/events')
		if name + '/photos' not in page_dict:
			self.tree[name + '/photos'] = Page( name + '/photos')
		if name + '/blog' not in page_dict:
			self.tree[name + '/blog'] = Page( name + '/blog')
示例#4
0
def edit_page():
    if request.method == 'POST':
        if request.form['to_edit']:
            return redirect('/edit/' + request.form['to_edit'])
        if request.form['to_create']:
            site.add(Page(site.name + request.form['to_create']))
    page_create = PageCreateForm(request.form)
    page_create.to_create.data = ''
    page_edit = PageEditForm(request.form)
    page_edit.choose(site.render().keys())
    return render_template('bedit.html',
                           edits=render_template('edit.html',
                                                 page_create=page_create,
                                                 page_edit=page_edit))
示例#5
0
文件: main.py 项目: Russ93/dpw
    def get(self):
    	page = Page() #creates an instance of the imported page

    	title = 'Russell'
        self.response.write(page.head(title))
        self.response.write(page.body())
        if self.request.GET:
        	self.response.write(page.returnedSub(self.request.GET))
        else:
        	self.response.write(page.regis())
        self.response.write(page.foot())
示例#6
0
 def __init__(self, name):
     try:
         if not os.path.isdir(name):
             os.mkdir(name)
     except:
         raise SiteError('Could not create a directory with that name')
     self.name = name
     self.tree = {}
     page_list = os.listdir(self.name)
     page_dict = {}
     for page in page_list:
         page_dict[self.name + '/' + page] = os.listdir(self.name + '/' +
                                                        page)
     for page_name in page_dict:
         page = Page(page_name)
         for element in page_dict[page_name]:
             try:
                 ele_file = open(page_name + '/' + element)
                 ele_content = ele_file.read()
                 ele_file.close()
                 ele_to_load = Element('text')
                 ele_to_load.load(json.loads(ele_content))
                 if element == ele_to_load.render()['id']:
                     page.add(ele_to_load, old=True)
                 else:
                     print(
                         'Element to load to page is non-natively generated: '
                         + element)
             except IsADirectoryError:
                 pass
             except:
                 print(
                     'Element to load to page is non-natively generated: ' +
                     element)
         self.tree[page_name] = page
     if name + '/index' not in page_dict:
         self.tree[name + '/index'] = Page(name + '/index')
     if name + '/events' not in page_dict:
         self.tree[name + '/events'] = Page(name + '/events')
     if name + '/photos' not in page_dict:
         self.tree[name + '/photos'] = Page(name + '/photos')
     if name + '/blog' not in page_dict:
         self.tree[name + '/blog'] = Page(name + '/blog')
示例#7
0
def makeDummyPage(site):
    name = random.getrandbits(16)
    print('Page name will be ' + str(name))
    test_page = Page(site + str(name))
    return test_page