durusmail: qp: problem in publisher init
problem in publisher init
2005-11-26
2005-11-28
2005-11-28
2005-11-28
problem in publisher init
David Binger
2005-11-28
On Nov 26, 2005, at 6:01 AM, mario ruggier wrote:

> Hi,
>
> the qp Publisher's init does:
>
>     def __init__(self, connection=None, site=None):
>         set_publisher(self)
>         self.connection = connection or Connection(TempFileStorage())
>         self.set_hit(None)
>         self.ensure_initialized()
>         self.site = site or qp.lib.site.Site.get_sites().values()[0]
>         self.root_directory = self.site.get_root_directory_class()()
>
> however, if i override Publisher.ensure_initialized(), and in there
> I make use of something such as:

I think you probably should, instead, override the __init__() if your
initialization code requires the site (or the root_directory) to be
present.  This is better because your code will not then depend on the
ordering of these statements in the Publisher.__init__().

The ensure_initialized() method is really intended to make
sure that future calls to get_users() and get_sessions() can work
the first time a site starts.  It is probably best to avoid
mixing this purpose with some other, since commit() calls are
involved.




reply