Django

Code

Show
Ignore:
Timestamp:
07/03/08 10:24:08 (5 months ago)
Author:
brosner
Message:

newforms-admin: Merged from trunk up to [7829].

Files:

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  
    77"Report-Msgid-Bugs-To: \n" 
    88"POT-Creation-Date: 2007-03-14 01:38+0200\n" 
    9 "PO-Revision-Date: 2007-12-30 12:15+0200\n" 
     9"PO-Revision-Date: 2008-07-02 23:37+0200\n" 
    1010"Last-Translator: Can Burak Çilingir <canburak@cs.bilgi.edu.tr>\n" 
    1111"Language-Team: Turkish <bahadir@pardus.org.tr>\n" 
     
    24672467#~ msgid "Have you <a href=\"/password_reset/\">forgotten your password</a>?" 
    24682468#~ msgstr "<a href=\"/password_reset/\">Şifrenizi mi unuttunuz?</a>" 
     2469 
     2470#: contrib/auth/forms.py:107 
     2471#, python-format 
     2472msgid "Password reset on %s" 
     2473msgstr "%s sitesindeki hesabınızın parolasının sıfırlanması" 
  • django/branches/newforms-admin/django/contrib/auth/backends.py

    r7233 r7830  
     1try: 
     2    set 
     3except NameError: 
     4    from sets import Set as set # Python 2.3 fallback 
     5 
    16from django.db import connection 
    27from django.contrib.auth.models import User 
    38 
    4 try:  
    5     set  
    6 except NameError:  
    7     from sets import Set as set # Python 2.3 fallback 
    8          
     9 
    910class ModelBackend(object): 
    1011    """ 
    11     Authenticate against django.contrib.auth.models.User 
     12    Authenticates against django.contrib.auth.models.User. 
    1213    """ 
    1314    # TODO: Model, login attribute name and password attribute name should be 
     
    2223 
    2324    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        """ 
    2529        if not hasattr(user_obj, '_group_perm_cache'): 
    2630            cursor = connection.cursor() 
     
    5155            user_obj._group_perm_cache = set(["%s.%s" % (row[0], row[1]) for row in cursor.fetchall()]) 
    5256        return user_obj._group_perm_cache 
    53      
     57 
    5458    def get_all_permissions(self, user_obj): 
    5559        if not hasattr(user_obj, '_perm_cache'): 
     
    6266 
    6367    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 
    6575 
    6676    def get_user(self, user_id): 
  • django/branches/newforms-admin/django/core/files/uploadedfile.py

    r7815 r7830  
    1313class UploadedFile(object): 
    1414    """ 
    15     A abstract uploadded file (``TemporaryUploadedFile`` and 
     15    A abstract uploaded file (``TemporaryUploadedFile`` and 
    1616    ``InMemoryUploadedFile`` are the built-in concrete subclasses). 
    1717 
     
    140140    A file uploaded into memory (i.e. stream-to-memory). 
    141141    """ 
    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
    144144        self.file = file 
    145145        self.field_name = field_name 
  • django/branches/newforms-admin/django/core/files/uploadhandler.py

    r7815 r7830  
    141141    def file_complete(self, file_size): 
    142142        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        ) 
    146150 
    147151class MemoryFileUploadHandler(FileUploadHandler): 
     
    183187            return 
    184188 
    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        ) 
    187197 
    188198class TemporaryFile(object): 
  • django/branches/newforms-admin/django/core/paginator.py

    r7378 r7830  
    174174            try: 
    175175                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). 
    177180                self._count = len(self.object_list) 
    178181        return self._count 
  • django/branches/newforms-admin/django/test/client.py

    r7815 r7830  
    66except ImportError: 
    77    from StringIO import StringIO 
     8 
    89from django.conf import settings 
    910from django.contrib.auth import authenticate, login 
     
    2324MULTIPART_CONTENT = 'multipart/form-data; boundary=%s' % BOUNDARY 
    2425 
     26 
    2527class FakePayload(object): 
    2628    """ 
     
    4244        return content 
    4345 
     46 
    4447class ClientHandler(BaseHandler): 
    4548    """ 
     
    6265            response = self.get_response(request) 
    6366 
    64             # Apply response middleware 
     67            # Apply response middleware. 
    6568            for middleware_method in self._response_middleware: 
    6669                response = middleware_method(request, response) 
     
    7275 
    7376def 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    """ 
    7580    store.setdefault('template',[]).append(template) 
    7681    store.setdefault('context',[]).append(context) 
     
    7883def encode_multipart(boundary, data): 
    7984    """ 
    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. 
    8286 
    8387    The key will be used as the form data name; the value will be transmitted 
     
    9195            lines.extend([ 
    9296                '--' + 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))), 
    9499                'Content-Type: application/octet-stream', 
    95100                '', 
     
    145150    def store_exc_info(self, *args, **kwargs): 
    146151        """ 
    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. 
    149153        """ 
    150154        self.exc_info = sys.exc_info() 
    151155 
    152156    def _session(self): 
    153         "Obtain the current session variables" 
     157        """ 
     158        Obtains the current session variables. 
     159        """ 
    154160        if 'django.contrib.sessions' in settings.INSTALLED_APPS: 
    155161            engine = __import__(settings.SESSION_ENGINE, {}, {}, ['']) 
     
    167173        using the arguments to the request. 
    168174        """ 
    169  
    170175        environ = { 
    171176            'HTTP_COOKIE':      self.cookies, 
     
    181186        environ.update(request) 
    182187 
    183         # Curry a data dictionary into an instance of 
    184         # the template renderer callback function 
     188        # Curry a data dictionary into an instance of the template renderer 
     189        # callback function. 
    185190        data = {} 
    186191        on_template_render = curry(store_rendered_templates, data) 
    187192        dispatcher.connect(on_template_render, signal=signals.template_rendered) 
    188193 
    189         # Capture exceptions created by the handler 
     194        # Capture exceptions created by the handler. 
    190195        dispatcher.connect(self.store_exc_info, signal=got_request_exception) 
    191196 
     
    210215            self.exc_info = None 
    211216            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. 
    214219        response.client = self 
    215220        response.request = request 
    216221 
    217         # Add any rendered template detail to the response 
     222        # Add any rendered template detail to the response. 
    218223        # 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. 
    220225        for detail in ('template', 'context'): 
    221226            if data.get(detail): 
     
    227232                setattr(response, detail, None) 
    228233 
    229         # Update persistent cookie data 
     234        # Update persistent cookie data. 
    230235        if response.cookies: 
    231236            self.cookies.update(response.cookies) 
     
    234239 
    235240    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        """ 
    237244        r = { 
    238245            'CONTENT_LENGTH':  None, 
     
    247254 
    248255    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        """ 
    251259        if content_type is MULTIPART_CONTENT: 
    252260            post_data = encode_multipart(BOUNDARY, data) 
     
    266274 
    267275    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. 
    269278 
    270279        Returns True if login is possible; False if the provided credentials 
     
    273282        """ 
    274283        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: 
    276286            engine = __import__(settings.SESSION_ENGINE, {}, {}, ['']) 
    277287 
    278             # Create a fake request to store login details 
     288            # Create a fake request to store login details. 
    279289            request = HttpRequest() 
    280290            request.session = engine.SessionStore() 
    281291            login(request, user) 
    282292 
    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. 
    292306            request.session.save() 
    293307 
     
    297311 
    298312    def logout(self): 
    299         """Removes the authenticated user's cookies. 
     313        """ 
     314        Removes the authenticated user's cookies. 
    300315 
    301316        Causes the authenticated user to be logged out. 
  • django/branches/newforms-admin/docs/upload_handling.txt

    r7815 r7830  
    88handles a file upload, the file data ends up placed in ``request.FILES`` (for 
    99more 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, 
     10objects`_). This document explains how files are stored on disk and in memory, 
    1111and how to customize the default behavior. 
    1212 
     
    7373        larger than 2.5 megabytes, but that's configurable; see below. 
    7474     
    75     ``UploadedFile.chunks()`` 
     75    ``UploadedFile.chunk()`` 
    7676        A generator returning chunks of the file. If ``multiple_chunks()`` is 
    7777        ``True``, you should use this method in a loop instead of ``read()``. 
     
    300300        smallest chunk size defined by any handler. 
    301301 
    302         The default is 64*2\ :sup:`10` bytes, or 64 Kb
     302        The default is 64*2\ :sup:`10` bytes, or 64 KB
    303303 
    304304    ``FileUploadHandler.new_file(self, field_name, file_name, content_type, content_length, charset)`` 
     
    326326        Callback signaling that the entire upload (all files) has completed. 
    327327 
    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)`` 
    329329        Allows the handler to completely override the parsing of the raw 
    330330        HTTP input. 
  • django/branches/newforms-admin/tests/modeltests/pagination/models.py

    r7351 r7830  
    201201[1] 
    202202 
     203# ObjectPaginator can be passed lists too. 
     204>>> paginator = ObjectPaginator([1, 2, 3], 5) 
     205>>> paginator.hits 
     2063 
     207>>> paginator.pages 
     2081 
     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 
     21942 
     220>>> paginator.pages 
     2215 
     222>>> paginator.page_range 
     223[1, 2, 3, 4, 5] 
     224 
     225 
    203226################## 
    204227# Orphan support # 
  • django/branches/newforms-admin/tests/regressiontests/select_related_regress/models.py

    r7809 r7830  
    1616class Port(models.Model): 
    1717    device = models.ForeignKey('Device') 
    18     number = models.CharField(max_length=10) 
     18    port_number = models.CharField(max_length=10) 
    1919 
    2020    def __unicode__(self): 
    21         return u"%s/%s" % (self.device.name, self.number) 
     21        return u"%s/%s" % (self.device.name, self.port_number) 
    2222 
    2323class Connection(models.Model): 
     
    3939>>> dev2=Device.objects.create(name="switch", building=b) 
    4040>>> 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) 
    4444>>> c1=Connection.objects.create(start=port1, end=port2) 
    4545>>> c2=Connection.objects.create(start=port2, end=port3)