help-debbugs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 0/5] Download WSDL for SOAP services from servers


From: Michael Albinus
Subject: Re: [PATCH v2 0/5] Download WSDL for SOAP services from servers
Date: Sat, 16 Mar 2024 12:25:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Felix Lechner <felix.lechner@lease-up.com> writes:

> Hi Michael,

Hi Felix,

> I don't think debbugs.gnu.org currently serves a WDSL.  If it does,
> the SOAP library may be using a GET request. A "411" missing
> Context-Length header could mean the wrong request type.
>
> I created a file suitable for bugs.debian.org and asked Don Armstrong
> to please serve it at any URL, but have not heard back.

I don't expect that debbugs.gnu.org or bugs.debian.org will offer a WSDL
file any time soon. We must accept this, and use a local file instead
for these two servers.

>> The Debbugs package is divided into a backend and a frontend. The
>> backend is debbugs.el, and this is the only file which shall know about
>> SOAP, WSDL and alike.
>
> This updated patch series replaces the local wdsl object with caching.
> (Thanks, wasamasa!)  I like that solution much better.  Please let me
> know what you think.

I don't believe we need caching for the WSDL file. It is stable per
server (compared with the life time of an Emacs session), so we need to
retrieve it only once per server, and use it as-it-is.

>> Currently, we just change the value of debbugs-port if we want to access
>> another debbugs server. This isn't sufficient
>
> It may be sufficient now. The cache is an alist holding any
> "debbugs-ports" the user may desire.

Yes, your solution should work (not tested furthermore yet). See my
comments on the code.

First of all, please ensure that line lengths do not exceed the 80 char
width, which is Emacs convention. It reads much better in Emacs windows
which aren't extra wide.

> +(defvar debbugs-wsdl-cache-last-update-alist nil
> +  "Lisp timestamps per server for the most recent updates of the
> +WSDL cache used in SOAP access.")
> +
> +(defcustom debbugs-wsdl-cache-expiry 60
> +  "How many seconds to cache WSDL downloads.
> +t or 0 disables caching, nil disables expiring."
> +  :type '(choice (const :tag "Never" t)
> +              (const :tag "Forever" nil)
> +              (integer :tag "Seconds")))

Both not needed.

> +(defun debbugs-wsdl-cache-valid ()
> +  "True if the WSDL cache is valid timewise, nil otherwise."
> +  (let ((last-update (alist-get debbugs-port
> +                                debbugs-wsdl-cache-last-update-alist
> +                                nil nil 'equal)))
> +    (and (natnump debbugs-wsdl-cache-expiry)
> +         (not (null last-update))
> +         (let ((age (time-convert
> +                     (time-subtract (current-time) last-update)
> +                     'integer)))
> +           (< age debbugs-wsdl-cache-expiry)))))

Not needed.

> +(defun debbugs-get-soap-wsdl ()
> +  "Return the cached WSDL object describing the SOAP interface, or
> +download a new one."
> +  (let* ((cache-hit
> +          (if (or (not debbugs-wsdl-cache-expiry)
> +                  (debbugs-wsdl-cache-valid))
> +              (alist-get debbugs-port debbugs-wsdl-cache-alist nil nil 
> 'equal)
> +            nil))
> +         (wsdl-object (or cache-hit (debbugs-download-soap-wsdl))))
> +    (if (or (eq debbugs-wsdl-cache-expiry t)
> +            (eq debbugs-wsdl-cache-expiry 0))
> +        (progn
> +          (setq debbugs-wsdl-cache-alist nil)
> +          (setq debbugs-wsdl-cache-last-update-alist nil))
> +      (progn
> +        (setf (alist-get debbugs-port debbugs-wsdl-cache-alist nil nil 
> 'equal)
> +              wsdl-object)
> +        (setf (alist-get debbugs-port debbugs-wsdl-cache-last-update-alist 
> nil nil 'equal)
> +              (current-time))))
> +    wsdl-object))

If the entry for debbugs-port is nil, download the wsdl-object. Return
the existing wsdl-object afterwards. Something like (untested)

--8<---------------cut here---------------start------------->8---
(or (alist-get debbugs-port debbugs-wsdl-cache-alist nil nil 'equal)
    (let ((wsdl-object (debbugs-download-soap-wsdl)))
      (push `(,debbugs-port . ,wsdl-object) debbugs-wsdl-cache-alist)
      wsdl-object))
--8<---------------cut here---------------end--------------->8---

In debbugs-servers, replace the :wsdl entry for the two predefined
servers with the URL of the local WSDL file.

That's it, I believe.

> Kind regards
> Felix

Best regards, Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]