Message info
 
To:Adam Roach From:Henrik Levkowetz Subject:Re: [Tools-discuss] Difficulty using DocumentInfo Date:Thu, 05 Apr 2012 23:18:47 +0200
 

Hi Adam,

On 2012-04-05 17:39 Adam Roach said the following:

<snip very complete presentation of problem>

The thing is, the 'external_url' attribute was not intended to be used
as a way to get the url of a document like a draft, agenda, charter,
etc.; which all reside at well-known paths in the server file-system;
it was meant as a way to record the url at which an _external_ document
(not residing on the datatracker server) could be found.

The conversion code has not adhered to this; which means that I failed
to communicate my intentions for this field.

It also means that both (b) and (c) below should be carried out -- for
(b) this means blanking out this field for docs with known locations.

> (a) Fixing the URL patterns so that the values in
> DocumentInfo.external_url work
> (b) Fixing the values in DocumentInfo.external_url so they match the
> existing URL patterns, or
> (c) Adding a new method to DocumentInfo that returns a value that can
> always be used in an href (and similar constructs); e.g. get_href()
>
> I can do (a) or (c) myself -- (b) would require that Henrik (or someone
> with similar access to the database) perform the fix-up.

For (c) I would suggest adding a dictionary to settings.py which
took the document prefix (the result of document.name.split('-',1)[0])
as a key, and returned a path format string, which would use a dictionary
of values relevant to the document to fill in the variable spots.

I'd use PEP 3101 format strings rather than the default %-formatting
in order to be able to express such things as zero-filled 2-digit
revision numbers (see http://www.python.org/dev/peps/pep-3101/)

You could have for instance

DOC_PATHS = {
...
"draft": "http://www.ietf.org/id/{doc.name}-{doc.rev:02}.txt",
...
}

to pick a simple example.

The get_href() would then pick the appropriate format string from the
DOC_PATHS setting, and use .format(doc) on it to fill in the blanks
-- *or*, if there were no pattern for the document prefix, return the
doc.external_url if set.

Some utility functions would probably be needed in order to make it
easy to get things such as meeting and group given a document.

(We probably should have another method to get the path of a document
on the local file system. That could probably be defined in terms of
get_url() together with an url lookup (or it could be done the other
way around, of course)).


Best regards,

Henrik
_______________________________________________
Tools-discuss mailing list
Tools-discuss@ietf.org
https://www.ietf.org/mailman/listinfo/tools-discuss