68
68
output = "S3 Debug: " + str(message)
70
70
output += ": " + str(value)
72
72
print >> sys.stderr, output
74
74
# -----------------------------------------------------------------------------
75
75
# User Time Zone Operations:
77
def s3_get_utc_offset():
79
""" Get the current UTC offset for the client """
81
if auth.is_logged_in():
82
# 1st choice is the personal preference (useful for GETs if user wishes to see times in their local timezone)
83
offset = session.auth.user.utc_offset
85
offset = offset.strip()
88
# 2nd choice is what the client provides in the hidden field (for form POSTs)
89
offset = request.post_vars.get("_utc_offset", None)
92
utcstr = offset < 0 and "UTC +" or "UTC -"
93
hours = abs(int(offset/60))
94
minutes = abs(int(offset % 60))
95
offset = "%s%02d%02d" % (utcstr, hours, minutes)
98
# 3rd choice is the server default (what most clients should see the timezone as)
99
offset = deployment_settings.L10n.utc_offset
103
# Store last value in session
104
session.s3.utc_offset = s3_get_utc_offset()
76
107
def shn_user_utc_offset():
78
returns the UTC offset of the current user or None, if not logged in
81
if auth.is_logged_in():
82
return db(db.auth_user.id == session.auth.user.id).select(db.auth_user.utc_offset, limitby=(0, 1)).first().utc_offset
85
offset = db().select(db.s3_setting.utc_offset, limitby=(0, 1)).first().utc_offset
109
""" for backward compatibility """
110
return session.s3.utc_offset
91
113
def shn_as_local_time(value):
376
398
# -----------------------------------------------------------------------------
377
def shn_reference_field():
399
def shn_table_links(reference):
401
Return a dict of tables & their fields which have references to the specified table
402
- to be replaced by db[tablename]._referenced_by
405
for table in db.tables:
407
for field in db[table].fields:
408
if db[table][field].type == "reference %s" % reference:
411
tables[table][count] = field
382
416
# -----------------------------------------------------------------------------
383
417
def shn_insert_subheadings(form, tablename, subheadings):