本文整理汇总了Python中globaleaks.utils.structures.Rosetta.get_localized_attrs方法的典型用法代码示例。如果您正苦于以下问题:Python Rosetta.get_localized_attrs方法的具体用法?Python Rosetta.get_localized_attrs怎么用?Python Rosetta.get_localized_attrs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类globaleaks.utils.structures.Rosetta
的用法示例。
在下文中一共展示了Rosetta.get_localized_attrs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: anon_serialize_node
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import get_localized_attrs [as 别名]
def anon_serialize_node(store, language=GLSetting.memory_copy.default_language):
node = store.find(models.Node).one()
# Contexts and Receivers relationship
associated = store.find(models.ReceiverContext).count()
custom_homepage = False
try:
custom_homepage = os.path.isfile(os.path.join(GLSetting.static_path, "custom_homepage.html"))
except:
pass
node_dict = {
'name': node.name,
'hidden_service': node.hidden_service,
'public_site': node.public_site,
'email': node.email,
'languages_enabled': node.languages_enabled,
'languages_supported': LANGUAGES_SUPPORTED,
'default_language' : node.default_language,
# extended settings info:
'maximum_namesize': node.maximum_namesize,
'maximum_textsize': node.maximum_textsize,
'maximum_filesize': node.maximum_filesize,
# public serialization use GLSetting memory var, and
# not the real one, because needs to bypass
# Tor2Web unsafe deny default settings
'tor2web_admin': GLSetting.memory_copy.tor2web_admin,
'tor2web_submission': GLSetting.memory_copy.tor2web_submission,
'tor2web_receiver': GLSetting.memory_copy.tor2web_receiver,
'tor2web_unauth': GLSetting.memory_copy.tor2web_unauth,
'ahmia': node.ahmia,
'postpone_superpower': node.postpone_superpower,
'can_delete_submission': node.can_delete_submission,
'wizard_done': node.wizard_done,
'anomaly_checks': node.anomaly_checks,
'allow_unencrypted': node.allow_unencrypted,
'x_frame_options_mode': node.x_frame_options_mode,
'x_frame_options_allow_from': node.x_frame_options_allow_from,
'receipt_regexp': node.receipt_regexp,
'configured': True if associated else False,
'password': u"",
'old_password': u"",
'custom_homepage': custom_homepage,
'disable_privacy_badge': node.disable_privacy_badge,
'disable_security_awareness_badge': node.disable_security_awareness_badge,
'disable_security_awareness_questions': node.disable_security_awareness_questions
}
mo = Rosetta()
mo.acquire_storm_object(node)
for attr in mo.get_localized_attrs():
node_dict[attr] = mo.dump_translated(attr, language)
return node_dict
示例2: anon_serialize_node
# 需要导入模块: from globaleaks.utils.structures import Rosetta [as 别名]
# 或者: from globaleaks.utils.structures.Rosetta import get_localized_attrs [as 别名]
def anon_serialize_node(store, language=GLSetting.memory_copy.default_language):
node = store.find(models.Node).one()
# Contexts and Receivers relationship
associated = store.find(models.ReceiverContext).count()
node_dict = {
'name': unicode(node.name),
'hidden_service': unicode(node.hidden_service),
'public_site': unicode(node.public_site),
'email': unicode(node.email),
'languages_enabled': node.languages_enabled,
'languages_supported': LANGUAGES_SUPPORTED,
'default_language' : node.default_language,
'configured': True if associated else False,
# extended settings info:
'maximum_namesize': node.maximum_namesize,
'maximum_textsize': node.maximum_textsize,
'maximum_filesize': node.maximum_filesize,
# public serialization use GLSetting memory var, and
# not the real one, because needs to bypass
# Tor2Web unsafe deny default settings
'tor2web_admin': GLSetting.memory_copy.tor2web_admin,
'tor2web_submission': GLSetting.memory_copy.tor2web_submission,
'tor2web_tip': GLSetting.memory_copy.tor2web_tip,
'tor2web_receiver': GLSetting.memory_copy.tor2web_receiver,
'tor2web_unauth': GLSetting.memory_copy.tor2web_unauth,
'postpone_superpower': node.postpone_superpower,
}
mo = Rosetta()
mo.acquire_storm_object(node)
for attr in mo.get_localized_attrs():
node_dict[attr] = mo.dump_translated(attr, language)
return node_dict