'abbreviated_name': Parameter(str, "Abbreviated site name", max = 50),
'login_base': Parameter(str, "Site slice prefix", max = 20),
'is_public': Parameter(bool, "Publicly viewable site"),
- 'latitude': Parameter(float, "Decimal latitude of the site", min = -90.0, max = 90.0, nullok = True),
+ 'enabled': Parameter(bool, "Has been enabled"),
+ 'latitude': Parameter(float, "Decimal latitude of the site", min = -90.0, max = 90.0, nullok = True),
'longitude': Parameter(float, "Decimal longitude of the site", min = -180.0, max = 180.0, nullok = True),
'url': Parameter(str, "URL of a page that describes the site", max = 254, nullok = True),
'date_created': Parameter(int, "Date and time when site entry was created, in seconds since UNIX epoch", ro = True),
'node_ids': Parameter([int], "List of site node identifiers"),
'peer_id': Parameter(int, "Peer to which this site belongs", nullok = True),
'peer_site_id': Parameter(int, "Foreign site identifier at peer", nullok = True),
+ 'ext_consortium_id': Parameter(int, "external consortium id", nullok = True)
}
# for Cache
if not len(login_base):
raise PLCInvalidArgument, "Login base must be specified"
- if not set(login_base).issubset(string.ascii_letters.lower()):
- raise PLCInvalidArgument, "Login base must consist only of lowercase ASCII letters"
+ if not set(login_base).issubset(string.lowercase + string.digits):
+ raise PLCInvalidArgument, "Login base must consist only of lowercase ASCII letters or numbers"
conflicts = Sites(self.api, [login_base])
for site in conflicts:
add_address = Row.add_object(Address, 'site_address')
remove_address = Row.remove_object(Address, 'site_address')
+ def update_last_updated(self, commit = True):
+ """
+ Update last_updated field with current time
+ """
+
+ assert 'site_id' in self
+ assert self.table_name
+
+ self.api.db.do("UPDATE %s SET last_updated = CURRENT_TIMESTAMP " % (self.table_name) + \
+ " where site_id = %d" % (self['site_id']) )
+ self.sync(commit)
+
def delete(self, commit = True):
"""
Delete existing site.
elif isinstance(site_filter, dict):
site_filter = Filter(Site.fields, site_filter)
sql += " AND (%s)" % site_filter.sql(api, "AND")
+ elif isinstance (site_filter, StringTypes):
+ site_filter = Filter(Site.fields, {'login_base':[site_filter]})
+ sql += " AND (%s)" % site_filter.sql(api, "AND")
+ elif isinstance (site_filter, int):
+ site_filter = Filter(Site.fields, {'site_id':[site_filter]})
+ sql += " AND (%s)" % site_filter.sql(api, "AND")
+ else:
+ raise PLCInvalidArgument, "Wrong site filter %r"%site_filter
self.selectall(sql)