FileCookieJar has not attribute "_self_load"

2009-01-16 Thread Dragos
I am trying to make a testing script to load/save cookies to a file
with FileCookieJar, but it results in this error: FileCookieJar has
not attribute "_self_load"

This is my script:

import urllib.request, urllib.parse,http.cookiejar
url="http://localhost/test.php";
cs=http.cookiejar.FileCookieJar()
cs.load("cookies.txt",ignore_discard=False, ignore_expires=False)
opener=urllib.request.build_opener(urllib.request.HTTPCookieProcessor
(cs))
y=opener.open(url)
print(y.read())

Thanks for helping.
--
http://mail.python.org/mailman/listinfo/python-list


Re: FileCookieJar has not attribute "_self_load"

2009-01-17 Thread Dragos
On Jan 16, 9:19 pm, Dragos  wrote:
> I am trying to make a testing script to load/save cookies to a file
> with FileCookieJar, but it results in this error: FileCookieJar has
> not attribute "_self_load"
>
> This is my script:
>
> import urllib.request, urllib.parse,http.cookiejar
> url="http://localhost/test.php";
> cs=http.cookiejar.FileCookieJar()
> cs.load("cookies.txt",ignore_discard=False, ignore_expires=False)
> opener=urllib.request.build_opener(urllib.request.HTTPCookieProcessor
> (cs))
> y=opener.open(url)
> print(y.read())
>
> Thanks for helping.

BUMP
--
http://mail.python.org/mailman/listinfo/python-list


Re: FileCookieJar has not attribute "_self_load"

2009-01-17 Thread Dragos
On Jan 17, 11:48 am, "Gabriel Genellina" 
wrote:
> En Fri, 16 Jan 2009 17:19:47 -0200, escribiste en el grupo
> gmane.comp.python.general
>
> > I am trying to make a testing script to load/save cookies to a file
> > with FileCookieJar, but it results in this error: FileCookieJar has
> > not attribute "_self_load"
>
> FileCookieJar is an abstract class, although it isn't clear at all from
> the documentation. (You may want to file a documentation bug 
> athttp://bugs.python.org)
> You must instantiate a specific subclass (like MozillaCookieJar), which
> determines the actual file format used.
>
> --
> Gabriel Genellina

Oh, thank you so much.
Using MozillaCookieJar works just fine.

But could you please explain what an abstract class is (or where i can
find documentation for this term). Thanks!
--
http://mail.python.org/mailman/listinfo/python-list


Re: FileCookieJar has not attribute "_self_load"

2009-01-17 Thread Dragos
On Jan 17, 1:33 pm, "Gabriel Genellina" 
wrote:
> En Sat, 17 Jan 2009 08:16:14 -0200, Dragos   
> escribió:
>
>
>
> > On Jan 17, 11:48 am, "Gabriel Genellina" 
> > wrote:
> >> En Fri, 16 Jan 2009 17:19:47 -0200, escribiste en el grupo
> >> gmane.comp.python.general
>
> >> > I am trying to make a testing script to load/save cookies to a file
> >> > with FileCookieJar, but it results in this error: FileCookieJar has
> >> > not attribute "_self_load"
>
> >> FileCookieJar is an abstract class, although it isn't clear at all from
> >> the documentation. (You may want to file a documentation bug  
> >> athttp://bugs.python.org)
> >> You must instantiate a specific subclass (like MozillaCookieJar), which
> >> determines the actual file format used.
>
> > Oh, thank you so much.
> > Using MozillaCookieJar works just fine.
>
> > But could you please explain what an abstract class is (or where i can
> > find documentation for this term). Thanks!
>
> Tryhttp://en.wikipedia.org/wiki/Abstract_class
> In short, it's an incomplete class, with "holes" that subclasses must fill  
> in order to get a complete, working class (a "concrete" class, as opposed  
> to the "abstract" base).
>
> If you look at FileCookieJar, its load() method calls self._really_load  
> but no such method exists in that class nor its ancestors (this explains  
> the error you got). Subclasses of FileCookieJar *must* implement  
> _really_load to be usable.
>
> It's customary to define the method anyway, and raise NotImplementedError;  
> this serves two purposes:
> - document the expected interfase
> - error messages are more meaningful
> (FileCookieJar.save() is implemented this way; _really_load() should be  
> the same)
>
> --
> Gabriel Genellina

Thanks, got it.
--
http://mail.python.org/mailman/listinfo/python-list