Ignore:
Timestamp:
Nov 12, 2010 1:07:34 PM (11 years ago)
Author:
olha
Message:

doc files updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/filters.txt

    r3002 r3005  
    33================== 
    44 
    5 Filtering introductioin 
    6 ======================= 
    7  
    8 Sitemap portal type has an option, designed to filter out 
    9 objects which should be excluded from a sitemap. This option is 
    10 accessable in sitemap edit form and is labeled as 
    11 "Blackout entries". 
     5Introduction 
     6============ 
     7 
     8Sitemap portal type has an option that filters objects that 
     9should be excluded from a sitemap. This option is accessable 
     10on sitemap edit form and is labeled as "Blackout entries". 
    1211 
    1312In earlier versions of the package (<4.0.1 for plone-4 branch 
    1413and <3.0.7 for plone-3 branch) this field allowed to 
    15 filter objects only by their ids, and looked like: 
     14filter objects only by their ids, and it looked like: 
    1615 
    1716<pre> 
     
    2019</pre> 
    2120 
    22 So, all objects with "index.html" or "index_html" ids were 
    23 excluded from the sitemap. 
    24  
    25 In the new versions of GoogleSitemaps filtering was remade 
    26 to pluggable architecture. Now filters became named multi 
    27 adapters. There are only two default filters - "id" and 
    28 "path". 
     21As a result, all objects with "index.html" or "index_html" ids  
     22were excluded from the sitemap. 
     23 
     24In the new versions of GoogleSitemaps filtering was refactored 
     25to pluggable architecture. Now filters turned to be named multi 
     26adapters. There are only two default filters: "id" and "path". 
    2927 
    3028Since different filters can be used - new syntax was applied 
     
    3432  [<filter name>:]<filter arguments> 
    3533 
    36 If no <filter name> is specified - "id" filter will 
    37 be used. If <filter name> is specified - system will look 
    38 for <filter name>-named  multiadapter to IBlackoutFilter 
    39 interface. If such multiadapter is not found - filter 
    40 will be ignored without raising any errors. 
    41  
    42  
    43 Following parts demonstrate working of the filtering. 
    44 Aspects of default filters ("id" and "path") 
    45 are considered yet. 
    46  
    47 Setup demonstration environment 
     34* If no <filter name> is specified - "id" filter will be used.  
     35* If <filter name> is specified - system will look for  
     36  <filter name>-named  multiadapter to IBlackoutFilter interface.  
     37  If such multiadapter is not found - filter ill be ignored without 
     38  raising any errors. 
     39 
     40The following parts demonstrate how to work with filtering. 
     41Aspects of default filters ("id" and "path") will also be  
     42considered. 
     43 
     44Demonstration environment setup 
    4845=============================== 
    4946 
    50 First, we must perform some setup. We use the testbrowser that is 
     47First, we have to do some setup. We use testbrowser that is 
    5148shipped with Five, as this provides proper Zope 2 integration. Most 
    5249of the documentation, though, is in the underlying zope.testbrower 
     
    5754    >>> portal_url = self.portal.absolute_url() 
    5855 
    59 The following is useful when writing and debugging testbrowser tests. 
    60 It lets us see all error messages in the error_log. 
     56This is useful when writing and debugging testbrowser tests. It lets 
     57us see all error messages in the error_log. 
    6158 
    6259    >>> self.portal.error_log._ignored_exceptions = () 
     
    8885============= 
    8986 
    90 First create some content for demonstrations. 
     87First, create some content for demonstration purpose. 
    9188 
    9289In the root of the portal 
     
    105102    >>> browser.getControl('Add Content Sitemap').click() 
    106103     
    107 Now we bring-up to edit form of the newly created content sitemap. 
    108 We are interested in two things: "Blackout entries" field must 
    109 present in the form and by default it should be empty. 
     104Now we are landed on the newly-created sitemap edit form. 
     105What we are interested in is "Blackout entries" field on the edit  
     106form, it should be empty by default settings. 
    110107 
    111108    >>> file("/tmp/browser.0.html","wb").write(browser.contents) 
     
    121118 
    122119 
    123 Click on "Save" button lead us to result sitemap view. 
     120Clicking on "Save" button will lead us to the sitemap view. 
    124121 
    125122    >>> print browser.contents 
     
    127124 
    128125 
    129 "sitemap.xml" link should appear in "Settings" page of the 
    130 Plone Google Sitemap configlet when "Content Sitemap" 
     126"sitemap.xml" link should appear on "Settings" page of the 
     127Plone Google Sitemap configlet after "Content Sitemap" 
    131128was added. 
    132129 
     
    135132    >>> smedit_url = smedit_link.url 
    136133 
    137 This link points to edit form of the newly created sitemap.xml. 
    138 Let prepare view link to simplifier following demonstrations. 
     134This link points to the newly-created sitemap.xml edit form. 
     135Let's prepare view link to simplify the following demonstrations. 
    139136 
    140137    >>> smedit_url.endswith("sitemap.xml/edit") 
     
    146143========== 
    147144 
    148 Created sitemap has no filters and all documents should appear in it. 
     145The created sitemap has no filters applied and all documents should appear in it. 
    149146 
    150147    >>> browser.open(smview_url) 
     
    152149    >>> no_filters_content = browser.contents 
    153150 
    154 Check if resulted page really is sitemap... 
     151Check if result page is really a sitemap... 
    155152 
    156153    >>> print browser.contents 
     
    158155 
    159156 
    160 Create regular expression, which help us to test which urls pass the filters. 
     157Create regular expression, which will help us to test which urls pass the filters. 
    161158 
    162159    >>> reloc = re.compile("<loc>%s([^\<]*)</loc>" % self.portal.absolute_url(), re.S) 
    163160 
    164 Test if all 4 documents and default front-page present in the sitemap 
    165 without filters. 
     161Test if all 4 documents and default front-page are in the sitemap without filters. 
    166162 
    167163    >>> no_filters_res = reloc.findall(no_filters_content) 
     
    178174================= 
    179175 
    180 Go to the edit form of the sitemap and add "doc1" 
    181 and "front-page" lines with "id:" prefix to the 
    182 "Blackout entries" field. 
     176Go to the sitemap edit form and add "doc1" and "front-page" lines with "id:"  
     177prefix to the "Blackout entries" field. 
    183178 
    184179    >>> browser.open(smedit_url) 
     
    191186    >>> id_filter_content = browser.contents 
    192187 
    193 "doc1" and "front-page" documents should be excluded from the 
     188"doc1" and "front-page" documents should now be excluded from the 
    194189sitemap. 
    195190 
     
    204199=================== 
    205200 
    206 Suppouse we wont to exclude the "front_page" from portal root 
    207 and "doc2" document, located in test_user_1_ home folder, 
    208 but leave untouched "doc2" in portal root with all other objects. 
     201Suppose we want to exclude "front_page" from portal root and "doc2" 
     202document, located in test_user_1_ home folder, but leave "doc2"  
     203untouched in portal root with all other objects. 
    209204 
    210205    >>> browser.open(smedit_url) 
     
    231226==================== 
    232227 
    233 Now I have the question: "What filter will be used when no  
    234 filter name prefix was specified (old-fashion filters for 
    235 example)?" 
    236  
    237 Go to the edit form of the sitemap and add "doc1" and 
    238 "front-page" lines without any filter name prefix to the 
    239 "Blackout entries" field. 
     228Now I have a question: "What filter will be used when no  
     229filter name prefix is specified (e.g. old-fashion filters)?" 
     230 
     231Go to the sitemap edit form and add "doc1" and "front-page" 
     232lines without any filter name prefix to the "Blackout entries"  
     233field. 
    240234 
    241235    >>> browser.open(portal_url + "/sitemap.xml/edit") 
     
    248242    >>> default_filter_content = browser.contents 
    249243 
    250 "id" filter must be used as default filter. So all "doc1" and 
     244"id" filter must be used as default filter. So, all "doc1" and 
    251245"front-page" objects should be excluded from the sitemap. 
    252246 
     
    258252 
    259253 
    260 Creation own filters 
    261 ==================== 
    262  
    263 Suppouse we want to create own blackout filter,  
    264 which behave like id-filter, but has some differencies. 
    265 Our fitler has following format: 
     254Create your own filters 
     255======================= 
     256 
     257Suppose we want to create our own blackout filter,  which will 
     258behave like id-filter, but will have some differences. Our fitler  
     259has the following format: 
    266260 
    267261  (+|-)<filtered id> 
    268262 
    269   - when 1st sign is "+" then only objects with <filtered id> 
    270     should be leaved in sitemap after filetering; 
    271   - if 1st sign is "-" then all objects with <filtered id> 
    272     should be excluded from the sitemap (like default id 
    273     filter). 
    274  
    275 You need create new IBlckoutFilter multi-adapter, 
    276 and register it with unique name. 
     263- if the 1st sign is "+" then only objects with <filtered id> 
     264  should be left in sitemap after filetering; 
     265- if the 1st sign is "-" then all objects with <filtered id> 
     266  should be excluded from the sitemap (like default id filter). 
     267 
     268You need to create new IBlckoutFilter multi-adapter, and register 
     269it with unique name. 
    277270 
    278271    >>> from zope.component import adapts 
     
    302295    ...                name=u'signedid') 
    303296 
    304 So that's all what needed to add new filter. 
    305 Now test newly created filter. 
     297So that's all what needed to add new filter. Now test newly-created 
     298filter. 
    306299 
    307300Check whether white filtering ("+" prefix) works correctly. 
    308 Go to edit form of the sitemap and add "signedid:+doc1" 
     301Go to the sitemap edit form and add "signedid:+doc1" 
    309302to the "Blackout entries" field. 
    310303 
     
    317310    >>> signedid_filter_content = browser.contents 
    318311 
    319 Only objects with "doc1" id should be leaved in the sitemap. 
     312Only objects with "doc1" id should be left in the sitemap. 
    320313 
    321314    >>> signedid_filter_res = reloc.findall(signedid_filter_content) 
     
    326319 
    327320 
    328 And for the last - check wheter black filtering ("-" prefix) 
    329 works correctly. 
    330 Go to the edit form of the sitemap and add "signedid:-doc1" 
    331 to the "Blackout entries" field. 
     321Finally, check whether black filtering ("-" prefix) works correctly. 
     322Go to the sitemaps edit form and add "signedid:-doc1" to the "Blackout  
     323entries" field. 
    332324 
    333325    >>> browser.open(smedit_url) 
     
    339331    >>> signedid_filter_content = browser.contents 
    340332 
    341 All objects except those having "doc1" id must be included in 
     333All objects, except those having "doc1" id, must be included in 
    342334the sitemap. 
    343335 
Note: See TracChangeset for help on using the changeset viewer.