Hmmm, another vote for the XTypeTable always being the last XType in the list; serving as a ‘backstop’ if there are no more specific implementations. I hadn’t thought about the ArchiveTable XType. If person A persists my XType (adds it to the db), I need to make sure my XType is after ArchiveTable but before XTypeTable. I suppose there is a use case for overriding ArchiveTableXType (prepending it, but at this time I don’t see it…. My head hurts! Thanks for the code snippet.
On Thursday 29 February 2024 at 15:18:41 UTC-5 Karen K wrote: > I thought about observation types that are calculated within an XType, but > then saved to the database. After that summaries could be retrieved from > the database instead of calculated again. So I guess neither inserting the > XType at the beginning nor appending it at the end is the best solution. > For the weewx-GTS <https://github.com/roe-dl/weewx-GTS> extension I now > decided to insert it before XTypeTable, but after DailySummaries and > ArchiveTable like this: > > # Register the class > archive_seen = False > summaries_seen = False > for idx,xtype in enumerate(weewx.xtypes.xtypes): > if (isinstance(xtype,weewx.xtypes.XTypeTable) or > (archive_seen and > summaries_seen)): > weewx.xtypes.xtypes.insert(idx,self.GTSextension) > break > if isinstance(xtype,weewx.xtypes.ArchiveTable): > archive_seen = True > elif isinstance(xtype,weewx.xtypes.DailySummaries): > summaries_seen = True > else: > weewx.xtypes.xtypes.append(self.GTSextension) > > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/2ffcddf2-5695-4d24-bb49-c04de6b87467n%40googlegroups.com.
