from libchewing import ChewingContext, CHEWING_DATA_DIR from ctypes import c_uint, byref, create_string_buffer config_dir = os.path.join(os.path.expandvars("%APPDATA%"), "PIME", "chewing") localdata_dir = os.path.join(os.path.expandvars("%LOCALAPPDATA%"), "PIME", "chewing") COOKIE_ID = "chewing_config_token" SERVER_TIMEOUT = 120 # syspath 參數可包含多個路徑,用 ; 分隔 # 此處把 user 設定檔目錄插入到 system-wide 資料檔路徑前 # 如此使用者變更設定後,可以比系統預設值有優先權 search_paths = ";".join( (chewingConfig.getConfigDir(), CHEWING_DATA_DIR)).encode("UTF-8") user_phrase = chewingConfig.getUserPhrase().encode("UTF-8") # print(search_paths, user_phrase) chewing_ctx = ChewingContext(syspath=search_paths, userpath=user_phrase) # new libchewing context class BaseHandler(tornado.web.RequestHandler): def get_current_user(self): # override the login check return self.get_cookie(COOKIE_ID) def prepare(self): # called before every request self.application.reset_timeout() # reset the quit server timeout class KeepAliveHandler(BaseHandler):
from chewing_config import chewingConfig from libchewing import ChewingContext, CHEWING_DATA_DIR from ctypes import c_uint, byref, create_string_buffer config_dir = os.path.join(os.path.expandvars("%APPDATA%"), "PIME", "chewing") localdata_dir = os.path.join(os.path.expandvars("%LOCALAPPDATA%"), "PIME", "chewing") COOKIE_ID = "chewing_config_token" SERVER_TIMEOUT = 120 # syspath 參數可包含多個路徑,用 ; 分隔 # 此處把 user 設定檔目錄插入到 system-wide 資料檔路徑前 # 如此使用者變更設定後,可以比系統預設值有優先權 search_paths = ";".join((chewingConfig.getConfigDir(), CHEWING_DATA_DIR)).encode("UTF-8") user_phrase = chewingConfig.getUserPhrase().encode("UTF-8") # print(search_paths, user_phrase) chewing_ctx = ChewingContext(syspath = search_paths, userpath = user_phrase) # new libchewing context class BaseHandler(tornado.web.RequestHandler): def get_current_user(self): # override the login check return self.get_cookie(COOKIE_ID) def prepare(self): # called before every request self.application.reset_timeout() # reset the quit server timeout class KeepAliveHandler(BaseHandler):
config_dir = os.path.join(os.path.expandvars("%APPDATA%"), "PIME", "chewing") current_dir = os.path.dirname(__file__) data_dir = os.path.join(current_dir, "data") localdata_dir = os.path.join(os.path.expandvars("%LOCALAPPDATA%"), "PIME", "chewing") COOKIE_ID = "chewing_config_token" SERVER_TIMEOUT = 120 # syspath 參數可包含多個路徑,用 ; 分隔 # 此處把 user 設定檔目錄插入到 system-wide 資料檔路徑前 # 如此使用者變更設定後,可以比系統預設值有優先權 search_paths = ";".join( (chewingConfig.getConfigDir(), data_dir)).encode("UTF-8") user_phrase = chewingConfig.getUserPhrase().encode("UTF-8") # print(search_paths, user_phrase) chewing_ctx = ChewingContext(syspath=search_paths, userpath=user_phrase) # new libchewing context class BaseHandler(tornado.web.RequestHandler): def get_current_user(self): # override the login check return self.get_cookie(COOKIE_ID) def prepare(self): # called before every request self.application.reset_timeout() # reset the quit server timeout class KeepAliveHandler(BaseHandler):
config_dir = os.path.join(os.path.expandvars("%APPDATA%"), "PIME", "chewing") current_dir = os.path.dirname(__file__) data_dir = os.path.join(current_dir, "data") localdata_dir = os.path.join(os.path.expandvars("%LOCALAPPDATA%"), "PIME", "chewing") COOKIE_ID = "chewing_config_token" SERVER_TIMEOUT = 120 # syspath 參數可包含多個路徑,用 ; 分隔 # 此處把 user 設定檔目錄插入到 system-wide 資料檔路徑前 # 如此使用者變更設定後,可以比系統預設值有優先權 search_paths = ";".join((chewingConfig.getConfigDir(), data_dir)).encode("UTF-8") user_phrase = chewingConfig.getUserPhrase().encode("UTF-8") # print(search_paths, user_phrase) chewing_ctx = ChewingContext(syspath = search_paths, userpath = user_phrase) # new libchewing context class BaseHandler(tornado.web.RequestHandler): def get_current_user(self): # override the login check return self.get_cookie(COOKIE_ID) def prepare(self): # called before every request self.application.reset_timeout() # reset the quit server timeout class KeepAliveHandler(BaseHandler):