Package: collective.weather
Table of ContentsLife, the Universe, and EverythingMostly HarmlessDon’t PanicInstallationUsageFinding locationsPortletViewletInternalsExtending the package with new weather providersNot entirely unlikeShare and EnjoyChangelog1.0a4 (2014-04-11)1.0a3 (2013-10-29)1.0a2 (2012-09-14)1.0a1 (2012-08-01)Life, the Universe, and EverythingA Plone package to display the current weather at selected locations inside a
portlet or viewlet.Mostly HarmlessGot an idea? Found a bug? Let us know byopening a support ticket.Don’t PanicInstallationTo enable this package on a buildout-based installation:Edit your buildout.cfg and addcollective.weatherto the list of eggs
to install:[buildout]
...
eggs =
    collective.weatherIf you are using Plone 4.1, you may need to extend a Dexterity known good
set (KGS) to make sure that you get the right versions of the packages that
make up Dexterity:[buildout]
...
extends =
    https://good-py.appspot.com/release/dexterity/1.2.1?plone=4.1.6After updating the configuration you need to run ‘’bin/buildout’’, which will
take care of updating your system.Go to the ‘Site Setup’ page in a Plone site and click on the ‘Add-ons’ link.Check the box next to ‘’collective.weather’’ and click the ‘Activate’ button.NoteYou may have to empty your browser cache and save your resource registries
in order to see the effects of the product installation.UsageGo to Site Setup and select ‘Weather’.Enter the list of locations that are going to be available on the site in the
following format:location_id|nameWherelocation_idshould be a unique value and not repeated among any of the
locations;nameis the name to be shown in the drop down (this doesn’t need
to be unique). Some examples could be:455827|São Paulo (for Yahoo! Weather)
-23.548871,-46.638814|São Paulo (for Forecast.io and Weather Underground)Select the sistem of units: Metric or Imperial. Metric system uses degrees
Celsius. Imperial system uses degrees Fahrenheit.Finding locationsDifferent weather service providers need different location ids to get
weather conditions.You’ll have to change theAvailable locationssetting depending on your
selection. Please, refer to providers documentation for more information:Yahoo Weatherneeds aWOEID. There’s a convenientonline tool to
get WOEID.Forecast.io APIjust needs alatitude, longitudecoordinate.Weather Undergroundaccepts many options (check thequeryoption).PortletThe package includes a portlet that you can add in your site.Open the ‘Manage portlets’ screen and select ‘Weather portlet’Set the title of the portletSelect a city from the listViewletWarningThe weather viewlet, as originaly planned, has proven to be pretty complex
to implement. Current implementation is still buggy. Use it at your own
risk.The package also includes a viewlet that will display the weather in one of
the locations defined in the settings. The viewlet will be displayed on top of
the site inside the IPortalHeader viewlet manager.To use the viewlet you need to activate it: go to Site Setup and select
‘Weather’ again. Select the ‘Show weather viewlet?’ box.The user will be able to select from one of the locations (this information
will be stored inside a cookie to show this location the next time the user
visits the site).The current weather condition of the selected location will be displayed at
the viewlet.InternalsNoteThis section could be outdated.The weather viewlet uses Javascript in order to change cities, so this will
only work for Javascript enabled browsers.To render the city weather, there is a “current-weather” view that will
render the latest info it has on weather conditions for a given city.
A cookie is used to get the latest chosen city, and you can override it
by passing a “city” argument to the view.To update the city weather, there is a “update-weather”, that, when called
without parameters, it will update all cities from the list.
You can pass a “city” argument to the view, to only update the given city.There’s an internal cache for each city (30 minutes), that if not enough
time has passed, then it will assume the current weather is updated, and
it will not do anything.The Javascript that changes the city, will call this “update-weather” for
the chosen city to update it first. Thanks to this internal cache, this
view will return fast, if not enough time has passed.In order to make it really fast for visitors of your site, you can set-up
a clockserver job to call this “update-weather” view with no params, once
every 30 minutes, so weather information for all your cities are ready for
when the visitor changes it from the drop-down.Extending the package with new weather providersIn case you want to contribute with new weather providers for this package or
if you want to add a new one in a custom package for your site you’ll just
need to create a new named utility that should implementcollective.weather.interfaces.IWeatherInfo.Weathercontrol panel will automatically learn about the new utility and
it will be listed as an option in the provider’s drop-down.This package already comes with some utilities you can check to get a quick
idea of how to create yours:yahooforecast.iowundergroundThe API for this utilityis very simple.In case your utility needsan API key you can pass it on initialization.Here’s and example you can copy and paste to start your custom utility:"""Example of a named utility for IWeatherInfo.
"""
from collective.weather.interfaces import IWeatherInfo
from zope.interface import implements


class DummyProvider(object):
    """Dummy weather implementation of IWeatherInfo
    """
    implements(IWeatherInfo)

    def __init__(self, key=None):
        self.key = key

    def getWeatherInfo(self, location, units='metric', lang='en'):
        """Dummy implementation of getWeatherInfo as an example
        """
        return {
            'summary': u'What a lovely day!',
            'temperature': 20,
            'icon': u'lovely-day-icon.png',
        }Not entirely unlikeWeather ForecastA very old an unmaintained product, Weather Forecast is a portlet that
will display the observation of the weather. Compatible with Plone 2.5.Share and Enjoycollective.weatherwould not have been possible without the contribution
of the following people:Franco Pellegrini (original author)Marcos F. RomeroHéctor VelardeSilvestre HuensGonzalo AlmeidaTango Desktop Project(icon)Adam Whitcroft’s Climacons(icon set)Development sponsored byOpenMultimedia.ChangelogThere’s a frood who really knows where his towel is.1.0a4 (2014-04-11)WarningThis release includes many changes in the package structure and is not
backwards compatible.Update package documentation.
[marcosfromero, hvelarde]Spanish and Brazilian Portuguese translations were updated. [hvelarde]Refactor weather_utility to use location_id as key. (closes#36).
[marcosfromero]Depend on plone.api and remove dependency on pywapi.
[hvelarde]New named utilities for Forecast.io and Weather Underground (closes#18).
[marcosfromero]New API for named utilities and Yahoo! Weather implementation.
[marcosfromero]The weather portlet is now configurable.
[marcosfromero]1.0a3 (2013-10-29)WarningThis release includes many changes in the package structure and is not
backwards compatible.Spanish and Brazilian Portuguese translations were updated. [hvelarde]Package documentation was updated. [hvelarde]A new option to define whether or not the weather viewlet is visible was
added; by default the viewlet is hidden (closes#14). [hvelarde]Control panel configlet was simplified; now all package settings are defined
in one screen (closes#19). [hvelarde]WeatherUtility is now registered as a global utility as we have no data to
persist on it (closes#7). If you’re still stock with aTypeError: ('object.new(WeatherUtility) is notsafe...error, keep calm an read the section dedicated tocomponentregistry.xmlonHow to make your Plone add-on products uninstall cleanly. May the
Force be with you. [hvelarde]Add weather portlet that displays weather conditions of current city
(closes#9). [marcosfromero]Remove all Google Weather related code. [marcosfromero]Weather conditions moved to title tag. [flecox]1.0a2 (2012-09-14)Made the code to be more resistent to invalid data from the weather server.
[frapell]Major refactoring to allow updates and city changes through AJAX calls
(fixes#6). [frapell]Implemented Yahoo! Weather. [frapell]1.0a1 (2012-08-01)Initial release.