예제 #1
0
	def post(self):
#		print ""
		storage_name = self.request.get('storage_name')	
		desired = storage_key(storage_name)
		bases = Database.all().ancestor(desired)
		worklists = WorkList.all().ancestor(desired)

#		var = url_splitter(self.request.uri)[1]
		base_list = []
		for base in bases:
			if self.request.get(str(base.name)) == str(base.name):
				base_list.append(base)
#		print base_names

#		base_list = [base for base in bases if str(base.name) in base_names]

		game_list = []
		for base in base_list:
			game_list += m.codelist(str(base.name), str(base.content))
#		print game_list

		w = get_worklist(worklists, desired)
		w.content = db.Text(str(game_list))
#		print w.content

		w.put()

		self.redirect('/search/parameters/')
예제 #2
0
	def post(self):
#		print ""
#		print "</br>"
#		print self.request.get('base_name')
		storage_name = self.request.get('storage_name')
		desired = storage_key(storage_name)
		bases = Database.all().ancestor(desired)

		name = self.request.get('base_name')

		d = get_database(bases, name, desired)

		r = self.request.get('Result').strip()
		if r not in ('0-1', '1-0','*'):
			r = '*'
		
		w = self.request.get('White').strip() or '???????'
		b = self.request.get('Black').strip() or '???????'
		date = self.request.get('Date').strip() or '??.??.????'
		e = self.request.get('Event').strip() or '???????'

		def make(par):
			return '[' + par[0] + ' "' + par[1] + '"]'
		ending = [make(("Event", e)), make(("Date", date)), make(("White", w)), make(("Black", b)), make(("Result", r))]

		for i in range(5):
			f = self.request.get("first" + str(i)).strip()
			s = self.request.get("second" + str(i)).strip()
			if (f and s):
				ending.append(make((f, s)))

		ending.append('')
		ending.append(r)

		game = '\r\n'.join(ending) + '\r\n'

#		new = f.to_saveformat(self.request.get('content'))

#		game = f.to_saveformat(self.request.get('game'), True)
#		old = str(d.content)
#		new = f.save_game(old, ind, game)

#		d.content = db.Text(new)
#		d.put()

#		print ""
#		print d

		d.content += db.Text(game)

		d.put()

		d = get_database(bases, name, desired)
		ind = str(len(m.codelist(name, str(d.content)))-1)

		self.redirect('/board/?' + urllib.urlencode({'base_name': name, 'index': ind}))
예제 #3
0
def search(variablelist, valuelist, store = True, filelist = None, directory = "databases/"):
	"""This returns a pgn file with all the games satisfying the search"""
	if filelist == None:
		filelist = os.listdir("databases/")
	s = open("results/" + resultname(store), "w")
	if store:
		for filename in filelist:
			for game in searchgames(variablelist, valuelist, filename, directory):
				s.write(game)
	else:
		for filename in filelist:
			for game in meta.codelist(filename, variablelist, valuelist, directory):
				s.write(game)
	s.close()
예제 #4
0
	def get(self):
#		print ""
		storage_name = self.request.get('storage_name')
		base_name = self.request.get('base_name')

		desired = storage_key(storage_name)
		bases = Database.all().ancestor(desired)

		b = get_database(bases, base_name, desired)
		output = f.make_html_page(m.codelist(str(b.name), str(b.content)), bases)

		t = test_user(self, VIEW_LOTS)

		template_values = {'user_url':t[1], 'user_url_linktext':t[2],
				'main_page_url':MAIN_PAGE_URL, 'output':output}
		path = os.path.join(os.path.dirname(__file__), t[0])

		self.response.out.write(template.render(path, template_values))
예제 #5
0
	def get(self):
#		print ""
		storage_name = self.request.get('storage_name')
		base_name = self.request.get('base_name')
#		print ""

		t = test_user(self, BROWSE_ONE_DIR)
#		print ""

		desired = storage_key(storage_name)
		bases = Database.all().ancestor(desired)
#		for base in bases:
#			print base.name

#		print ""

		b = get_database(bases, base_name, desired)
#		print '</br>' + b.name + '</br>'
#		print b.content + '</br>'

#		print ""
#		print str(b.name)
#		print str(b.content)
#		print str(b.content).splitlines(True)
		if b.content == '':
			games = []
		else:
			games = m.codelist(str(b.name), str(b.content))
#			games = m.codelist(b.name, b.content)
#		print str(games)

		view_url = url_splitter(MAIN_PAGE_URL)[0] + 'view/'
		view_lots_url = url_splitter(MAIN_PAGE_URL)[0] + 'viewbase/?' + urllib.urlencode({'base_name':str(b.name)})

		template_values = {'user_url':t[1], 'user_url_linktext':t[2],
				'main_page_url':MAIN_PAGE_URL, 'view_url': view_url,
				'view_lots_url':view_lots_url, 'games':games}

		path = os.path.join(os.path.dirname(__file__), t[0])

		self.response.out.write(template.render(path, template_values))