Logo Search packages:      
Sourcecode: zeroinstall-injector version File versions

def zeroinstall::injector::iface_cache::IfaceCache::update_interface_from_network (   self,
  interface,
  new_xml,
  modified_time 
)

Update a cached interface.
Called by L{update_interface_if_trusted} if we trust this data.
After a successful update, L{writer} is used to update the interface's
last_checked time and then all the L{watchers} are notified.
@param interface: the interface being updated
@type interface: L{model.Interface}
@param new_xml: the downloaded replacement interface document
@type new_xml: str
@param modified_time: the timestamp of the oldest trusted signature
(used as an approximation to the interface's modification time)
@type modified_time: long
@raises SafeException: if modified_time is older than the currently cached time

Definition at line 251 of file iface_cache.py.

00251                                                                                 :
            """Update a cached interface.
            Called by L{update_interface_if_trusted} if we trust this data.
            After a successful update, L{writer} is used to update the interface's
            last_checked time and then all the L{watchers} are notified.
            @param interface: the interface being updated
            @type interface: L{model.Interface}
            @param new_xml: the downloaded replacement interface document
            @type new_xml: str
            @param modified_time: the timestamp of the oldest trusted signature
            (used as an approximation to the interface's modification time)
            @type modified_time: long
            @raises SafeException: if modified_time is older than the currently cached time
            """
            debug("Updating '%s' from network; modified at %s" %
                  (interface.name or interface.uri, _pretty_time(modified_time)))

            if '\n<!-- Base64 Signature' not in new_xml:
                  # Only do this for old-style interfaces without
                  # signatures Otherwise, we can get the time from the
                  # signature, and adding this attribute just makes the
                  # signature invalid.
                  from xml.dom import minidom
                  doc = minidom.parseString(new_xml)
                  doc.documentElement.setAttribute('last-modified', str(modified_time))
                  new_xml = StringIO()
                  doc.writexml(new_xml)
                  new_xml = new_xml.getvalue()

            self._import_new_interface(interface, new_xml, modified_time)

            import writer
            interface.last_checked = long(time.time())
            writer.save_interface(interface)

            info("Updated interface cache entry for %s (modified %s)",
                  interface.get_name(), _pretty_time(modified_time))

            for w in self.watchers:
                  w.interface_changed(interface)
      
      def _import_new_interface(self, interface, new_xml, modified_time):


Generated by  Doxygen 1.6.0   Back to index