Django

Code

Changeset 1235

Show
Ignore:
Timestamp:
11/14/05 19:36:12 (3 years ago)
Author:
rjwittams
Message:

Merged to trunk r1234

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/new-admin/django/bin/daily_cleanup.py

    r518 r1235  
    88    # Clean up old database records 
    99    cursor = db.cursor() 
    10     cursor.execute("DELETE FROM core_sessions WHERE expire_date < NOW()") 
    11     cursor.execute("DELETE FROM registration_challenges WHERE request_date < NOW() - INTERVAL '1 week'") 
     10    cursor.execute("DELETE FROM %s WHERE %s < NOW()" % \ 
     11        (db.quote_name('core_sessions'), db.quote_name('expire_date'))) 
     12    cursor.execute("DELETE FROM %s WHERE %s < NOW() - INTERVAL '1 week'" % \ 
     13        (db.quote_name('registration_challenges'), db.quote_name('request_date'))) 
    1214    db.commit() 
    1315 
  • django/branches/new-admin/django/conf/locale/cs/LC_MESSAGES/django.po

    r1223 r1235  
    1515"Content-Type: text/plain; charset=utf-8\n" 
    1616"Content-Transfer-Encoding: 8bit\n" 
    17 "Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%" 
    18 "10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" 
     17"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" 
    1918"X-Poedit-Language: Czech\n" 
    2019"X-Poedit-Country: CZECH REPUBLIC\n" 
     
    264263 
    265264#: contrib/admin/templates/admin/500.html:10 
    266 msgid "" 
    267 "There's been an error. It's been reported to the site administrators via e-" 
    268 "mail and should be fixed shortly. Thanks for your patience." 
    269 msgstr "" 
    270 "Nastala chyba. Ta byla oznámena administrátorovi serveru pomocí e-mailu a " 
    271 "měla by být brzy odstraněna. Děkujeme za trpělivost." 
     265msgid "There's been an error. It's been reported to the site administrators via e-mail and should be fixed shortly. Thanks for your patience." 
     266msgstr "Nastala chyba. Ta byla oznámena administrátorovi serveru pomocí e-mailu a měla by být brzy odstraněna. Děkujeme za trpělivost." 
    272267 
    273268#: contrib/admin/templates/admin/404.html:4 
     
    360355#: contrib/admin/templates/admin/delete_confirmation.html:7 
    361356#, fuzzy, python-format 
    362 msgid "" 
    363 "Deleting the %(object_name)s '%(object)s' would result in deleting related " 
    364 "objects, but your account doesn't have permission to delete the following " 
    365 "types of objects:" 
    366 msgstr "" 
    367 "Mazání %(object_name)s  '%(object)s' by vyústilo ve vymazání souvisejících " 
    368 "objektů, ale Váš účet nemá oprávnění pro mazání následujících typů objektů:" 
     357msgid "Deleting the %(object_name)s '%(object)s' would result in deleting related objects, but your account doesn't have permission to delete the following types of objects:" 
     358msgstr "Mazání %(object_name)s  '%(object)s' by vyústilo ve vymazání souvisejících objektů, ale Váš účet nemá oprávnění pro mazání následujících typů objektů:" 
    369359 
    370360#: contrib/admin/templates/admin/change_form.html:20 
     
    409399#: contrib/admin/templates/admin/delete_confirmation.html:14 
    410400#, python-format 
    411 msgid "" 
    412 "Are you sure you want to delete the %(object_name)s \"%(object)s\"? All of " 
    413 "the following related items will be deleted:" 
    414 msgstr "" 
    415 "Jste si jist(á), že chcete smazat %(object_name)s \"%(object)s\"? Všechny " 
    416 "následující související položky budou smazány:" 
     401msgid "Are you sure you want to delete the %(object_name)s \"%(object)s\"? All of the following related items will be deleted:" 
     402msgstr "Jste si jist(á), že chcete smazat %(object_name)s \"%(object)s\"? Všechny následující související položky budou smazány:" 
    417403 
    418404#: contrib/admin/templates/admin/delete_confirmation.html:18 
     
    443429 
    444430#: contrib/admin/templates/registration/password_reset_form.html:12 
    445 msgid "" 
    446 "Forgotten your password? Enter your e-mail address below, and we'll reset " 
    447 "your password and e-mail the new one to you." 
    448 msgstr "" 
    449 "Zapomněl(a) jste heslo? Vložte níže Vaši e-mailovou adresu a my Vaše heslo " 
    450 "obnovíme a zašleme Vám e-mailem nové." 
     431msgid "Forgotten your password? Enter your e-mail address below, and we'll reset your password and e-mail the new one to you." 
     432msgstr "Zapomněl(a) jste heslo? Vložte níže Vaši e-mailovou adresu a my Vaše heslo obnovíme a zašleme Vám e-mailem nové." 
    451433 
    452434#: contrib/admin/templates/registration/password_reset_form.html:16 
     
    472454 
    473455#: contrib/admin/templates/registration/password_reset_done.html:12 
    474 msgid "" 
    475 "We've e-mailed a new password to the e-mail address you submitted. You " 
    476 "should be receiving it shortly." 
    477 msgstr "" 
    478 "Poslali jsme Vám e-mailem nové heslo na adresu, kterou jste zadal(a). Měl(a) " 
    479 "byste ji dostat během okamžiku." 
     456msgid "We've e-mailed a new password to the e-mail address you submitted. You should be receiving it shortly." 
     457msgstr "Poslali jsme Vám e-mailem nové heslo na adresu, kterou jste zadal(a). Měl(a) byste ji dostat během okamžiku." 
    480458 
    481459#: contrib/admin/templates/registration/password_change_form.html:12 
    482 msgid "" 
    483 "Please enter your old password, for security's sake, and then enter your new " 
    484 "password twice so we can verify you typed it in correctly." 
    485 msgstr "" 
    486 "Prosíme, pro zabezpečení vložte svoje staré heslo a poté vložte dvakrát nové " 
    487 "heslo, takže můžeme ověřit, že jste ho napsal(a) správně." 
     460msgid "Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly." 
     461msgstr "Prosíme, pro zabezpečení vložte svoje staré heslo a poté vložte dvakrát nové heslo, takže můžeme ověřit, že jste ho napsal(a) správně." 
    488462 
    489463#: contrib/admin/templates/registration/password_change_form.html:17 
     
    568542#: utils/translation.py:335 
    569543msgid "DATE_FORMAT" 
    570 msgstr "
     544msgstr "Formát data
    571545 
    572546#: utils/translation.py:336 
    573547msgid "DATETIME_FORMAT" 
    574 msgstr "
     548msgstr "Formát data a času
    575549 
    576550#: utils/translation.py:337 
    577551msgid "TIME_FORMAT" 
    578 msgstr "
     552msgstr "Formát času
    579553 
    580554#: utils/dates.py:6 
     
    614588msgstr "Únor" 
    615589 
    616 #: utils/dates.py:14 utils/dates.py:27 
     590#: utils/dates.py:14 
     591#: utils/dates.py:27 
    617592msgid "March" 
    618593msgstr "Březen" 
    619594 
    620 #: utils/dates.py:14 utils/dates.py:27 
     595#: utils/dates.py:14 
     596#: utils/dates.py:27 
    621597msgid "April" 
    622598msgstr "Duben" 
    623599 
    624 #: utils/dates.py:14 utils/dates.py:27 
     600#: utils/dates.py:14 
     601#: utils/dates.py:27 
    625602msgid "May" 
    626603msgstr "Květen" 
    627604 
    628 #: utils/dates.py:14 utils/dates.py:27 
     605#: utils/dates.py:14 
     606#: utils/dates.py:27 
    629607msgid "June" 
    630608msgstr "Červen" 
    631609 
    632 #: utils/dates.py:15 utils/dates.py:27 
     610#: utils/dates.py:15 
     611#: utils/dates.py:27 
    633612msgid "July" 
    634613msgstr "Červenec" 
     
    702681msgstr "nadpis" 
    703682 
    704 #: models/core.py:29 models/core.py:40 models/auth.py:6 models/auth.py:19 
     683#: models/core.py:29 
     684#: models/core.py:40 
     685#: models/auth.py:6 
     686#: models/auth.py:19 
    705687msgid "name" 
    706688msgstr "jméno" 
     
    833815msgstr "Oprávnění" 
    834816 
    835 #: models/auth.py:11 models/auth.py:58 
     817#: models/auth.py:11 
     818#: models/auth.py:58 
    836819msgid "Permissions" 
    837820msgstr "Oprávnění" 
     
    841824msgstr "Skupina" 
    842825 
    843 #: models/auth.py:23 models/auth.py:60 
     826#: models/auth.py:23 
     827#: models/auth.py:60 
    844828msgid "Groups" 
    845829msgstr "Skupiny" 
     
    895879 
    896880#: models/auth.py:44 
    897 msgid "" 
    898 "In addition to the permissions manually assigned, this user will also get " 
    899 "all permissions granted to each group he/she is in." 
    900 msgstr "" 
    901 "Kromě manuálně přidělených oprávnění uživatel dostane všechna oprávnění pro " 
    902 "každou skupinu, ve které je." 
     881msgid "In addition to the permissions manually assigned, this user will also get all permissions granted to each group he/she is in." 
     882msgstr "Kromě manuálně přidělených oprávnění uživatel dostane všechna oprávnění pro každou skupinu, ve které je." 
    903883 
    904884#: models/auth.py:48 
     
    952932#: conf/global_settings.py:44 
    953933msgid "Icelandic" 
    954 msgstr "
     934msgstr "Islandština
    955935 
    956936#: conf/global_settings.py:45 
     
    988968#: core/validators.py:63 
    989969msgid "This value must contain only letters, numbers, underscores and slashes." 
    990 msgstr "" 
    991 "Tato hodnota musí obsahovat pouze znaky, čísla, podtržítka nebo lomítka." 
     970msgstr "Tato hodnota musí obsahovat pouze znaky, čísla, podtržítka nebo lomítka." 
    992971 
    993972#: core/validators.py:71 
     
    10481027 
    10491028#: core/validators.py:147 
    1050 msgid "" 
    1051 "Upload a valid image. The file you uploaded was either not an image or a " 
    1052 "corrupted image." 
    1053 msgstr "" 
    1054 "Nahrajte na server platný obrázek. Soubor, který jste nahrál(a) nebyl " 
    1055 "obrázek, nebo byl porušen." 
     1029msgid "Upload a valid image. The file you uploaded was either not an image or a corrupted image." 
     1030msgstr "Nahrajte na server platný obrázek. Soubor, který jste nahrál(a) nebyl obrázek, nebo byl porušen." 
    10561031 
    10571032#: core/validators.py:154 
     
    10931068msgstr "Neplatné URL: %s" 
    10941069 
    1095 #: core/validators.py:205 core/validators.py:207 
     1070#: core/validators.py:205 
     1071#: core/validators.py:207 
    10961072#, python-format 
    10971073msgid "The URL %s is a broken link." 
     
    11191095msgstr "Prosíme, vložte něco alespoň pro jedno pole." 
    11201096 
    1121 #: core/validators.py:263 core/validators.py:274 
     1097#: core/validators.py:263 
     1098#: core/validators.py:274 
    11221099msgid "Please enter both fields or leave them both empty." 
    11231100msgstr "Prosíme, vložte obě pole, nebo je nechte obě prázdná." 
     
    11491126#, python-format 
    11501127msgid "Please enter a valid decimal number with at most %s total digit." 
    1151 msgid_plural "" 
    1152 "Please enter a valid decimal number with at most %s total digits." 
     1128msgid_plural "Please enter a valid decimal number with at most %s total digits." 
    11531129msgstr[0] "Prosíme, vložte platné číslo s nejvíce %s cifrou celkem." 
    11541130msgstr[1] "Prosíme, vložte platné číslo s nejvíce %s ciframi celkem." 
     
    11581134#, python-format 
    11591135msgid "Please enter a valid decimal number with at most %s decimal place." 
    1160 msgid_plural "" 
    1161 "Please enter a valid decimal number with at most %s decimal places." 
    1162 msgstr[0] "" 
    1163 "Prosíme, vložte platné číslo s nejvíce %s cifrou za desetinnou čárkou celkem." 
    1164 msgstr[1] "" 
    1165 "Prosíme, vložte platné číslo s nejvíce %s ciframi za desetinnou čárkou " 
    1166 "celkem." 
    1167 msgstr[2] "" 
    1168 "Prosíme, vložte platné číslo s nejvíce %s ciframi za desetinnou čárkou " 
    1169 "celkem." 
     1136msgid_plural "Please enter a valid decimal number with at most %s decimal places." 
     1137msgstr[0] "Prosíme, vložte platné číslo s nejvíce %s cifrou za desetinnou čárkou celkem." 
     1138msgstr[1] "Prosíme, vložte platné číslo s nejvíce %s ciframi za desetinnou čárkou celkem." 
     1139msgstr[2] "Prosíme, vložte platné číslo s nejvíce %s ciframi za desetinnou čárkou celkem." 
    11701140 
    11711141#: core/validators.py:361 
     
    11941164#: core/validators.py:428 
    11951165#, python-format 
    1196 msgid "" 
    1197 "The URL %(url)s returned the invalid Content-Type header '%(contenttype)s'." 
     1166msgid "The URL %(url)s returned the invalid Content-Type header '%(contenttype)s'." 
    11981167msgstr "URL %(url)s vrátilo neplatnou hlavičku Content-Type '%(contenttype)s'." 
    11991168 
    12001169#: core/validators.py:461 
    12011170#, python-format 
    1202 msgid "" 
    1203 "Please close the unclosed %(tag)s tag from line %(line)s. (Line starts with " 
    1204 "\"%(start)s\".)" 
    1205 msgstr "" 
    1206 "Prosíme, zavřete nezavřenou značku %(tag)s z řádky %(line)s. (Řádka začíná s " 
    1207 "\"%(start)s\".)" 
     1171msgid "Please close the unclosed %(tag)s tag from line %(line)s. (Line starts with \"%(start)s\".)" 
     1172msgstr "Prosíme, zavřete nezavřenou značku %(tag)s z řádky %(line)s. (Řádka začíná s \"%(start)s\".)" 
    12081173 
    12091174#: core/validators.py:465 
    12101175#, python-format 
    1211 msgid "" 
    1212 "Some text starting on line %(line)s is not allowed in that context. (Line " 
    1213 "starts with \"%(start)s\".)" 
    1214 msgstr "" 
    1215 "Nějaký text začínající na řádce %(line)s není povolen v tomto kontextu. " 
    1216 "(Řádka začíná s \"%(start)s\".)" 
     1176msgid "Some text starting on line %(line)s is not allowed in that context. (Line starts with \"%(start)s\".)" 
     1177msgstr "Nějaký text začínající na řádce %(line)s není povolen v tomto kontextu. (Řádka začíná s \"%(start)s\".)" 
    12171178 
    12181179#: core/validators.py:470 
    12191180#, python-format 
    1220 msgid "" 
    1221 "\"%(attr)s\" on line %(line)s is an invalid attribute. (Line starts with \"%" 
    1222 "(start)s\".)" 
    1223 msgstr "" 
    1224 "\"%(attr)s\" na řádce %(line)s je neplatný atribut. (Řádka začíná s \"%" 
    1225 "(start)s\".)" 
     1181msgid "\"%(attr)s\" on line %(line)s is an invalid attribute. (Line starts with \"%(start)s\".)" 
     1182msgstr "\"%(attr)s\" na řádce %(line)s je neplatný atribut. (Řádka začíná s \"%(start)s\".)" 
    12261183 
    12271184#: core/validators.py:475 
    12281185#, python-format 
    1229 msgid "" 
    1230 "\"<%(tag)s>\" on line %(line)s is an invalid tag. (Line starts with \"%" 
    1231 "(start)s\".)" 
    1232 msgstr "" 
    1233 "\"<%(tag)s>\" na řádce %(line)s je neplatná značka. (Řádka začíná s \"%" 
    1234 "(start)s\".)" 
     1186msgid "\"<%(tag)s>\" on line %(line)s is an invalid tag. (Line starts with \"%(start)s\".)" 
     1187msgstr "\"<%(tag)s>\" na řádce %(line)s je neplatná značka. (Řádka začíná s \"%(start)s\".)" 
    12351188 
    12361189#: core/validators.py:479 
    12371190#, python-format 
    1238 msgid "" 
    1239 "A tag on line %(line)s is missing one or more required attributes. (Line " 
    1240 "starts with \"%(start)s\".)" 
    1241 msgstr "" 
    1242 "Značce na řádce %(line)s schází jeden nebo více požadovaných atributů. " 
    1243 "(Řádka začíná s \"%(start)s\".)" 
     1191msgid "A tag on line %(line)s is missing one or more required attributes. (Line starts with \"%(start)s\".)" 
     1192msgstr "Značce na řádce %(line)s schází jeden nebo více požadovaných atributů. (Řádka začíná s \"%(start)s\".)" 
    12441193 
    12451194#: core/validators.py:484 
    12461195#, python-format 
    1247 msgid "" 
    1248 "The \"%(attr)s\" attribute on line %(line)s has an invalid value. (Line " 
    1249 "starts with \"%(start)s\".)" 
    1250 msgstr "" 
    1251 "Atribut \"%(attr)s\" na řádce %(line)s má neplatnou hodnotu. (Řádka začína s " 
    1252 "\"%(start)s\".)" 
     1196msgid "The \"%(attr)s\" attribute on line %(line)s has an invalid value. (Line starts with \"%(start)s\".)" 
     1197msgstr "Atribut \"%(attr)s\" na řádce %(line)s má neplatnou hodnotu. (Řádka začína s \"%(start)s\".)" 
    12531198 
    12541199#: core/meta/fields.py:114 
     
    12571202 
    12581203#: core/meta/fields.py:117 
    1259 msgid "" 
    1260 " Hold down \"Control\", or \"Command\" on a Mac, to select more than one." 
    1261 msgstr "" 
    1262 "Podržte  \"Control\", nebo \"Command\" na Macu pro vybrání více jak jedné " 
    1263 "položky." 
     1204msgid " Hold down \"Control\", or \"Command\" on a Mac, to select more than one." 
     1205msgstr "Podržte  \"Control\", nebo \"Command\" na Macu pro vybrání více jak jedné položky." 
     1206 
  • django/branches/new-admin/django/conf/locale/sk/LC_MESSAGES/django.po

    r1223 r1235  
    1212"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 
    1313"Last-Translator: Vladimir Labath <vlado@labath.org>\n" 
    14 "Language-Team: Slovak <info@labath.org>\n" 
     14"Language-Team: Slovak <sk@li.org>\n" 
    1515"MIME-Version: 1.0\n" 
    1616"Content-Type: text/plain; charset=utf-8\n" 
     
    569569msgstr "" 
    570570 
    571 #: utils/translation.py:335 
    572 msgid "DATE_FORMAT" 
    573 msgstr "" 
    574  
    575 #: utils/translation.py:336 
    576 msgid "DATETIME_FORMAT" 
    577 msgstr "" 
    578  
    579 #: utils/translation.py:337 
    580 msgid "TIME_FORMAT" 
    581 msgstr "" 
    582  
    583571#: utils/dates.py:6 
    584572msgid "Monday" 
     
    685673msgstr "" 
    686674 
     675#: utils/translation.py:335 
     676msgid "DATE_FORMAT" 
     677msgstr "DATUM_FORMAT" 
     678 
     679#: utils/translation.py:336 
     680msgid "DATETIME_FORMAT" 
     681msgstr "DATUMCAS_FORMAT" 
     682 
     683#: utils/translation.py:337 
     684msgid "TIME_FORMAT" 
     685msgstr "CAS_FORMAT" 
     686 
    687687#: models/core.py:7 
    688688msgid "domain name" 
     
    917917msgstr "Dôležité údaje" 
    918918 
    919 #: models/auth.py:182 
     919#: models/auth.py:195 
    920920msgid "Message" 
    921921msgstr "Zpráva" 
  • django/branches/new-admin/django/contrib/admin/templatetags/admin_list.py

    r1223 r1235  
    210210        if first: # First column is a special case 
    211211            first = False 
    212             result_id = getattr(result, pk
    213             yield ('<th%s><a href="%s/"%s>%s</a></th>' % \ 
    214                 (row_class, result_id, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %r); return false;"' % result_id or ''), result_repr)) 
     212            url = cl.url_for_result(result
     213            yield ('<th%s><a href="%s"%s>%s</a></th>' % \ 
     214                (row_class, url, (cl.is_popup and ' onclick="opener.dismissRelatedLookupPopup(window, %r); return false;"' % result_id or ''), result_repr)) 
    215215        else: 
    216216            yield ('<td%s>%s</td>' % (row_class, result_repr)) 
  • django/branches/new-admin/django/contrib/admin/views/main.py

    r1154 r1235  
    209209                      or _('Select %s to change') % self.opts.verbose_name) 
    210210        self.get_filters(request) 
     211        self.pk_attname = self.lookup_opts.pk.attname 
    211212     
    212213    def get_filters(self, request): 
     
    302303                  full_result_count, result_list, can_show_all, multi_page, paginator ) 
    303304     
     305    def url_for_result(self, result): 
     306        return "%s/" % getattr(result, self.pk_attname) 
     307         
    304308    def get_ordering(self): 
    305309        lookup_opts, params = self.lookup_opts, self.params 
  • django/branches/new-admin/django/contrib/syndication/feeds.py

    r1198 r1235  
    1818    feed_type = feedgenerator.DefaultFeed 
    1919 
    20     def __init__(self, slug): 
     20    def __init__(self, slug, feed_url): 
    2121        self.slug = slug 
     22        self.feed_url = feed_url 
    2223 
    2324    def item_link(self, item): 
     
    2728            raise ImproperlyConfigured, "Give your %s class a get_absolute_url() method, or define an item_link() method in your Feed class." % item.__class__.__name__ 
    2829 
    29     def __get_dynamic_attr(self, attname, obj): 
    30         attr = getattr(self, attname) 
     30    def __get_dynamic_attr(self, attname, obj, default=None): 
     31        try: 
     32            attr = getattr(self, attname) 
     33        except AttributeError: 
     34            return default 
    3135        if callable(attr): 
    3236            try: 
     
    5761            link = link, 
    5862            description = self.__get_dynamic_attr('description', obj), 
    59             language = LANGUAGE_CODE.decode() 
     63            language = LANGUAGE_CODE.decode(), 
     64            feed_url = add_domain(current_site, self.feed_url), 
     65            author_name = self.__get_dynamic_attr('author_name', obj), 
     66            author_link = self.__get_dynamic_attr('author_link', obj), 
     67            author_email = self.__get_dynamic_attr('author_email', obj), 
    6068        ) 
    6169 
     
    7987                    mime_type = self.__get_dynamic_attr('item_enclosure_mime_type', item).decode('utf-8'), 
    8088                ) 
     89            author_name = self.__get_dynamic_attr('item_author_name', item) 
     90            if author_name is not None: 
     91                author_email = self.__get_dynamic_attr('item_author_email', item) 
     92                author_link = self.__get_dynamic_attr('item_author_link', item) 
     93            else: 
     94                author_email = author_link = None 
    8195            feed.add_item( 
    8296                title = title_template.render(Context({'obj': item, 'site': current_site})).decode('utf-8'), 
     
    86100                enclosure = enc, 
    87101                pubdate = self.__get_dynamic_attr('item_pubdate', item), 
     102                author_name = author_name, 
     103                author_email = author_email, 
     104                author_link = author_link, 
    88105            ) 
    89106        return feed 
  • django/branches/new-admin/django/contrib/syndication/views.py

    r1223 r1235  
    1818 
    1919    try: 
    20         feedgen = f(slug).get_feed(param) 
     20        feedgen = f(slug, request.path).get_feed(param) 
    2121    except feeds.FeedDoesNotExist: 
    2222        raise Http404, "Invalid feed parameters. Slug %r is valid, but other parameters, or lack thereof, are not." % slug 
  • django/branches/new-admin/django/core/db/backends/ado_mssql.py

    r1223 r1235  
    150150    'OneToOneField':     'int', 
    151151    'PhoneNumberField':  'varchar(20)', 
    152     'PositiveIntegerField': 'int CONSTRAINT [CK_int_pos_%(name)s] CHECK ([%(name)s] > 0)', 
    153     'PositiveSmallIntegerField': 'smallint CONSTRAINT [CK_smallint_pos_%(name)s] CHECK ([%(name)s] > 0)', 
     152    'PositiveIntegerField': 'int CONSTRAINT [CK_int_pos_%(column)s] CHECK ([%(column)s] > 0)', 
     153    'PositiveSmallIntegerField': 'smallint CONSTRAINT [CK_smallint_pos_%(column)s] CHECK ([%(column)s] > 0)', 
    154154    'SlugField':         'varchar(50)', 
    155155    'SmallIntegerField': 'smallint', 
  • django/branches/new-admin/django/core/db/backends/postgresql.py

    r1223 r1235  
    171171    'OneToOneField':     'integer', 
    172172    'PhoneNumberField':  'varchar(20)', 
    173     'PositiveIntegerField': 'integer CHECK (%(name)s >= 0)', 
    174     'PositiveSmallIntegerField': 'smallint CHECK (%(name)s >= 0)', 
     173    'PositiveIntegerField': 'integer CHECK (%(column)s >= 0)', 
     174    'PositiveSmallIntegerField': 'smallint CHECK (%(column)s >= 0)', 
    175175    'SlugField':         'varchar(50)', 
    176176    'SmallIntegerField': 'smallint', 
  • django/branches/new-admin/django/core/handlers/base.py

    r1023 r1235  
    8787        except exceptions.Http404, e: 
    8888            if DEBUG: 
    89                 return self.get_technical_error_response(is404=True, exception=e) 
     89                return self.get_technical_error_response(request, is404=True, exception=e) 
    9090            else: 
    9191                callback, param_dict = resolver.resolve404() 
     
    9494            db.db.rollback() 
    9595            if DEBUG: 
    96                 return self.get_technical_error_response(
     96                return self.get_technical_error_response(request
    9797            else: 
    9898                subject = 'Database error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in INTERNAL_IPS and 'internal' or 'EXTERNAL'), getattr(request, 'path', '')) 
     
    104104        except: # Handle everything else, including SuspiciousOperation, etc. 
    105105            if DEBUG: 
    106                 return self.get_technical_error_response(
     106                return self.get_technical_error_response(request
    107107            else: 
    108108                subject = 'Coding error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in INTERNAL_IPS and 'internal' or 'EXTERNAL'), getattr(request, 'path', '')) 
     
    124124        return callback(request, **param_dict) 
    125125 
    126     def get_technical_error_response(self, is404=False, exception=None): 
     126    def get_technical_error_response(self, request, is404=False, exception=None): 
    127127        """ 
    128128        Returns an HttpResponse that displays a TECHNICAL error message for a 
    129129        fundamental database or coding error. 
    130130        """ 
     131        import sys 
     132        from django.views import debug 
    131133        if is404: 
    132             from django.conf.settings import ROOT_URLCONF 
    133             from django.utils.html import escape 
    134             html = ['<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'] 
    135             html.append('<html><head><title>Error 404</title>') 
    136             # Explicitly tell robots not to archive this, in case this slips 
    137             # onto a production site. 
    138             html.append('<meta name="robots" content="NONE,NOARCHIVE" />') 
    139             html.append('</head><body><h1>Error 404</h1>') 
    140             try: 
    141                 tried = exception.args[0]['tried'] 
    142             except (IndexError, TypeError): 
    143                 if exception.args: 
    144                     html.append('<p>%s</p>' % escape(exception.args[0])) 
    145             else: 
    146                 html.append('<p>Using the URLconf defined in <code>%s</code>, Django tried these URL patterns, in this order:</p>' % ROOT_URLCONF) 
    147                 html.append('<ul>%s</ul>' % ''.join(['<li><code>%s</code></li>' % escape(t).replace(' ', '&nbsp;') for t in tried])) 
    148                 html.append("<p>The current URL, <code><strong>%r</strong></code>, didn't match any of these.</p>" % exception.args[0]['path']) 
    149             html.append("<hr /><p>You're seeing this error because you have <code>DEBUG = True</code> in your Django settings file. Change that to <code>False</code>, and Django will display a standard 404 page.</p>") 
    150             html.append('</body></html>') 
    151             return httpwrappers.HttpResponseNotFound('\n'.join(html)) 
     134            return debug.technical_404_response(request, exception) 
    152135        else: 
    153             output = "There's been an error:\n\n%s" % self._get_traceback() 
    154             return httpwrappers.HttpResponseServerError(output, mimetype='text/plain') 
     136            return debug.technical_500_response(request, *sys.exc_info()) 
    155137 
    156138    def _get_traceback(self): 
  • django/branches/new-admin/django/core/management.py

    <
    r1154 r1235  
    2020 
    2121def _get_packages_insert(app_label): 
    22     return "INSERT INTO packages (label, name) VALUES ('%s', '%s');" % (app_label, app_label) 
     22    from django.core.db import db 
     23    return "INSERT INTO %s (%s, %s) VALUES ('%s', '%s');" % \ 
     24        (db.quote_name('packages'), db.quote_name('label'), db.quote_name('name'), 
     25        app_label, app_label) 
    2326 
    2427def _get_permission_codename(action, opts): 
     
    3437 
    3538def _get_permission_insert(name, codename, opts): 
    36     return "INSERT INTO auth_permissions (name, package, codename) VALUES ('%s', '%s', '%s');" % \ 
    37         (name.replace("'", "''"), opts.app_label, codename) 
     39    from django.core.db import db 
     40    return "INSERT INTO %s (%s, %s, %s) VALUES ('%s', '%s', '%s');" % \ 
     41        (db.quote_name('auth_permissions'), db.quote_name('name'), db.quote_name('package'), 
     42        db.quote_name('codename'), name.replace("'", "''"), opts.app_label, codename) 
    3843 
    3944def _get_contenttype_insert(opts): 
    40     return "INSERT INTO content_types (name, package, python_module_name) VALUES ('%s', '%s', '%s');" % \ 
    41         (opts.verbose_name, opts.app_label, opts.module_name) 
     45    from django.core.db import db 
     46    return "INSERT INTO %s (%s, %s, %s) VALUES ('%s', '%s', '%s');" % \ 
     47        (db.quote_name('content_types'), db.quote_name('name'), db.quote_name('package'), 
     48        db.quote_name('python_module_name'), opts.verbose_name, opts.app_label, opts.module_name) 
    4249 
    4350def _is_valid_dir_name(s): 
     
    6572            col_type = db.DATA_TYPES[data_type] 
    6673            if col_type is not None: 
    67                 field_output = [f.column, col_type % rel_field.__dict__] 
     74                field_output = [db.db.quote_name(f.column), col_type % rel_field.__dict__] 
    6875                field_output.append('%sNULL' % (not f.null and 'NOT ' or '')) 
    6976                if f.unique: 
     
    7380                if f.rel: 
    7481                    field_output.append('REFERENCES %s (%s)' % \ 
    75                         (f.rel.to.db_table, f.rel.to.get_field(f.rel.field_name).column)) 
     82                        (db.db.quote_name(f.rel.to.db_table), 
     83                        db.db.quote_name(f.rel.to.get_field(f.rel.field_name).column))) 
    7684                table_output.append(' '.join(field_output)) 
    7785        if opts.order_with_respect_to: 
    78             table_output.append('_order %s NULL' % db.DATA_TYPES['IntegerField']
     86            table_output.append('%s %s NULL' % (db.db.quote_name('_order'), db.DATA_TYPES['IntegerField'])
    7987        for field_constraints in opts.unique_together: 
    80             table_output.append('UNIQUE (%s)' % ", ".join([opts.get_field(f).column for f in field_constraints])) 
    81  
    82         full_statement = ['CREATE TABLE %s (' % opts.db_table] 
     88            table_output.append('UNIQUE (%s)' % \ 
     89                ", ".join([db.db.quote_name(opts.get_field(f).column) for f in field_constraints])) 
     90 
     91        full_statement = ['CREATE TABLE %s (' % db.db.quote_name(opts.db_table)] 
    8392        for i, line in enumerate(table_output): # Combine and add commas. 
    8493            full_statement.append('    %s%s' % (line, i < len(table_output)-1 and ',' or '')) 
     
    8998        opts = klass._meta 
    9099        for f in opts.many_to_many: 
    91             table_output = ['CREATE TABLE %s (' % f.get_m2m_db_table(opts)] 
    92             table_output.append('    id %s NOT NULL PRIMARY KEY,' % db.DATA_TYPES['AutoField']) 
    93             table_output.append('    %s_id %s NOT NULL REFERENCES %s (%s),' % \ 
    94                 (opts.object_name.lower(), db.DATA_TYPES[get_rel_data_type(opts.pk)] % opts.pk.__dict__, opts.db_table, opts.pk.column)) 
    95             table_output.append('    %s_id %s NOT NULL REFERENCES %s (%s),' % \ 
    96                 (f.rel.to.object_name.lower(), db.DATA_TYPES[get_rel_data_type(f.rel.to.pk)] % f.rel.to.pk.__dict__, f.rel.to.db_table, f.rel.to.pk.column)) 
    97             table_output.append('    UNIQUE (%s_id, %s_id)' % (opts.object_name.lower(), f.rel.to.object_name.lower())) 
     100            table_output = ['CREATE TABLE %s (' % db.db.quote_name(f.get_m2m_db_table(opts))] 
     101            table_output.append('    %s %s NOT NULL PRIMARY KEY,' % (db.db.quote_name('id'), db.DATA_TYPES['AutoField'])) 
     102            table_output.append('    %s %s NOT NULL REFERENCES %s (%s),' % \ 
     103                (db.db.quote_name(opts.object_name.lower() + '_id'), 
     104                db.DATA_TYPES[get_rel_data_type(opts.pk)] % opts.pk.__dict__, 
     105                db.db.quote_name(opts.db_table), 
     106                db.db.quote_name(opts.pk.column))) 
     107            table_output.append('    %s %s NOT NULL REFERENCES %s (%s),' % \ 
     108                (db.db.quote_name(f.rel.to.object_name.lower() + '_id'), 
     109                db.DATA_TYPES[get_rel_data_type(f.rel.to.pk)] % f.rel.to.pk.__dict__, 
     110                db.db.quote_name(f.rel.to.db_table), 
     111                db.db.quote_name(f.rel.to.pk.column))) 
     112            table_output.append('    UNIQUE (%s, %s)' % \ 
     113                (db.db.quote_name(opts.object_name.lower() + '_id'), 
     114                db.db.quote_name(f.rel.to.object_name.lower() + '_id'))) 
    98115            table_output.append(');') 
    99116            final_output.append('\n'.join(table_output)) 
     
    115132        if cursor is not None: 
    116133            # Check whether the table exists. 
    117             cursor.execute("SELECT 1 FROM django_admin_log LIMIT 1"
     134            cursor.execute("SELECT 1 FROM %s LIMIT 1" % db.db.quote_name('django_admin_log')
    118135    except: 
    119136        # The table doesn't exist, so it doesn't need to be dropped. 
     
    130147            if cursor is not None: 
    131148                # Check whether the table exists. 
    132                 cursor.execute("SELECT 1 FROM %s LIMIT 1" % klass._meta.db_table
     149                cursor.execute("SELECT 1 FROM %s LIMIT 1" % db.db.quote_name(klass._meta.db_table)
    133150        except: 
    134151            # The table doesn't exist, so it doesn't need to be dropped. 
    135152            db.db.rollback() 
    136153        else: 
    137             output.append("DROP TABLE %s;" % klass._meta.db_table
     154            output.append("DROP TABLE %s;" % db.db.quote_name(klass._meta.db_table)
    138155 
    139156    # Output DROP TABLE statements for many-to-many tables. 
     
    143160            try: 
    144161                if cursor is not None: 
    145                     cursor.execute("SELECT 1 FROM %s LIMIT 1" % f.get_m2m_db_table(opts)) 
     162                    cursor.execute("SELECT 1 FROM %s LIMIT 1" % db.db.quote_name(f.get_m2m_db_table(opts))) 
    146163            except: 
    147164                db.db.rollback() 
    148165            else: 
    149                 output.append("DROP TABLE %s;" % f.get_m2m_db_table(opts)) 
     166                output.append("DROP TABLE %s;" % db.db.quote_name(f.get_m2m_db_table(opts))) 
    150167 
    151168    app_label = mod._MODELS[0]._meta.app_label 
    152169 
    153170    # Delete from packages, auth_permissions, content_types. 
    154     output.append("DELETE FROM packages WHERE label = '%s';" % app_label) 
    155     output.append("DELETE FROM auth_permissions WHERE package = '%s';" % app_label) 
    156     output.append("DELETE FROM content_types WHERE package = '%s';" % app_label) 
     171    output.append("DELETE FROM %s WHERE %s = '%s';" % \ 
     172        (db.db.quote_name('packages'), db.db.quote_name('label'), app_label)) 
     173    output.append("DELETE FROM %s WHERE %s = '%s';" % \ 
     174        (db.db.quote_name('auth_permissions'), db.db.quote_name('package'), app_label)) 
     175    output.append("DELETE FROM %s WHERE %s = '%s';" % \ 
     176        (db.db.quote_name('content_types'), db.db.quote_name('package'), app_label)) 
    157177 
    158178    # Delete from the admin log. 
    159179    if cursor is not None: 
    160         cursor.execute("SELECT id FROM content_types WHERE package = %s", [app_label]) 
     180        cursor.execute("SELECT %s FROM %s WHERE %s = %%s" % \ 
     181            (db.db.quote_name('id'), db.db.quote_name('content_types'), 
     182            db.db.quote_name('package')), [app_label]) 
    161183        if admin_log_exists: 
    162184            for row in cursor.fetchall(): 
    163                 output.append("DELETE FROM django_admin_log WHERE content_type_id = %s;" % row[0]) 
     185                output.append("DELETE FROM %s WHERE %s = %s;" % \ 
     186                    (db.db.quote_name('django_admin_log'), db.db.quote_name('content_type_id'), row[0])) 
    164187 
    165188    # Close database connection explicitly, in case this output is being piped 
     
    207230def get_sql_sequence_reset(mod): 
    208231    "Returns a list of the SQL statements to reset PostgreSQL sequences for the given module." 
    209     from django.core import meta 
     232    from django.core import db, meta 
    210233    output = [] 
    211234    for klass in mod._MODELS: 
    212235        for f in klass._meta.fields: 
    213236            if isinstance(f, meta.AutoField): 
    214                 output.append("SELECT setval('%s_%s_seq', (SELECT max(%s) FROM %s));" % (klass._meta.db_table, f.column, f.column, klass._meta.db_table)) 
     237                output.append("SELECT setval('%s_%s_seq', (SELECT max(%s) FROM %s));" % \ 
     238                    (klass._meta.db_table, f.column, db.db.quote_name(f.column), 
     239                    db.db.quote_name(klass._meta.db_table))) 
    215240    return output 
    216241get_sql_sequence_reset.help_doc = "Prints the SQL statements for resetting PostgreSQL sequences for the given model module name(s)." 
     
    219244def get_sql_indexes(mod): 
    220245    "Returns a list of the CREATE INDEX SQL statements for the given module." 
     246    from django.core.db import db 
    221247    output = [] 
    222248    for klass in mod._MODELS: 
     
    225251                unique = f.unique and "UNIQUE " or "" 
    226252                output.append("CREATE %sINDEX %s_%s ON %s (%s);" % \ 
    227                     (unique, klass._meta.db_table, f.column, klass._meta.db_table, f.column)) 
     253                    (unique, klass._meta.db_table, f.column, 
     254                    db.quote_name(klass._meta.db_table), db.quote_name(f.column))) 
    228255    return output 
    229256get_sql_indexes.help_doc = "Prints the CREATE INDEX SQL statements for the given model module name(s)." 
     
    243270 
    244271    # Check that the package exists in the database. 
    245     cursor.execute("SELECT 1 FROM packages WHERE label = %s", [app_label]) 
     272    cursor.execute("SELECT 1 FROM %s WHERE %s = %%s" % \ 
     273        (db.db.quote_name('packages'), db.db.quote_name('label')), [app_label]) 
    246274    if cursor.rowcount < 1: 
    247275#         sys.stderr.write("The '%s' package isn't installed.\n" % app_label) 
     
    257285        contenttypes_seen[opts.module_name] = 1 
    258286        for codename, name in perms: 
    259             cursor.execute("SELECT 1 FROM auth_permissions WHERE package = %s AND codename = %s", (app_label, codename)) 
     287            cursor.execute("SELECT 1 FROM %s WHERE %s = %%s AND %s = %%s" % \ 
     288                (db.db.quote_name('auth_permissions'), db.db.quote_name('package'), 
     289                db.db.quote_name('codename')), (app_label, codename)) 
    260290            if cursor.rowcount < 1: 
    261291#                 sys.stderr.write("The '%s.%s' permission doesn't exist.\n" % (app_label, codename)) 
    262292                print _get_permission_insert(name, codename, opts) 
    263         cursor.execute("SELECT 1 FROM content_types WHERE package = %s AND python_module_name = %s", (app_label, opts.module_name)) 
     293        cursor.execute("SELECT 1 FROM %s WHERE %s = %%s AND %s = %%s" % \ 
     294            (db.db.quote_name('content_types'), db.db.quote_name('package'), 
     295            db.db.quote_name('python_module_name')), (app_label, opts.module_name)) 
    264296        if cursor.rowcount < 1: 
    265297#             sys.stderr.write("The '%s.%s' content type doesn't exist.\n" % (app_label, opts.module_name)) 
     
    268300    # Check that there aren't any *extra* permissions in the DB that the model 
    269301    # doesn't know about. 
    270     cursor.execute("SELECT codename FROM auth_permissions WHERE package = %s", (app_label,)) 
     302    cursor.execute("SELECT %s FROM %s WHERE %s = %%s" % \ 
     303        (db.db.quote_name('codename'), db.db.quote_name('auth_permissions'), 
     304        db.db.quote_name('package')), (app_label,)) 
    271305    for row in cursor.fetchall(): 
    272306        try: 
     
    274308        except KeyError: 
    275309#             sys.stderr.write("A permission called '%s.%s' was found in the database but not in the model.\n" % (app_label, row[0])) 
    276             print "DELETE FROM auth_permissions WHERE package='%s' AND codename = '%s';" % (app_label, row[0]) 
     310            print "DELETE FROM %s WHERE %s='%s' AND %s = '%s';" % \ 
     311                (db.db.quote_name('auth_permissions'), db.db.quote_name('package'), 
     312                app_label, db.db.quote_name('codename'), row[0]) 
    277313 
    278314    # Check that there aren't any *extra* content types in the DB that the 
    279315    # model doesn't know about. 
    280     cursor.execute("SELECT python_module_name FROM content_types WHERE package = %s", (app_label,)) 
     316    cursor.execute("SELECT %s FROM %s WHERE %s = %%s" % \ 
     317        (db.db.quote_name('python_module_name'), db.db.quote_name('content_types'), 
     318        db.db.quote_name('package')), (app_label,)) 
    281319    for row in cursor.fetchall(): 
    282320        try: 
     
    284322        except KeyError: