Django

Code

Changeset 7533

Show
Ignore:
Timestamp:
05/14/08 00:48:44 (2 months ago)
Author:
brosner
Message:

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

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-7499 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-7532
  • django/branches/newforms-admin/django/db/backends/oracle/query.py

    r7479 r7533  
    11""" 
    2 Custom Query class for this backend (a derivative of 
    3 django.db.models.sql.query.Query). 
     2Custom Query class for Oracle. 
     3Derives from: django.db.models.sql.query.Query 
    44""" 
    55 
     
    1313def query_class(QueryClass, Database): 
    1414    """ 
    15     Returns a custom djang.db.models.sql.query.Query subclass that is 
    16     appropraite for Oracle. 
     15    Returns a custom django.db.models.sql.query.Query subclass that is 
     16    appropriate for Oracle. 
    1717 
    1818    The 'Database' module (cx_Oracle) is passed in here so that all the setup 
  • django/branches/newforms-admin/django/db/models/base.py

    r7479 r7533  
    235235        dispatcher.send(signal=signals.post_init, sender=self.__class__, instance=self) 
    236236 
    237     def from_sequence(cls, values): 
    238         """ 
    239         An alternate class constructor, primarily for internal use. 
    240  
    241         Creates a model instance from a sequence of values (which corresponds 
    242         to all the non-many-to-many fields in creation order. If there are more 
    243         fields than values, the remaining (final) fields are given their 
    244         default values. 
    245  
    246         ForeignKey fields can only be initialised using id values, not 
    247         instances, in this method. 
    248         """ 
    249         dispatcher.send(signal=signals.pre_init, sender=cls, args=values, 
    250                 kwargs={}) 
    251         obj = Empty() 
    252         obj.__class__ = cls 
    253         field_iter = iter(obj._meta.fields) 
    254         for val, field in izip(values, field_iter): 
    255             setattr(obj, field.attname, val) 
    256         for field in field_iter: 
    257             setattr(obj, field.attname, field.get_default()) 
    258         dispatcher.send(signal=signals.post_init, sender=cls, instance=obj) 
    259         return obj 
    260  
    261     from_sequence = classmethod(from_sequence) 
    262  
    263237    def __repr__(self): 
    264238        return smart_str(u'<%s: %s>' % (self.__class__.__name__, unicode(self))) 
     
    362336            dispatcher.send(signal=signals.post_save, sender=self.__class__, 
    363337                    instance=self, created=(not record_exists), raw=raw) 
     338 
     339    save_base.alters_data = True 
    364340 
    365341    def validate(self): 
  • django/branches/newforms-admin/django/db/models/query.py

    r7500 r7533  
    165165                        max_depth, requested=requested) 
    166166            else: 
    167                 obj = self.model.from_sequence(row[index_start:]) 
     167                obj = self.model(*row[index_start:]) 
    168168            for i, k in enumerate(extra_select): 
    169169                setattr(obj, k, row[i]) 
     
    656656    restricted = requested is not None 
    657657    index_end = index_start + len(klass._meta.fields) 
    658     obj = klass.from_sequence(row[index_start:index_end]) 
     658    obj = klass(*row[index_start:index_end]) 
    659659    for f in klass._meta.fields: 
    660660        if (not f.rel or (not restricted and f.null) or 
  • django/branches/newforms-admin/django/db/models/sql/query.py

    r7500 r7533  
    395395        """ 
    396396        qn = self.quote_name_unless_alias 
    397         result = ['(%s) AS %s' % (col, alias) for alias, col in self.extra_select.iteritems()] 
     397        qn2 = self.connection.ops.quote_name 
     398        result = ['(%s) AS %s' % (col, qn2(alias)) for alias, col in self.extra_select.iteritems()] 
    398399        aliases = set(self.extra_select.keys()) 
    399400        if with_aliases: 
  • django/branches/newforms-admin/django/db/models/sql/where.py

    r7479 r7533  
    5252                elif isinstance(child, tree.Node): 
    5353                    sql, params = self.as_sql(child, qn) 
    54                     if len(child.children) == 1: 
     54                    if child.negated: 
     55                        format = 'NOT (%s)' 
     56                    elif len(child.children) == 1: 
    5557                        format = '%s' 
    5658                    else: 
    5759                        format = '(%s)' 
    58                     if child.negated: 
    59                         format = 'NOT %s' % format 
    6060                else: 
    6161                    sql, params = self.make_atom(child, qn) 
  • django/branches/newforms-admin/docs/request_response.txt

    r7378 r7533  
    403403      object. Doing so will raise ``Exception``. 
    404404 
     405Setting headers 
     406~~~~~~~~~~~~~~~ 
     407 
     408To set a header in your response, just treat it like a dictionary:: 
     409 
     410    >>> response = HttpResponse() 
     411    >>> response['Pragma'] = 'no-cache' 
     412 
     413Telling the browser to treat the response as a file attachment 
     414~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     415 
     416To tell the browser to treat the response as a file attachment, use the 
     417``mimetype`` argument and set the ``Content-Disposition`` header. For example, 
     418this is how you might return a Microsoft Excel spreadsheet:: 
     419 
     420    >>> response = HttpResponse(my_data, mimetype='application/vnd.ms-excel') 
     421    >>> response['Content-Disposition'] = 'attachment; filename=foo.xls' 
     422 
     423There's nothing Django-specific about the ``Content-Disposition`` header, but 
     424it's easy to forget the syntax, so we've included it here. 
     425 
    405426Methods 
    406427------- 
     
    421442    header, it can also include the character set encoding, which makes it 
    422443    more than just a MIME type specification. If ``mimetype`` is specified 
    423     (not None), that value is used. Otherwise, ``content_type`` is used. If 
     444    (not ``None``), that value is used. Otherwise, ``content_type`` is used. If 
    424445    neither is given, the ``DEFAULT_CONTENT_TYPE`` setting is used. 
    425446 
  • django/branches/newforms-admin/tests/modeltests/basic/models.py

    r7479 r7533  
    399399>>> Article.objects.get(headline='Article 11') in s 
    400400True 
     401 
     402# The 'select' argument to extra() supports names with dashes in them, as long 
     403# as you use values(). 
     404>>> Article.objects.filter(pub_date__year=2008).extra(select={'dashed-value': '1'}).values('headline', 'dashed-value') 
     405[{'headline': u'Article 11', 'dashed-value': 1}, {'headline': u'Article 12', 'dashed-value': 1}] 
     406 
     407# If you use 'select' with extra() and names containing dashes on a query 
     408# that's *not* a values() query, those extra 'select' values will silently be 
     409# ignored. 
     410>>> articles = Article.objects.filter(pub_date__year=2008).extra(select={'dashed-value': '1', 'undashedvalue': '2'}) 
     411>>> articles[0].undashedvalue 
     4122 
    401413""" 
  • django/branches/newforms-admin/tests/regressiontests/queries/models.py

    r7500 r7533  
    121121class CustomManager(models.Manager): 
    122122    def get_query_set(self): 
    123         return super(CustomManager, self).get_query_set().filter(public=True, 
    124                 tag__name='t1') 
     123        qs = super(CustomManager, self).get_query_set() 
     124        return qs.filter(is_public=True, tag__name='t1') 
    125125 
    126126class ManagedModel(models.Model): 
    127127    data = models.CharField(max_length=10) 
    128128    tag = models.ForeignKey(Tag) 
    129     public = models.BooleanField(default=True) 
     129    is_public = models.BooleanField(default=True) 
    130130 
    131131    objects = CustomManager() 
     
    699699Updates that are filtered on the model being updated are somewhat tricky to get 
    700700in MySQL. This exercises that case. 
    701 >>> mm = ManagedModel.objects.create(data='mm1', tag=t1, public=True) 
     701>>> mm = ManagedModel.objects.create(data='mm1', tag=t1, is_public=True) 
    702702>>> ManagedModel.objects.update(data='mm') 
    703703