o 3a'"@sddlmZddlmZddlmZmZddlmZm Z ddl m Z m Z ddl mZddlmZddlmZdd lmZdd lmZmZmZdd lmZdd dZGdddeZGdddZdS))timegm)get_current_site)ImproperlyConfiguredObjectDoesNotExist)Http404 HttpResponse)TemplateDoesNotExistloader) feedgenerator) iri_to_uri)escape) http_date)get_default_timezoneis_naive make_aware) get_languageFcCsF|rdnd}|drd||f}|S|ds!td|||f}|S)Nhttpshttpz//z%s:%s)zhttp://zhttps://zmailto:z %s://%s%s) startswithr )domainurlsecureprotocolrB/usr/lib/python3/dist-packages/django/contrib/syndication/views.py add_domains    rc@s eZdZdS)FeedDoesNotExistN)__name__ __module__ __qualname__rrrrrsrc@sxeZdZejZdZdZdZddZ ddZ ddZ dd Z d d Z dd d ZddZddZddZddZddZdS)FeedNcOsz|j|g|Ri|}Wn tytdw|||}t|jd}t|ds0t|dr=tt| |j d<| |d|S)NzFeed object does not exist.) content_type item_pubdateitem_updateddatez Last-Modifiedzutf-8) get_objectrrget_feedrr!hasattrr rlatest_post_date utctimetupleheaderswrite)selfrequestargskwargsobjfeedgenresponserrr__call__#s    z Feed.__call__cCs tt|SN)r strr+itemrrr item_title2s zFeed.item_titlecCst|Sr3)r4r5rrritem_description6szFeed.item_descriptioncCs*z|WStytd|jjw)NzcGive your %s class a get_absolute_url() method, or define an item_link() method in your Feed class.)get_absolute_urlAttributeErrorr __class__rr5rrr item_link9s  zFeed.item_linkcCsF|d|}|r!tjt|t|d|t|d|d}|gSgS)Nitem_enclosure_urlitem_enclosure_lengthitem_enclosure_mime_type)rlength mime_type)_get_dynamic_attrr Enclosurer4)r+r6enc_urlencrrritem_enclosuresBs zFeed.item_enclosurescCspzt||}Wn ty|YSwt|r6z|j}Wn ty)|jj}Ynw|jdkr3||S|S|S)N)getattrr:callable__code__r2 co_argcount)r+attnamer/defaultattrcoderrrrBMs     zFeed._get_dynamic_attrcCiS)zy Return an extra keyword arguments dictionary that is used when initializing the feed generator. r)r+r/rrrfeed_extra_kwargs`zFeed.feed_extra_kwargscCrP)z Return an extra keyword arguments dictionary that is used with the `add_item` call of the feed generator. rr5rrritem_extra_kwargsgrRzFeed.item_extra_kwargscOsdSr3r)r+r,r-r.rrrr$nszFeed.get_objectcKs|d|ddS)a Return a dictionary to use as extra context if either ``self.description_template`` or ``self.item_template`` are used. Default implementation preserves the old behavior of using {'obj': item, 'site': current_site} as the context. r6site)r/rT)get)r+r.rrrget_context_dataqszFeed.get_context_datacCst|}|d|}t|j||}|jd |d||d|||d||jp+tt|j|d|p6|j||d||d||d||d ||d ||d ||d |d | |}d}|j durzt |j }Wn t y~Ynwd}|jdurzt |j}Wn t yYnw|d|D]}|j||||d} |dur|| |} n|d|} |dur|| |} n|d|} t|j|d||}|d|} |d|} | dur|d|}|d|}nd}}t}|d|}|rt|rt||}|d|}|r"t|r"t||}|jd | || |d|||d|| ||| |||d||d||d|d||q|S)!z Return a feedgenerator.DefaultFeed object, fully populated, for this feed. Raise FeedDoesNotExist for invalid parameters. linktitlesubtitle descriptionfeed_url author_name author_link author_email categoriesfeed_copyright feed_guidttl) rXrYrWrZlanguager[r\r]r^r_r`rarbNitems)r6rTr/r,r7r8r<rFitem_author_nameitem_author_emailitem_author_linkr"r# item_guiditem_guid_is_permalink item_commentsitem_categoriesitem_copyright)rXrWrZ unique_idunique_id_is_permalink enclosurespubdate updateddater\r^r]commentsr_rlr)rrBrr is_secure feed_typercrpathrQtitle_templater get_templaterdescription_templaterVrenderrrradd_itemrS)r+r/r, current_siterWfeed title_tmpdescription_tmpr6contextrXrZror\r^r]tzrprqrrrr%{s                              z Feed.get_feedr3)rrrr DefaultFeedrtrvrxrcr2r7r8r<rFrBrQrSr$rVr%rrrrr s   r N)F)calendarrdjango.contrib.sites.shortcutsrdjango.core.exceptionsrr django.httprrdjango.templaterr django.utilsr django.utils.encodingr django.utils.htmlr django.utils.httpr django.utils.timezonerrrdjango.utils.translationrrrr rrrrs