def __init__(self): CTK.Box.__init__(self, {'class': 'add_new_domain'}) # Dialog field = CTK.TextField({'name': 'new_domain', 'class': 'noauto'}) add = CTK.SubmitterButton("Add") report = CTK.Box() box = CTK.Box() box += field box += add box += report submit = CTK.Submitter(URL_NEW_SUBMIT) submit += box submit.bind( 'submit_success', self.REPORT_OK_JS % (report.id, field.id) + field.JS_to_clean()) submit.bind('submit_fail', self.REPORT_FAIL_JS % (report.id, field.id)) coll = CTK.CollapsibleEasy(('Add your domain…', 'Add your domain…')) coll += CTK.RawHTML('<p>%s</p>' % (self.P1)) coll += submit self += coll
def __init__ (self, command_progress): CTK.Container.__init__ (self) # Length and current commands_len = len(command_progress.commands) if command_progress.error or \ command_progress.executed >= commands_len: command_entry = command_progress.commands [command_progress.executed - 1] else: command_entry = command_progress.commands [command_progress.executed] # Title if command_entry.has_key('description'): title = CTK.escape_html (command_entry['description']) elif command_entry.has_key('command'): title = CTK.escape_html (command_entry['command']) elif command_entry.has_key('function'): title = CTK.escape_html (command_entry['function'].__name__) else: assert False, 'Unknown command entry type' # Error if command_progress.error: ret = command_progress.last_popen_ret percent = command_progress.executed * 100.0 / (commands_len + 1) if ret.get('command'): title_error = CTK.escape_html (ret['command']) elif command_entry.has_key ('function'): title_error = CTK.escape_html (command_entry['function'].__name__) else: title_error = _("Unknown Error") error_content = CTK.Box ({'class': 'market-commands-exec-error-details'}) error_content += CTK.RawHTML ("<pre>%s</pre>" %(error_to_HTML(ret['stderr']))) details = CTK.CollapsibleEasy ((_(MORE), _(LESS))) details += error_content self += CTK.ProgressBar ({'value': percent}) self += CTK.RawHTML ("<p><b>%s</b>: %s</p>" %(_("Error executing"), title_error)) self += details return # Regular percent = (command_progress.executed + 1) * 100.0 / (commands_len + 1) self += CTK.ProgressBar ({'value': percent}) self += CTK.Box ({'class': 'market-commands-exec-command'}, CTK.RawHTML ("<p>%s</p>" %(title))) # Next step if command_progress.executed < commands_len: JS = "update = function(){%s}; setTimeout ('update()', %s);" self += CTK.RawHTML (js = JS%(command_progress.refresh.JS_to_refresh(), DELAY)) else: self += CTK.RawHTML (js = CTK.DruidContent__JS_to_goto (command_progress.id, command_progress.finished_url))
def __init__ (self, vsrv_num, refreshable): CTK.Container.__init__ (self) pre = "vserver!%s" %(vsrv_num) url_apply = "%s/%s/log" %(URL_APPLY, vsrv_num) writers = [('', _('Disabled'))] + trans_options(LOGGER_WRITERS) # Error writer table = CTK.PropsTable() table.Add (_('Write errors to'), CTK.ComboCfg('%s!error_writer!type'%(pre), writers), _(NOTE_ERRORS)) writer = CTK.cfg.get_val ('%s!error_writer!type'%(pre)) if writer == 'file': table.Add (_('Filename'), CTK.TextCfg('%s!error_writer!filename'%(pre)), _(NOTE_WRT_FILE)) elif writer == 'exec': table.Add (_('Command'), CTK.TextCfg('%s!error_writer!command'%(pre)), _(NOTE_WRT_EXEC)) submit = CTK.Submitter(url_apply) submit.bind ('submit_success', refreshable.JS_to_refresh()) submit += table self += CTK.RawHTML ('<h2>%s</h2>' % (_('Error Logging'))) self += CTK.Indenter (submit) # Access logger pre = 'vserver!%s!logger' %(vsrv_num) submit = CTK.Submitter(url_apply) submit.bind ('submit_success', refreshable.JS_to_refresh()) submit += CTK.ComboCfg(pre, trans_options(Cherokee.support.filter_available(LOGGERS))) table = CTK.PropsTable() table.Add (_('Format'), submit, _(NOTE_LOGGERS)) format = CTK.cfg.get_val(pre) if format: submit = CTK.Submitter(url_apply) submit.bind ('submit_success', refreshable.JS_to_refresh()) submit += CTK.ComboCfg('%s!access!type'%(pre), trans_options(LOGGER_WRITERS)) table.Add (_('Write accesses to'), submit, _(NOTE_ACCESSES)) submit = CTK.Submitter(url_apply) writer = CTK.cfg.get_val ('%s!access!type'%(pre)) if not writer: CTK.cfg['%s!access!type'%(pre)] = 'file' if writer == 'file' or not writer: # Set a default value if not CTK.cfg.get_val ('%s!access!filename'%(pre)): CTK.cfg['%s!access!filename'%(pre)] = os.path.join (CHEROKEE_VAR_LOG, 'cherokee.log') submit += CTK.TextCfg('%s!access!filename'%(pre), False) table.Add (_('Filename'), submit, _(NOTE_WRT_FILE)) elif writer == 'exec': submit += CTK.TextCfg('%s!access!command'%(pre)) table.Add (_('Command'), submit, _(NOTE_WRT_EXEC)) if format == 'custom': table_macros = CTK.Table ({'class': 'custom-logger-macros'}) for macro, desc in CUSTOM_MACROS_LIST: table_macros += [CTK.RawHTML('${%s}'%(macro)), CTK.RawHTML (_(desc))] collaps = CTK.CollapsibleEasy ((_('Show macros'), _('Hide'))) collaps += table_macros macros = CTK.Container() macros += CTK.RawHTML (_(NOTE_LOGGER_TEMPLATE)) macros += collaps submit = CTK.Submitter(url_apply) submit += CTK.TextCfg('%s!access_template'%(pre)) table.Add (_('Template: '), submit, macros) self += CTK.RawHTML ('<h2>%s</h2>' % (_('Access Logging'))) self += CTK.Indenter (table) # Properties if CTK.cfg.get_val (pre): table = CTK.PropsTable() table.Add (_('Time standard'), CTK.ComboCfg ('%s!utc_time'%(pre), trans_options(UTC_TIME)), _(NOTE_UTC_TIME)) table.Add (_('Accept Forwarded IPs'), CTK.CheckCfgText ('%s!x_real_ip_enabled'%(pre), False, _('Accept')), _(NOTE_X_REAL_IP)) if int (CTK.cfg.get_val('%s!x_real_ip_enabled'%(pre), "0")): table.Add (_('Don\'t check origin'), CTK.CheckCfgText ('%s!x_real_ip_access_all'%(pre), False, _('Do not check')), _(NOTE_X_REAL_IP_ALL)) if not int (CTK.cfg.get_val ('%s!x_real_ip_access_all'%(pre), "0")): table.Add (_('Accept from Hosts'), CTK.TextCfg ('%s!x_real_ip_access'%(pre)), _(NOTE_X_REAL_IP_ACCESS)) submit = CTK.Submitter(url_apply) submit.bind ('submit_success', refreshable.JS_to_refresh()) submit += table self += CTK.RawHTML ('<h3>%s</h3>' % (_('Logging Options'))) self += CTK.Indenter (submit)