From: Mark Huang Date: Fri, 8 Sep 2006 19:45:57 +0000 (+0000) Subject: - set min and max for str fields X-Git-Tag: pycurl-7_13_1~767 X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=commitdiff_plain;h=33e016e4c427ac96cd4470c1449930ba31653cb7 - set min and max for str fields --- diff --git a/PLC/Nodes.py b/PLC/Nodes.py index 4c93e3d..05bb73a 100644 --- a/PLC/Nodes.py +++ b/PLC/Nodes.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id$ +# $Id: Nodes.py,v 1.1 2006/09/06 15:36:07 mlhuang Exp $ # from types import StringTypes @@ -26,16 +26,16 @@ class Node(Row): fields = { 'node_id': Parameter(int, "Node identifier"), - 'hostname': Parameter(str, "Fully qualified hostname"), - 'boot_state': Parameter(str, "Boot state"), - 'model': Parameter(str, "Make and model of the actual machine"), - 'boot_nonce': Parameter(str, "(Admin only) Random value generated by the node at last boot"), - 'version': Parameter(str, "Apparent Boot CD version"), - 'ssh_rsa_key': Parameter(str, "Last known SSH host key"), + 'hostname': Parameter(str, "Fully qualified hostname", max = 255), + 'boot_state': Parameter(str, "Boot state", max = 20), + 'model': Parameter(str, "Make and model of the actual machine", max = 255), + 'boot_nonce': Parameter(str, "(Admin only) Random value generated by the node at last boot", max = 128), + 'version': Parameter(str, "Apparent Boot CD version", max = 64), + 'ssh_rsa_key': Parameter(str, "Last known SSH host key", max = 1024), 'date_created': Parameter(str, "Date and time when node entry was created"), 'deleted': Parameter(bool, "Has been deleted"), - 'key': Parameter(str, "(Admin only) Node key"), - 'session': Parameter(str, "(Admin only) Node session value"), + 'key': Parameter(str, "(Admin only) Node key", max = 256), + 'session': Parameter(str, "(Admin only) Node session value", max = 256), } # These fields are derived from join tables and are not actually diff --git a/PLC/Sites.py b/PLC/Sites.py index fadc5b6..f452f6c 100644 --- a/PLC/Sites.py +++ b/PLC/Sites.py @@ -20,13 +20,13 @@ class Site(Row): fields = { 'site_id': Parameter(int, "Site identifier"), - 'name': Parameter(str, "Full site name"), - 'abbreviated_name': Parameter(str, "Abbreviated site name"), - 'login_base': Parameter(str, "Site slice prefix"), + 'name': Parameter(str, "Full site name", max = 254), + '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"), - 'longitude': Parameter(float, "Decimal longitude of the site"), - 'url': Parameter(str, "URL of a page that describes the site"), + 'latitude': Parameter(float, "Decimal latitude of the site", min = -90.0, max = 90.0), + 'longitude': Parameter(float, "Decimal longitude of the site", min = -180.0, max = 180.0), + 'url': Parameter(str, "URL of a page that describes the site", max = 254), 'nodegroup_id': Parameter(int, "Identifier of the nodegroup containing the site's nodes"), 'organization_id': Parameter(int, "Organizational identifier if the site is part of a larger organization"), 'ext_consortium_id': Parameter(int, "Consortium identifier if the site is part of an external consortium"), @@ -65,9 +65,6 @@ class Site(Row): self.api = api def validate_login_base(self, login_base): - if len(login_base) > 20: - raise PLCInvalidArgument, "Login base must be <= 20 characters" - if not set(login_base).issubset(string.ascii_letters): raise PLCInvalidArgument, "Login base must consist only of ASCII letters" @@ -80,9 +77,6 @@ class Site(Row): return login_base def validate_latitude(self, latitude): - if latitude < -90.0 or latitude > 90.0: - raise PLCInvalidArgument, "Invalid latitude value" - if not self.has_key('longitude') or \ self['longitude'] is None: raise PLCInvalidArgument, "Longitude must also be specified" @@ -90,9 +84,6 @@ class Site(Row): return latitude def validate_longitude(self, longitude): - if longitude < -180.0 or longitude > 180.0: - raise PLCInvalidArgument, "Invalid longitude value" - if not self.has_key('latitude') or \ self['latitude'] is None: raise PLCInvalidArgument, "Latitude must also be specified"