Exemple #1
0
def remote_export_primitive(obj):
    """Remote exports a primitive."""
    if isinstance(obj, RemoteObject):
        return obj.remote_export()
    if is_lazy_string(obj):
        return unicode(obj)
    if isinstance(obj, datetime):
        return {'#type': 'solace.datetime',
                'value': obj.strftime('%Y-%m-%dT%H:%M:%SZ')}
    if isinstance(obj, Locale):
        return unicode(str(obj))
    if isinstance(obj, dict):
        return dict((key, remote_export_primitive(value))
                    for key, value in obj.iteritems())
    if hasattr(obj, '__iter__'):
        return map(remote_export_primitive, obj)
    return obj
Exemple #2
0
def lazy_gettext(string):
    """A lazy version of `gettext`."""
    if is_lazy_string(string):
        return string
    return make_lazy_string(gettext, string)
Exemple #3
0
def lazy_gettext(string):
    """A lazy version of `gettext`."""
    if is_lazy_string(string):
        return string
    return make_lazy_string(gettext, string)