nausheenfatma / python-wikitools

Automatically exported from code.google.com/p/python-wikitools
0 stars 0 forks source link

page.exists True False None #41

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'm trying to use the default value None for the attribute exists.
The value is set to True or False in page.setPageInfo().
So we can know if the check has been done.

It allows several checks

if page.exists:
  ...
if page.exists is True:
  ...
(the two above are equivalent
but not the tree below)

if page.exists is None: # not checked : the page would be created
  ...
if page.exists is False: # checked but missing : the page would be modified
  ...
if not page.exists: # not checked or missing
  ...

Original issue reported on code.google.com by vpott...@gmail.com on 8 Jun 2011 at 7:17

GoogleCodeExporter commented 8 years ago
Would be good to overhaul all of these similar things at some point, it's 
currently a bit of a mess

Original comment by MrZmanwiki@gmail.com on 8 Jun 2011 at 10:44

GoogleCodeExporter commented 8 years ago

Original comment by MrZmanwiki@gmail.com on 8 Jun 2011 at 10:44

GoogleCodeExporter commented 8 years ago
(posted this commend on the wrong issue ... sorry)

Unless I'm using it incorrectly, it appears that trying to initialize a page 
with a section name is broken.  Doing wikitools.page.Page(site, 
title='PageName', section='SectionName') ends up setting self.section to 0.  
looking into it, it checks "if section or sectionnumber is not False" and then 
calls SetSection, passing in "section" and "sectionnumber" ... which in this 
case section is 'SectionName' and sectionnumber is False.  However, the default 
parameters of setSection are "None" ... not "False", so setSection gets 
confused about the passed in "False" and sets self.section to "str(int(False))" 
... which is 0.  Since that's the only internal call to setSection, I'm going 
to change the default parameters to that function to use "False" instead of 
"None" locally to see if that works better (since that seems to be the default 
parameter you like to use instead of None)

Original comment by pnow...@gmail.com on 16 Mar 2012 at 7:48