@@ -84,15 +84,18 @@ def __init__(self, value):
84
84
self .port = self .scheme == "https" and 443 or 80
85
85
self .public_key = parts .username
86
86
if not self .public_key :
87
- raise BadDsn ("Missig public key" )
87
+ raise BadDsn ("Missing public key" )
88
88
self .secret_key = parts .password
89
- if not parts .path :
90
- raise BadDsn ("Missing project ID in DSN" )
89
+
90
+ path = parts .path .rsplit ("/" , 1 )
91
+
91
92
try :
92
- self .project_id = text_type (int (parts . path [ 1 :] ))
93
+ self .project_id = text_type (int (path . pop () ))
93
94
except (ValueError , TypeError ):
94
95
raise BadDsn ("Invalid project in DSN (%r)" % (parts .path or "" )[1 :])
95
96
97
+ self .path = "/" .join (path ) + "/"
98
+
96
99
@property
97
100
def netloc (self ):
98
101
"""The netloc part of a DSN."""
@@ -106,18 +109,20 @@ def to_auth(self, client=None):
106
109
return Auth (
107
110
scheme = self .scheme ,
108
111
host = self .netloc ,
112
+ path = self .path ,
109
113
project_id = self .project_id ,
110
114
public_key = self .public_key ,
111
115
secret_key = self .secret_key ,
112
116
client = client ,
113
117
)
114
118
115
119
def __str__ (self ):
116
- return "%s://%s%s@%s/ %s" % (
120
+ return "%s://%s%s@%s%s %s" % (
117
121
self .scheme ,
118
122
self .public_key ,
119
123
self .secret_key and "@" + self .secret_key or "" ,
120
124
self .netloc ,
125
+ self .path ,
121
126
self .project_id ,
122
127
)
123
128
@@ -129,6 +134,7 @@ def __init__(
129
134
self ,
130
135
scheme ,
131
136
host ,
137
+ path ,
132
138
project_id ,
133
139
public_key ,
134
140
secret_key = None ,
@@ -137,6 +143,7 @@ def __init__(
137
143
):
138
144
self .scheme = scheme
139
145
self .host = host
146
+ self .path = path
140
147
self .project_id = project_id
141
148
self .public_key = public_key
142
149
self .secret_key = secret_key
@@ -146,7 +153,12 @@ def __init__(
146
153
@property
147
154
def store_api_url (self ):
148
155
"""Returns the API url for storing events."""
149
- return "%s://%s/api/%s/store/" % (self .scheme , self .host , self .project_id )
156
+ return "%s://%s%sapi/%s/store/" % (
157
+ self .scheme ,
158
+ self .host ,
159
+ self .path ,
160
+ self .project_id ,
161
+ )
150
162
151
163
def to_header (self , timestamp = None ):
152
164
"""Returns the auth header a string."""
0 commit comments