Changeset 7830
- Timestamp:
- 07/03/08 10:24:08 (5 months ago)
- Files:
-
- django/branches/newforms-admin (modified) (1 prop)
- django/branches/newforms-admin/django/conf/locale/tr/LC_MESSAGES/django.mo (modified) (previous)
- django/branches/newforms-admin/django/conf/locale/tr/LC_MESSAGES/django.po (modified) (2 diffs)
- django/branches/newforms-admin/django/contrib/auth/backends.py (modified) (4 diffs)
- django/branches/newforms-admin/django/core/files/uploadedfile.py (modified) (2 diffs)
- django/branches/newforms-admin/django/core/files/uploadhandler.py (modified) (2 diffs)
- django/branches/newforms-admin/django/core/paginator.py (modified) (1 diff)
- django/branches/newforms-admin/django/test/client.py (modified) (17 diffs)
- django/branches/newforms-admin/docs/upload_handling.txt (modified) (4 diffs)
- django/branches/newforms-admin/tests/modeltests/pagination/models.py (modified) (1 diff)
- django/branches/newforms-admin/tests/regressiontests/select_related_regress/models.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/newforms-admin
- Property svnmerge-integrated changed from /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6390,6392-7814 to /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-6390,6392-7829
django/branches/newforms-admin/django/conf/locale/tr/LC_MESSAGES/django.po
r7351 r7830 7 7 "Report-Msgid-Bugs-To: \n" 8 8 "POT-Creation-Date: 2007-03-14 01:38+0200\n" 9 "PO-Revision-Date: 200 7-12-30 12:15+0200\n"9 "PO-Revision-Date: 2008-07-02 23:37+0200\n" 10 10 "Last-Translator: Can Burak Çilingir <canburak@cs.bilgi.edu.tr>\n" 11 11 "Language-Team: Turkish <bahadir@pardus.org.tr>\n" … … 2467 2467 #~ msgid "Have you <a href=\"/password_reset/\">forgotten your password</a>?" 2468 2468 #~ msgstr "<a href=\"/password_reset/\">Şifrenizi mi unuttunuz?</a>" 2469 2470 #: contrib/auth/forms.py:107 2471 #, python-format 2472 msgid "Password reset on %s" 2473 msgstr "%s sitesindeki hesabınızın parolasının sıfırlanması" django/branches/newforms-admin/django/contrib/auth/backends.py
r7233 r7830 1 try: 2 set 3 except NameError: 4 from sets import Set as set # Python 2.3 fallback 5 1 6 from django.db import connection 2 7 from django.contrib.auth.models import User 3 8 4 try: 5 set 6 except NameError: 7 from sets import Set as set # Python 2.3 fallback 8 9 9 10 class ModelBackend(object): 10 11 """ 11 Authenticate against django.contrib.auth.models.User12 Authenticates against django.contrib.auth.models.User. 12 13 """ 13 14 # TODO: Model, login attribute name and password attribute name should be … … 22 23 23 24 def get_group_permissions(self, user_obj): 24 "Returns a list of permission strings that this user has through his/her groups." 25 """ 26 Returns a set of permission strings that this user has through his/her 27 groups. 28 """ 25 29 if not hasattr(user_obj, '_group_perm_cache'): 26 30 cursor = connection.cursor() … … 51 55 user_obj._group_perm_cache = set(["%s.%s" % (row[0], row[1]) for row in cursor.fetchall()]) 52 56 return user_obj._group_perm_cache 53 57 54 58 def get_all_permissions(self, user_obj): 55 59 if not hasattr(user_obj, '_perm_cache'): … … 62 66 63 67 def has_module_perms(self, user_obj, app_label): 64 return bool(len([p for p in self.get_all_permissions(user_obj) if p[:p.index('.')] == app_label])) 68 """ 69 Returns True if user_obj has any permissions in the given app_label. 70 """ 71 for perm in self.get_all_permissions(user_obj): 72 if perm[:perm.index('.')] == app_label: 73 return True 74 return False 65 75 66 76 def get_user(self, user_id): django/branches/newforms-admin/django/core/files/uploadedfile.py
r7815 r7830 13 13 class UploadedFile(object): 14 14 """ 15 A abstract upload ded file (``TemporaryUploadedFile`` and15 A abstract uploaded file (``TemporaryUploadedFile`` and 16 16 ``InMemoryUploadedFile`` are the built-in concrete subclasses). 17 17 … … 140 140 A file uploaded into memory (i.e. stream-to-memory). 141 141 """ 142 def __init__(self, file, field_name, file_name, content_type, charset, file_size):143 super(InMemoryUploadedFile, self).__init__(file_name, content_type, charset, file_size)142 def __init__(self, file, field_name, file_name, content_type, file_size, charset): 143 super(InMemoryUploadedFile, self).__init__(file_name, content_type, file_size, charset) 144 144 self.file = file 145 145 self.field_name = field_name django/branches/newforms-admin/django/core/files/uploadhandler.py
r7815 r7830 141 141 def file_complete(self, file_size): 142 142 self.file.seek(0) 143 return TemporaryUploadedFile(self.file, self.file_name, 144 self.content_type, file_size, 145 self.charset) 143 return TemporaryUploadedFile( 144 file = self.file, 145 file_name = self.file_name, 146 content_type = self.content_type, 147 file_size = file_size, 148 charset = self.charset 149 ) 146 150 147 151 class MemoryFileUploadHandler(FileUploadHandler): … … 183 187 return 184 188 185 return InMemoryUploadedFile(self.file, self.field_name, self.file_name, 186 self.content_type, self.charset, file_size) 189 return InMemoryUploadedFile( 190 file = self.file, 191 field_name = self.field_name, 192 file_name = self.file_name, 193 content_type = self.content_type, 194 file_size = file_size, 195 charset = self.charset 196 ) 187 197 188 198 class TemporaryFile(object): django/branches/newforms-admin/django/core/paginator.py
r7378 r7830 174 174 try: 175 175 self._count = self.object_list.count() 176 except TypeError: 176 except (AttributeError, TypeError): 177 # AttributeError if object_list has no count() method. 178 # TypeError if object_list.count() requires arguments 179 # (i.e. is of type list). 177 180 self._count = len(self.object_list) 178 181 return self._count django/branches/newforms-admin/django/test/client.py
r7815 r7830 6 6 except ImportError: 7 7 from StringIO import StringIO 8 8 9 from django.conf import settings 9 10 from django.contrib.auth import authenticate, login … … 23 24 MULTIPART_CONTENT = 'multipart/form-data; boundary=%s' % BOUNDARY 24 25 26 25 27 class FakePayload(object): 26 28 """ … … 42 44 return content 43 45 46 44 47 class ClientHandler(BaseHandler): 45 48 """ … … 62 65 response = self.get_response(request) 63 66 64 # Apply response middleware 67 # Apply response middleware. 65 68 for middleware_method in self._response_middleware: 66 69 response = middleware_method(request, response) … … 72 75 73 76 def store_rendered_templates(store, signal, sender, template, context): 74 "A utility function for storing templates and contexts that are rendered" 77 """ 78 Stores templates and contexts that are rendered. 79 """ 75 80 store.setdefault('template',[]).append(template) 76 81 store.setdefault('context',[]).append(context) … … 78 83 def encode_multipart(boundary, data): 79 84 """ 80 A simple method for encoding multipart POST data from a dictionary of 81 form values. 85 Encodes multipart POST data from a dictionary of form values. 82 86 83 87 The key will be used as the form data name; the value will be transmitted … … 91 95 lines.extend([ 92 96 '--' + boundary, 93 'Content-Disposition: form-data; name="%s"; filename="%s"' % (to_str(key), to_str(os.path.basename(value.name))), 97 'Content-Disposition: form-data; name="%s"; filename="%s"' \ 98 % (to_str(key), to_str(os.path.basename(value.name))), 94 99 'Content-Type: application/octet-stream', 95 100 '', … … 145 150 def store_exc_info(self, *args, **kwargs): 146 151 """ 147 Utility method that can be used to store exceptions when they are 148 generated by a view. 152 Stores exceptions when they are generated by a view. 149 153 """ 150 154 self.exc_info = sys.exc_info() 151 155 152 156 def _session(self): 153 "Obtain the current session variables" 157 """ 158 Obtains the current session variables. 159 """ 154 160 if 'django.contrib.sessions' in settings.INSTALLED_APPS: 155 161 engine = __import__(settings.SESSION_ENGINE, {}, {}, ['']) … … 167 173 using the arguments to the request. 168 174 """ 169 170 175 environ = { 171 176 'HTTP_COOKIE': self.cookies, … … 181 186 environ.update(request) 182 187 183 # Curry a data dictionary into an instance of 184 # the template renderer callback function188 # Curry a data dictionary into an instance of the template renderer 189 # callback function. 185 190 data = {} 186 191 on_template_render = curry(store_rendered_templates, data) 187 192 dispatcher.connect(on_template_render, signal=signals.template_rendered) 188 193 189 # Capture exceptions created by the handler 194 # Capture exceptions created by the handler. 190 195 dispatcher.connect(self.store_exc_info, signal=got_request_exception) 191 196 … … 210 215 self.exc_info = None 211 216 raise exc_info[1], None, exc_info[2] 212 213 # Save the client and request that stimulated the response 217 218 # Save the client and request that stimulated the response. 214 219 response.client = self 215 220 response.request = request 216 221 217 # Add any rendered template detail to the response 222 # Add any rendered template detail to the response. 218 223 # If there was only one template rendered (the most likely case), 219 # flatten the list to a single element 224 # flatten the list to a single element. 220 225 for detail in ('template', 'context'): 221 226 if data.get(detail): … … 227 232 setattr(response, detail, None) 228 233 229 # Update persistent cookie data 234 # Update persistent cookie data. 230 235 if response.cookies: 231 236 self.cookies.update(response.cookies) … … 234 239 235 240 def get(self, path, data={}, **extra): 236 "Request a response from the server using GET." 241 """ 242 Requests a response from the server using GET. 243 """ 237 244 r = { 238 245 'CONTENT_LENGTH': None, … … 247 254 248 255 def post(self, path, data={}, content_type=MULTIPART_CONTENT, **extra): 249 "Request a response from the server using POST." 250 256 """ 257 Requests a response from the server using POST. 258 """ 251 259 if content_type is MULTIPART_CONTENT: 252 260 post_data = encode_multipart(BOUNDARY, data) … … 266 274 267 275 def login(self, **credentials): 268 """Set the Client to appear as if it has sucessfully logged into a site. 276 """ 277 Sets the Client to appear as if it has successfully logged into a site. 269 278 270 279 Returns True if login is possible; False if the provided credentials … … 273 282 """ 274 283 user = authenticate(**credentials) 275 if user and user.is_active and 'django.contrib.sessions' in settings.INSTALLED_APPS: 284 if user and user.is_active \ 285 and 'django.contrib.sessions' in settings.INSTALLED_APPS: 276 286 engine = __import__(settings.SESSION_ENGINE, {}, {}, ['']) 277 287 278 # Create a fake request to store login details 288 # Create a fake request to store login details. 279 289 request = HttpRequest() 280 290 request.session = engine.SessionStore() 281 291 login(request, user) 282 292 283 # Set the cookie to represent the session 284 self.cookies[settings.SESSION_COOKIE_NAME] = request.session.session_key 285 self.cookies[settings.SESSION_COOKIE_NAME]['max-age'] = None 286 self.cookies[settings.SESSION_COOKIE_NAME]['path'] = '/' 287 self.cookies[settings.SESSION_COOKIE_NAME]['domain'] = settings.SESSION_COOKIE_DOMAIN 288 self.cookies[settings.SESSION_COOKIE_NAME]['secure'] = settings.SESSION_COOKIE_SECURE or None 289 self.cookies[settings.SESSION_COOKIE_NAME]['expires'] = None 290 291 # Save the session values 293 # Set the cookie to represent the session. 294 session_cookie = settings.SESSION_COOKIE_NAME 295 self.cookies[session_cookie] = request.session.session_key 296 cookie_data = { 297 'max-age': None, 298 'path': '/', 299 'domain': settings.SESSION_COOKIE_DOMAIN, 300 'secure': settings.SESSION_COOKIE_SECURE or None, 301 'expires': None, 302 } 303 self.cookies[session_cookie].update(cookie_data) 304 305 # Save the session values. 292 306 request.session.save() 293 307 … … 297 311 298 312 def logout(self): 299 """Removes the authenticated user's cookies. 313 """ 314 Removes the authenticated user's cookies. 300 315 301 316 Causes the authenticated user to be logged out. django/branches/newforms-admin/docs/upload_handling.txt
r7815 r7830 8 8 handles a file upload, the file data ends up placed in ``request.FILES`` (for 9 9 more on the ``request`` object see the documentation for `request and response 10 objects`_). This document explains how files are stored on disk an in memory,10 objects`_). This document explains how files are stored on disk and in memory, 11 11 and how to customize the default behavior. 12 12 … … 73 73 larger than 2.5 megabytes, but that's configurable; see below. 74 74 75 ``UploadedFile.chunk s()``75 ``UploadedFile.chunk()`` 76 76 A generator returning chunks of the file. If ``multiple_chunks()`` is 77 77 ``True``, you should use this method in a loop instead of ``read()``. … … 300 300 smallest chunk size defined by any handler. 301 301 302 The default is 64*2\ :sup:`10` bytes, or 64 K b.302 The default is 64*2\ :sup:`10` bytes, or 64 KB. 303 303 304 304 ``FileUploadHandler.new_file(self, field_name, file_name, content_type, content_length, charset)`` … … 326 326 Callback signaling that the entire upload (all files) has completed. 327 327 328 ``FileUploadHandler. ``handle_raw_input(self, input_data, META, content_length, boundary, encoding)``328 ``FileUploadHandler.handle_raw_input(self, input_data, META, content_length, boundary, encoding)`` 329 329 Allows the handler to completely override the parsing of the raw 330 330 HTTP input. django/branches/newforms-admin/tests/modeltests/pagination/models.py
r7351 r7830 201 201 [1] 202 202 203 # ObjectPaginator can be passed lists too. 204 >>> paginator = ObjectPaginator([1, 2, 3], 5) 205 >>> paginator.hits 206 3 207 >>> paginator.pages 208 1 209 >>> paginator.page_range 210 [1] 211 212 213 # ObjectPaginator can be passed other objects with a count() method. 214 >>> class Container: 215 ... def __len__(self): 216 ... return 42 217 >>> paginator = ObjectPaginator(Container(), 10) 218 >>> paginator.hits 219 42 220 >>> paginator.pages 221 5 222 >>> paginator.page_range 223 [1, 2, 3, 4, 5] 224 225 203 226 ################## 204 227 # Orphan support # django/branches/newforms-admin/tests/regressiontests/select_related_regress/models.py
r7809 r7830 16 16 class Port(models.Model): 17 17 device = models.ForeignKey('Device') 18 number = models.CharField(max_length=10)18 port_number = models.CharField(max_length=10) 19 19 20 20 def __unicode__(self): 21 return u"%s/%s" % (self.device.name, self. number)21 return u"%s/%s" % (self.device.name, self.port_number) 22 22 23 23 class Connection(models.Model): … … 39 39 >>> dev2=Device.objects.create(name="switch", building=b) 40 40 >>> dev3=Device.objects.create(name="server", building=b) 41 >>> port1=Port.objects.create( number='4',device=dev1)42 >>> port2=Port.objects.create( number='7',device=dev2)43 >>> port3=Port.objects.create( number='1',device=dev3)41 >>> port1=Port.objects.create(port_number='4',device=dev1) 42 >>> port2=Port.objects.create(port_number='7',device=dev2) 43 >>> port3=Port.objects.create(port_number='1',device=dev3) 44 44 >>> c1=Connection.objects.create(start=port1, end=port2) 45 45 >>> c2=Connection.objects.create(start=port2, end=port3)
