本文整理汇总了Python中dNG.data.text.l10n.L10n.get_instance方法的典型用法代码示例。如果您正苦于以下问题:Python L10n.get_instance方法的具体用法?Python L10n.get_instance怎么用?Python L10n.get_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dNG.data.text.l10n.L10n
的用法示例。
在下文中一共展示了L10n.get_instance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import get_instance [as 别名]
def execute(self):
#
"""
Executes the processor.
:since: v0.1.00
"""
if (self.form is None or (not self.validate_settings(self.settings))): raise ValueException("Processor is not configured")
lang = (self.settings['email_lang']
if ("email_lang" in self.settings) else
L10n.get_instance().get_lang()
)
sender = (InputFilter.filter_control_chars(self.form.get_input(self.settings['email_sender_field_name']))
if ("email_sender_field_name" in self.settings) else
None
)
subject = (InputFilter.filter_control_chars(self.form.get_input(self.settings['email_subject_field_name']))
if ("email_subject_field_name" in self.settings) else
self.settings['email_subject_title']
)
if (subject is None or len(subject.strip()) < 1): raise ValueException("Given e-mail subject is invalid")
content_list = [ ]
titles = self.settings.get("form_field_titles", { })
for field_name in self.settings['email_content_field_names']:
#
value = InputFilter.filter_control_chars(self.form.get_input(field_name))
content_list.append("{0}:\n{1}".format((titles[field_name] if (field_name in titles) else field_name),
value
)
)
#
content = "\n\n".join(content_list)
DatabaseTasks.get_instance().add("dNG.pas.http.Form.sendEMail.{0}".format(Binary.str(hexlify(urandom(16)))),
"dNG.pas.http.Form.sendEMail",
1,
lang = lang,
sender = sender,
subject = subject,
content = content
)
示例2: run
# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import get_instance [as 别名]
def run(self):
"""
Task execution
:since: v0.2.00
"""
user_profile_class = NamedLoader.get_class("dNG.data.user.Profile")
user_profile = user_profile_class.load_username(self.username)
original_user_profile_data = user_profile.get_data_attributes(*self.values_changed.keys())
user_profile.set_data_attributes(**self.values_changed)
user_profile.save()
DatabaseTasksProxy.get_instance().add("dNG.pas.user.Profile.onEdited.{0}".format(self.username),
"dNG.pas.user.Profile.onEdited",
1,
user_profile_id = user_profile.get_id(),
user_profile_data_changed = self.values_changed,
original_user_profile_data = original_user_profile_data
)
task_data = DatabaseTasks.get_instance().get(self.vid)
if (task_data is not None and "_task" in task_data):
task_data['_task'].set_status_completed()
task_data['_task'].save()
#
user_profile_data = user_profile.get_data_attributes("id", "name", "lang")
L10n.init("core", user_profile_data['lang'])
L10n.init("pas_core", user_profile_data['lang'])
L10n.init("pas_http_user", user_profile_data['lang'])
l10n = L10n.get_instance(user_profile_data['lang'])
_return = PredefinedHttpRequest()
_return.set_module("output")
_return.set_service("http")
_return.set_action("done")
_return.set_parameter_chained("title", l10n.get("pas_http_user_title_change_profile"))
_return.set_parameter_chained("message", l10n.get("pas_http_user_done_change_profile"))
_return.set_parameter_chained("lang", l10n.get_lang())
_return.set_parameter_chained("target_iline", "m=user;s=profile;lang={0};dsd=upid+{1}".format(user_profile_data['lang'], user_profile_data['id']))
return _return
示例3: execute_done
# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import get_instance [as 别名]
def execute_done(self):
"""
Action for "done"
:since: v1.0.0
"""
if (not isinstance(self.request, AbstractInnerRequest)): raise TranslatableException("pas_http_core_400", 400)
parameters_chained = self.request.parameters_chained
is_parameters_chained_valid = ("title" in parameters_chained and "message" in parameters_chained)
if (not is_parameters_chained_valid): raise TranslatableException("pas_http_core_500")
l10n = (L10n.get_instance(parameters_chained['lang'])
if ("lang" in parameters_chained) else
L10n.get_instance()
)
L10n.init("core", l10n.lang)
content = { "title": parameters_chained['title'],
"title_task_done": l10n.get("core_title_task_done"),
"message": parameters_chained['message']
}
if ("target_iline" in parameters_chained):
content['link_title'] = l10n.get("core_continue")
target_iline = re.sub("\\_\\_\\w+\\_\\_", "", parameters_chained['target_iline'])
content['link_url'] = Link().build_url(Link.TYPE_RELATIVE_URL, { "__query__": target_iline })
#
self.response.init()
self.response.page_title = parameters_chained['title']
self.response.add_oset_content("core.done", content)
示例4: run
# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import get_instance [as 别名]
def run(self):
"""
Task execution
:since: v0.2.00
"""
user_profile_class = NamedLoader.get_class("dNG.data.user.Profile")
user_profile = user_profile_class.load_username(self.username)
user_profile.unlock()
user_profile.save()
database_tasks_proxy = DatabaseTasksProxy.get_instance()
database_tasks_proxy.add("dNG.pas.user.Profile.updateSecID.{0}".format(self.username),
"dNG.pas.user.Profile.updateSecID",
1,
username = self.username
)
database_tasks_proxy.remove("dNG.pas.user.Profile.delete.{0}".format(self.username))
task_data = DatabaseTasks.get_instance().get(self.vid)
if (task_data is not None and "_task" in task_data):
task_data['_task'].set_status_completed()
task_data['_task'].save()
#
user_profile_data = user_profile.get_data_attributes("name", "lang")
L10n.init("core", user_profile_data['lang'])
L10n.init("pas_core", user_profile_data['lang'])
L10n.init("pas_http_user", user_profile_data['lang'])
l10n = L10n.get_instance(user_profile_data['lang'])
_return = PredefinedHttpRequest()
_return.set_module("output")
_return.set_service("http")
_return.set_action("done")
_return.set_parameter_chained("title", l10n.get("pas_http_user_title_registration"))
_return.set_parameter_chained("message", l10n.get("pas_http_user_done_registration"))
_return.set_parameter_chained("lang", l10n.get_lang())
_return.set_parameter_chained("target_iline", "m=user;s=status;a=login;lang={0}".format(user_profile_data['lang']))
return _return
示例5: run
# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import get_instance [as 别名]
def run(self):
"""
Task execution
:since: v0.2.00
"""
if (self.__class__.EMAIL_RENDERER is None): raise ValueException("Defined e-mail renderer is invalid")
user_profile_class = NamedLoader.get_class("dNG.data.user.Profile")
user_profile = user_profile_class.load_username(self.username)
user_profile_data = user_profile.get_data_attributes("name", "lang", "email")
email = self.get_email_recipient()
if (email is None): email = user_profile_data['email']
L10n.init("core", user_profile_data['lang'])
L10n.init("pas_core", user_profile_data['lang'])
L10n.init("pas_http_user", user_profile_data['lang'])
l10n = L10n.get_instance(user_profile_data['lang'])
email_renderer = NamedLoader.get_instance(self.__class__.EMAIL_RENDERER, l10n = l10n)
content = email_renderer.render(user_profile_data, self.vid, self.vid_timeout_days)
subject = self.get_email_subject(l10n)
if (subject is None): subject = l10n.get("pas_http_user_title_verification")
part = Part(Part.TYPE_MESSAGE_BODY, "text/plain", content)
message = Message()
message.add_body(part)
message.set_subject(subject)
message.set_to(Message.format_address(user_profile_data['name'], email))
smtp_client = SmtpClient()
smtp_client.set_message(message)
smtp_client.send()
示例6: run
# 需要导入模块: from dNG.data.text.l10n import L10n [as 别名]
# 或者: from dNG.data.text.l10n.L10n import get_instance [as 别名]
def run(self):
"""
Task execution
:since: v0.2.00
"""
user_profile_class = NamedLoader.get_class("dNG.data.user.Profile")
user_profile = user_profile_class.load_username(self.username)
secid = user_profile_class.generate_secid()
secid_hashed = Tmd5.password_hash(re.sub("\\W+", "", secid), Settings.get("pas_user_profile_password_salt"), self.username)
user_profile.set_data_attributes(secid = secid_hashed)
user_profile.save()
user_profile_data = user_profile.get_data_attributes("name", "lang", "email")
L10n.init("core", user_profile_data['lang'])
L10n.init("pas_core", user_profile_data['lang'])
L10n.init("pas_http_user", user_profile_data['lang'])
l10n = L10n.get_instance(user_profile_data['lang'])
email_renderer = NamedLoader.get_instance("dNG.data.text.user.SecIDUpdatedEMailRenderer", l10n = l10n)
content = email_renderer.render(user_profile_data, secid)
subject = l10n.get("pas_http_user_title_sec_id_updated")
part = Part(Part.TYPE_MESSAGE_BODY, "text/plain", content)
message = Message()
message.add_body(part)
message.set_subject(subject)
message.set_to(Message.format_address(user_profile_data['name'], user_profile_data['email']))
smtp_client = SmtpClient()
smtp_client.set_message(message)
smtp_client.send()