Changeset 2997 in products


Ignore:
Timestamp:
Nov 11, 2010 1:16:53 PM (13 years ago)
Author:
mylan
Message:

#228: reviewed explanation, correct grammar for filters doctest

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.plonegooglesitemaps/branches/blacklist/quintagroup/plonegooglesitemaps/filters.txt

    r2992 r2997  
    33================== 
    44 
    5 Sitemaps has option to filterout objects, which shouldn't present 
    6 in a sitemap. This option is accessable in sitemap edit form 
    7 and present as "Blackout entries" lines field. 
    8  
    9 In earlier (<3.0.7 and <4.0.1) versions of the package the field 
    10 filter-out objects only by its ids, and looks like: 
     5Filtering introductioin 
     6======================= 
     7 
     8Sitemap portal type has an option, designed to filter out 
     9objects which should be excluded from a sitemap. This option is 
     10accessable in sitemap edit form and is labeled as 
     11"Blackout entries". 
     12 
     13In earlier versions of the package (<4.0.1 for plone-4 branch 
     14and <3.0.7 for plone-3 branch) this field allowed to 
     15filter objects only by their ids, and looked like: 
    1116 
    1217<pre> 
     
    1520</pre> 
    1621 
    17 So all objects with "index.html" or "index_html" ids excluded 
    18 from the sitemap. 
    19  
    20 In the new versions of GoogleSitemaps filtering was remaked 
    21 to pluggable architecture. Now filters are named mutli adapters. 
    22 By default there are only two most useful filters - "id" and 
     22So, all objects with "index.html" or "index_html" ids were 
     23excluded from the sitemap. 
     24 
     25In the new versions of GoogleSitemaps filtering was remade 
     26to pluggable architecture. Now filters became named multi 
     27adapters. There are only two default filters - "id" and 
    2328"path". 
    2429 
    25 Because of different filters can be used - new syntax applied 
     30Since different filters can be used - new syntax was applied 
    2631to the "Blackout entries" field. Every record in the field 
    27 should follow the spec: 
     32should follow the specification: 
    2833   
    2934  [<filter name>:]<filter arguments> 
    3035 
    31 By default (if no <filter name> specified) - "id" filter will 
    32 be used. If <filter name> specified - system looking for  
    33 <filter name> name  multiadapter to IBlackoutFilter interface. 
    34 If such multiadapter was not found - it's ignored silently. 
    35  
    36  
    37 Setup  
    38 ===== 
    39  
    40 First, we must perform some setup. We use the testbrowser that is shipped 
    41 with Five, as this provides proper Zope 2 integration. Most of the  
    42 documentation, though, is in the underlying zope.testbrower package. 
     36If no <filter name> is specified - "id" filter will 
     37be used. If <filter name> is specified - system will look 
     38for <filter name>-named  multiadapter to IBlackoutFilter 
     39interface. If such multiadapter is not found - filter 
     40will be ignored without raising any errors. 
     41 
     42 
     43Following parts demonstrate working of the filtering. 
     44Aspects of default filters ("id" and "path") 
     45are considered yet. 
     46 
     47Setup demonstration environment 
     48=============================== 
     49 
     50First, we must perform some setup. We use the testbrowser that is 
     51shipped with Five, as this provides proper Zope 2 integration. Most 
     52of the documentation, though, is in the underlying zope.testbrower 
     53package. 
    4354 
    4455    >>> from Products.Five.testbrowser import Browser 
     
    4657    >>> portal_url = self.portal.absolute_url() 
    4758 
    48 The following is useful when writing and debugging testbrowser tests. It lets 
    49 us see all error messages in the error_log. 
     59The following is useful when writing and debugging testbrowser tests. 
     60It lets us see all error messages in the error_log. 
    5061 
    5162    >>> self.portal.error_log._ignored_exceptions = () 
    5263 
    53 With that in place, we can go to the portal front page and log in. We will 
    54 do this using the default user from PloneTestCase: 
     64With that in place, we can go to the portal front page and log in. 
     65We will do this using the default user from PloneTestCase: 
    5566 
    5667    >>> from Products.PloneTestCase.setup import portal_owner, default_password 
     
    7485 
    7586 
    76  
    7787Functionality 
    7888============= 
    7989 
    80 First create several documents for demonstrations. 
     90First create some content for demonstrations. 
    8191 
    8292In the root of the portal 
     
    90100    >>> self.addDocument(self.folder, "doc2", "Member Document 2 text") 
    91101 
    92 We need add sitemap, of corse, for demonstration. 
     102We need to add sitemap for demonstration. 
    93103 
    94104    >>> browser.open(portal_url + "/prefs_gsm_settings") 
     
    96106     
    97107Now we bring-up to edit form of the newly created content sitemap. 
    98 We interested in two things: "Blackout entries" field must present 
    99 in the form and it should be empty by default. 
    100      
    101      
     108We are interested in two things: "Blackout entries" field must 
     109present in the form and by default it should be empty. 
     110 
    102111    >>> file("/tmp/browser.0.html","wb").write(browser.contents) 
    103112    >>> blackout_list = browser.getControl("Blackout entries") 
     
    118127 
    119128 
    120 After adding "Content Sitemap", "sitemap.xml" link will appear 
    121 on "Settings" tab page of Plone Google Sitemap configlet. 
     129"sitemap.xml" link should appear in "Settings" page of the 
     130Plone Google Sitemap configlet when "Content Sitemap" 
     131was added. 
    122132 
    123133    >>> browser.open(portal_url + "/prefs_gsm_settings") 
     
    125135    >>> smedit_url = smedit_link.url 
    126136 
    127 This link lead to edit form of the newly created sitemap.xml. 
    128 Also prepare view link to simplifier following demonstrations. 
     137This link points to edit form of the newly created sitemap.xml. 
     138Let prepare view link to simplifier following demonstrations. 
    129139 
    130140    >>> smedit_url.endswith("sitemap.xml/edit") 
     
    136146========== 
    137147 
    138 Resulted sitemap has no filters - all document should present in it. 
     148Created sitemap has no filters and all documents should appear in it. 
    139149 
    140150    >>> browser.open(smview_url) 
     
    142152    >>> no_filters_content = browser.contents 
    143153 
    144 Check if resulted page is real sitemap... 
     154Check if resulted page really is sitemap... 
    145155 
    146156    >>> print browser.contents 
     
    148158 
    149159 
    150 To check urls, which pass filters - create regular expression... 
     160Create regular expression, which help us to test which urls pass the filters. 
    151161 
    152162    >>> reloc = re.compile("<loc>%s([^\<]*)</loc>" % self.portal.absolute_url(), re.S) 
    153163 
    154 With help of reloc regular expression - check if all 4 documents + default 
    155 front-page present in the sitemap without filters. 
     164Test if all 4 documents and default front-page present in the sitemap 
     165without filters. 
    156166 
    157167    >>> no_filters_res = reloc.findall(no_filters_content) 
     
    181191    >>> id_filter_content = browser.contents 
    182192 
    183 As result - all "doc1" and "front-page" documents must be 
    184 filtered-out from the sitemap. 
     193"doc1" and "front-page" documents should be excluded from the 
     194sitemap. 
    185195 
    186196    >>> id_filter_res = reloc.findall(id_filter_content) 
     
    194204=================== 
    195205 
    196 Suppouse we wont to filter-out doc2 of the test_user_1_'s (but  
    197 not from the portal root) and the front-page from the portal root. 
     206Suppouse we wont to exclude the "front_page" from portal root 
     207and "doc2" document, located in test_user_1_ home folder, 
     208but leave untouched "doc2" in portal root with all other objects. 
    198209 
    199210    >>> browser.open(smedit_url) 
     
    206217    >>> path_filter_content = browser.contents 
    207218 
    208 As result - "doc2" of the pointed member and "front-page" documents 
    209 must be filtered-out from the sitemap. 
     219"/Members/test_user_1_/doc2" and "/front_page" objects should 
     220be excluded from the sitemap. 
    210221 
    211222    >>> path_filter_res = reloc.findall(path_filter_content) 
    212223    >>> path_filter_res.sort() 
    213224    >>> print "\n".join(path_filter_res) 
    214     /Members/test_user_1_/doc1 
     225    /Membe rs/test_user_1_/doc1 
    215226    /doc1 
    216227    /doc2 
     
    220231==================== 
    221232 
    222 Lets check what filter should be used for old-feshion filters 
    223 (without any filter name prefixes)? 
    224  
    225 Go to the edit form of the sitemap and add "doc1" and front-page 
    226 lines without any filter name prefix to the "Blackout entries" 
    227 field. 
     233Now I have the question: "What filter will be used when no  
     234filter name prefix was specified (old-fashion filters for 
     235example)?" 
     236 
     237Go 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. 
    228240 
    229241    >>> browser.open(portal_url + "/sitemap.xml/edit") 
     
    236248    >>> default_filter_content = browser.contents 
    237249 
    238 By default "id" filter must be used, so all "doc1" and "front-page" 
    239 objects must be filtered-out from the sitemap. 
     250"id" filter must be used as default filter. So all "doc1" and 
     251"front-page" objects should be excluded from the sitemap. 
    240252 
    241253    >>> default_filter_res = reloc.findall(default_filter_content) 
     
    250262 
    251263Suppouse we want to create own blackout filter,  
    252 which behave like id-filter, but with some differencies. 
     264which behave like id-filter, but has some differencies. 
    253265Our fitler has following format: 
    254266 
    255267  (+|-)<filtered id> 
    256268 
    257   - when 1st sign "+" then only objects with <filtered id> 
    258     must leave after filetering, 
    259   - if 1st sign is "-" or  all objects with <filtered id> must be 
    260     filtered-out (like default id filter) 
     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). 
    261274 
    262275You need create new IBlckoutFilter multi-adapter, 
     
    289302    ...                name=u'signedid') 
    290303 
    291 So thet's all what neede to add new filter. 
    292 No test if newly added filter really take into consideration. 
    293  
    294 Check if white filtering ("+" prefix) work correctly. 
    295 Go to the edit form of the sitemap and add "signedid:+doc1" 
     304So that's all what needed to add new filter. 
     305Now test newly created filter. 
     306 
     307Check whether white filtering ("+" prefix) works correctly. 
     308Go to edit form of the sitemap and add "signedid:+doc1" 
    296309to the "Blackout entries" field. 
    297310 
     
    304317    >>> signedid_filter_content = browser.contents 
    305318 
    306 As result - only objects with "doc1" id must present in the sitemap. 
     319Only objects with "doc1" id should be leaved in the sitemap. 
    307320 
    308321    >>> signedid_filter_res = reloc.findall(signedid_filter_content) 
     
    313326 
    314327 
    315 An for the last - check black filtering ("-" prefix) is working. 
     328And for the last - check wheter black filtering ("-" prefix) 
     329works correctly. 
    316330Go to the edit form of the sitemap and add "signedid:-doc1" 
    317331to the "Blackout entries" field. 
     
    325339    >>> signedid_filter_content = browser.contents 
    326340 
    327 As result - all except objects with "doc1" id must present in the sitemap. 
     341All objects except those having "doc1" id must be included in 
     342the sitemap. 
    328343 
    329344    >>> signedid_filter_res = reloc.findall(signedid_filter_content) 
Note: See TracChangeset for help on using the changeset viewer.