コード例 #1
0
ファイル: app.py プロジェクト: puumuki/tahmatassu-api
app.userstorage = UserStorage()
load_users(app.userstorage)

#Enables GZIP compression
compressor = Compress()
compressor.init_app(app)

#Expose markdown trough application object
app.markdown = Markdown()

app.storage = RecipeStorage(directory=app.config['RECIPE_DIRECTORY'], 
              backup=True, 
              logger=app.logger.info)

#Jinja Context Processor
@app.context_processor
def inject_template_variables():
    return dict(base_path=app.config['BASE_PATH'], upload_directory=app.config['UPLOAD_DIRECTORY'])

@app.context_processor
def file_size_context_processor():
    def file_size( base_url, file_name ):    	    	
      return os.stat(os.path.join(base_url, file_name)).st_size / 1024
    return dict(file_size=file_size)


#Set server language response language
language(app.config['LANGUAGE'] if 'LANGUAGE' in app.config else 'fi')

app.logger.info('Started tahmatassu application')
コード例 #2
0
	def test_changing_language(self):
		language('en')
		self.assertEqual('Missing key testi',msg('missing.key', ('testi',)))
コード例 #3
0
	def test_existing_localization(self):
		language('fi')
		self.assertEqual(u'Reseptiä ei löytynyt',msg('recipe.not.found'))
コード例 #4
0
	def test_existing_localization_with_arguments(self):
		language('fi')
		self.assertEqual('Tallennus parametri puuttu: testi',msg('missing.key', ('testi',)))
コード例 #5
0
	def test_localization(self):
		language('fi')
		self.assertEqual('Missing translation for key ',msg(''))