HTD

Merge lp:~simon-d-bull/htd/3.1.fix_parameter_type_checks into lp:htd/3.1

Proposed by Simon Bull
Status: Merged
Approved by: Andrew Hayzen
Approved revision: 20
Merged at revision: 20
Proposed branch: lp:~simon-d-bull/htd/3.1.fix_parameter_type_checks
Merge into: lp:htd/3.1
Diff against target: 61 lines (+18/-7)
2 files modified
htd31/__init__.py (+14/-7)
htd31/_objects/connection.py (+4/-0)
To merge this branch: bzr merge lp:~simon-d-bull/htd/3.1.fix_parameter_type_checks
Reviewer Review Type Date Requested Status
Andrew Hayzen Approve
Review via email: mp+126510@code.launchpad.net

Description of the change

Parameter type check improvements. Fixes bug 1036377 and bug 1036395.

To post a comment you must log in.
Revision history for this message
Andrew Hayzen (ahayzen) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'htd31/__init__.py'
2--- htd31/__init__.py 2012-09-22 17:18:43 +0000
3+++ htd31/__init__.py 2012-09-26 17:14:20 +0000
4@@ -165,13 +165,24 @@
5
6
7 @_base.trace.trace
8-def create(location, identifier=None, attributes={}, users=None,
9- login_user=None, htd_file=None):
10+def create(location, identifier=None, attributes={}, users={}, login_user=None,
11+ htd_file=None):
12 """
13 Create a new HTD File
14 To create a table parse the identifier for the table otherwise leave
15 the identifier blank to create a db
16 """
17+ # Confirm location is str
18+ if not isinstance(location, str):
19+ raise ValueError("location (%s) must be a str object." % location)
20+
21+ # Confirm attributes is dict
22+ if not isinstance(attributes, dict):
23+ raise ValueError("attributes (%s) must be a dict object." % attributes)
24+
25+ # Confirm users is dict
26+ if not isinstance(users, dict):
27+ raise ValueError("users (%s) must be a dict object." % users)
28
29 # Check for identifier
30 if identifier is not None:
31@@ -213,14 +224,10 @@
32
33 # Load guest account if needed
34 guest = False
35- if users is None or len(users) == 0:
36+ if len(users) == 0:
37 users = {"guest": User(None)}
38 guest = True
39
40- # Confirm users is dict
41- if not isinstance(users, dict):
42- raise ValueError("users (%s) must be a dict object." % users)
43-
44 # Confirm users are valid
45 acc = False
46
47
48=== modified file 'htd31/_objects/connection.py'
49--- htd31/_objects/connection.py 2012-09-21 13:24:18 +0000
50+++ htd31/_objects/connection.py 2012-09-26 17:14:20 +0000
51@@ -39,6 +39,10 @@
52 self.alive = True
53 self._children = []
54
55+ # Confirm location is str
56+ if not isinstance(location, str):
57+ raise ValueError("location (%s) must be a str object." % location)
58+
59 # Load user
60 if user is None:
61 user = Authenticate("guest", None)

Subscribers

People subscribed via source and target branches

to all changes: