I'm not exactly sure what you're asking, but that won't stop me from
answering! :-)

The member function get_extension_list() will be called for each template.
So, if you have 10 templates, it will get called 10 times. If there is an
expensive calculation that does not depend on the timespan that needs to be
done, then it is best done in the initializer ('__init__') of your
extension.

There are 3 runtime options for extensions:
1. The initializer. Called once per skin.
2. In  get_extension_list(). Called once per template.
3. In the extension tag. Gets called when a '$' tag matches your extension
tag.

In general, you want expensive calculations to be done farther up this
list. But, if they depend on things only known farther down the list, in
particular, a timespan, then you're out of luck.

Hope this helps.

-tk


On Tue, Sep 8, 2020 at 12:14 AM Chris Davies-Barnard <
cdaviesbarn...@gmail.com> wrote:

> Good morning all,
>
> After an extended hiatus I am very happy to have a working and recording
> weather station again.  Unable to contain myself I am now tinkering with
> skins, extensions and data on https://davies-barnard.co.uk/
>
> Anyway,  my install of Weewx seems to be making repeated calls to the
> extension I'm playing around with.  Its quite computational so I want it to
> run only when required to stay up to date.
>
> *skin.conf*
> search_list_extensions = user.xstats.ExtendedStatistics,
> user.celestialPatterns.CelestialPatterns
>
> [[ToDate]]
> ...
> [[[celestialpatterns]]]
> template = celestialPatterns.html.tmpl
>
> My Extension
>
> def get_extension_list(self, timespan, db_lookup):
>     print("Extension Called")
>
>      #Get the seasons
>     seasons = self.getSeasons()
>
>      #Get all the sun/moon rises and sets for 12 months.
>      allRiseAndSet = self.getRiseAndSet()
>      ...
>
> def getSeasons(self):
>     print ("calling getSeasons")
>     ....
>
> def getRiseAndSet(self):
>     print("Calling getRiseAndSet")
>     ...
>
> *Is outputing:*
> daviesc@pecan-ubuntu:/home/weewx$ sudo ./bin/wee_reports weewx.conf
> Using configuration file weewx.conf
> Generating for all time
> Extension Called
> calling getSeasons
> Calling getRiseAndSet
> Extension Called
> calling getSeasons
> Calling getRiseAndSet
> Extension Called
> calling getSeasons
> Calling getRiseAndSet
> Extension Called
> calling getSeasons
> Calling getRiseAndSet
> Extension Called
> calling getSeasons
> Calling getRiseAndSet
> Extension Called
> calling getSeasons
> Calling getRiseAndSet
> Extension Called
> calling getSeasons
> Calling getRiseAndSet
> Extension Called
> calling getSeasons
> Calling getRiseAndSet
> Extension Called
> calling getSeasons
> Calling getRiseAndSet
> Extension Called
> calling getSeasons
> Calling getRiseAndSet
> daviesc@pecan-ubuntu:/home/weewx$
>
> I can see this could align with the number of entries
> under CheetahGenerator but it seems excessive or is it by design?    If
> someone could enlighten me I would be very grateful.
>
> Thanks again.
>
> Chris
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "weewx-development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to weewx-development+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/weewx-development/c904e46d-c4ec-4293-90ed-ae1a0b3fba24n%40googlegroups.com
> <https://groups.google.com/d/msgid/weewx-development/c904e46d-c4ec-4293-90ed-ae1a0b3fba24n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-development+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/CAPq0zECdMag6QfwsG0wcE%2BtT%3DJCaTGgPyvoDjogg3OV1y8qw4Q%40mail.gmail.com.

Reply via email to