Merge lp:~bac/launchpadlib/lplib-comm_sub into lp:~launchpad-pqm/launchpadlib/devel

Proposed by Brad Crittenden
Status: Merged
Merged at revision: not available
Proposed branch: lp:~bac/launchpadlib/lplib-comm_sub
Merge into: lp:~launchpad-pqm/launchpadlib/devel
To merge this branch: bzr merge lp:~bac/launchpadlib/lplib-comm_sub
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Launchpad PQM Bot code Pending
Review via email: mp+2866@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Add XSLT processing for commercial_subscriptions

lp:~bac/launchpadlib/lplib-comm_sub updated
29. By Brad Crittenden

Added sample scripts.

30. By Brad Crittenden

Added helper files.

31. By Brad Crittenden

added a new sample test using sample-person

Revision history for this message
Curtis Hovey (sinzui) wrote :
Download full text (12.5 KiB)

Hi Brad

Thanks for adding the samples, I'm sure they will help people understand how to use launchapd lib. Your XSLT rule is broken; I suggest a fix.

> === modified file 'launchpadlib/wadl-to-refhtml.xsl'
> --- launchpadlib/wadl-to-refhtml.xsl 2009-01-13 17:30:59 +0000
> +++ launchpadlib/wadl-to-refhtml.xsl 2009-01-15 22:34:48 +0000
> @@ -379,6 +379,12 @@
> <xsl:text>/+wikiname/</xsl:text>
> <var>&lt;id&gt;</var>
> </xsl:when>
> + <xsl:when test="@id = 'commercial_subscription'">
> + <xsl:text>/</xsl:text>
> + <xsl:text>/+commercialsubscription/</xsl:text>
> + <xsl:text>/</xsl:text>
> + <var>&lt;commercial_subscription.id&gt;</var>
> + </xsl:when>

This instruction builds a path by concatenating text, and it does not look
correct. I see

    //+commercialsubscription//<commercial_subscription.id>

/me looks at source
Yep, I am right. Since the convention is to have wrap the view name in
"/"s, this markup should look like the h_w_device rules

            <xsl:when test="@id = 'commercial_subscription'">
                <xsl:text>/+commercialsubscription/</xsl:text>
                <var>&lt;commercial_subscription.id&gt;</var>
            </xsl:when>

> === added directory 'samples'
> === added file 'samples/_pythonpath.py'
> --- samples/_pythonpath.py 1970-01-01 00:00:00 +0000
> +++ samples/_pythonpath.py 2009-01-15 22:34:48 +0000
> @@ -0,0 +1,14 @@
> +__metaclass__ = type
> +
> +import sys, os, os.path

Put each import on its own line.

> +
> +# See if we can find launchpadlib and waddlib
> +try:
> + import launchpadlib
> + import wadllib
> +except ImportError:
> + # Modify sys.path to add trunk/lib.
> + HOME = os.environ['HOME']
> + trunk_path = os.environ.get('LP_TRUNK_PATH',
> + os.path.join(HOME, 'canonical/lp-branches/trunk'))

Wrap the code at 78 characters.

...

> === added file 'samples/lpapi.py'
> --- samples/lpapi.py 1970-01-01 00:00:00 +0000
> +++ samples/lpapi.py 2009-01-15 22:34:48 +0000
> @@ -0,0 +1,108 @@
> +#!/usr/bin/python2.4
> +import os
> +import sys
> +from urlparse import urljoin
> +import commands
> +
> +try:
> + from launchpadlib.launchpad import (
> + Launchpad, EDGE_SERVICE_ROOT, STAGING_SERVICE_ROOT)
> + from launchpadlib.credentials import Credentials
> + from launchpadlib.errors import *
> + import launchpadlib
> +except ImportError:
> + print >> sys.stderr, "Usage:"
> + print >> sys.stderr, " PYTHONPATH=somebranch/lib %s" % sys.argv[0]
> + raise
> +
> +
> +class InvalidCredentials(Exception):
> + pass
> +
> +
> +class Retry(Exception):
> + pass
> +
> +
> +class LPSystem:

Can you add docstrings to these. This is a great base class and exceptions
that I expect other people will use and evolve.'

> + endpoint = None
> + auth_file = None
> + def __init__(self, app_name='just testing', use_cache=True):
> + home = os.environ['HOME']
> + if use_cache:
> + cachedir = os.path.join(home, '.launchpadlib', 'cache')
> + if not os.path.exists(cachedir):
> + ...

review: Needs Fixing (code)
lp:~bac/launchpadlib/lplib-comm_sub updated
32. By Brad Crittenden

Changes per review.

33. By Brad Crittenden

Fixed typo

Revision history for this message
Brad Crittenden (bac) wrote :
Download full text (13.8 KiB)

On Jan 16, 2009, at 09:10 , Curtis Hovey wrote:

> Review: Needs Fixing code
> Hi Brad
>
> Thanks for adding the samples, I'm sure they will help people
> understand how to use launchapd lib. Your XSLT rule is broken; I
> suggest a fix.

Thanks for catching that dumb XSLT problem.

>
>
>> === modified file 'launchpadlib/wadl-to-refhtml.xsl'
>> --- launchpadlib/wadl-to-refhtml.xsl 2009-01-13 17:30:59 +0000
>> +++ launchpadlib/wadl-to-refhtml.xsl 2009-01-15 22:34:48 +0000
>> @@ -379,6 +379,12 @@
>> <xsl:text>/+wikiname/</xsl:text>
>> <var>&lt;id&gt;</var>
>> </xsl:when>
>> + <xsl:when test="@id = 'commercial_subscription'">
>> + <xsl:text>/</xsl:text>
>> + <xsl:text>/+commercialsubscription/</xsl:text>
>> + <xsl:text>/</xsl:text>
>> + <var>&lt;commercial_subscription.id&gt;</var>
>> + </xsl:when>
>
> This instruction builds a path by concatenating text, and it does
> not look
> correct. I see
>
> //+commercialsubscription//<commercial_subscription.id>
>
> /me looks at source
> Yep, I am right. Since the convention is to have wrap the view name in
> "/"s, this markup should look like the h_w_device rules
>
> <xsl:when test="@id = 'commercial_subscription'">
> <xsl:text>/+commercialsubscription/</xsl:text>
> <var>&lt;commercial_subscription.id&gt;</var>
> </xsl:when>
>

Fixed

>> === added directory 'samples'
>> === added file 'samples/_pythonpath.py'
>> --- samples/_pythonpath.py 1970-01-01 00:00:00 +0000
>> +++ samples/_pythonpath.py 2009-01-15 22:34:48 +0000
>> @@ -0,0 +1,14 @@
>> +__metaclass__ = type
>> +
>> +import sys, os, os.path
>
> Put each import on its own line.

Fixed

>
>
>> +
>> +# See if we can find launchpadlib and waddlib
>> +try:
>> + import launchpadlib
>> + import wadllib
>> +except ImportError:
>> + # Modify sys.path to add trunk/lib.
>> + HOME = os.environ['HOME']
>> + trunk_path = os.environ.get('LP_TRUNK_PATH',
>> + os.path.join(HOME, 'canonical/lp-
>> branches/trunk'))
>
> Wrap the code at 78 characters.

Done

>
>
> ...
>
>> === added file 'samples/lpapi.py'
>> --- samples/lpapi.py 1970-01-01 00:00:00 +0000
>> +++ samples/lpapi.py 2009-01-15 22:34:48 +0000
>> @@ -0,0 +1,108 @@
>> +#!/usr/bin/python2.4
>> +import os
>> +import sys
>> +from urlparse import urljoin
>> +import commands
>> +
>> +try:
>> + from launchpadlib.launchpad import (
>> + Launchpad, EDGE_SERVICE_ROOT, STAGING_SERVICE_ROOT)
>> + from launchpadlib.credentials import Credentials
>> + from launchpadlib.errors import *
>> + import launchpadlib
>> +except ImportError:
>> + print >> sys.stderr, "Usage:"
>> + print >> sys.stderr, " PYTHONPATH=somebranch/lib %s" %
>> sys.argv[0]
>> + raise
>> +
>> +
>> +class InvalidCredentials(Exception):
>> + pass
>> +
>> +
>> +class Retry(Exception):
>> + pass
>> +
>> +
>> +class LPSystem:
>
> Can you add docstrings to these. This is a great base class and
> exceptions
> that I expect other people will use and evolve.'

Yes. Done. Retry removed as it ...

Revision history for this message
Curtis Hovey (sinzui) wrote :

Hi Brad.

Thanks for making these changes. I approve this branch for merging.

review: Approve (code)
lp:~bac/launchpadlib/lplib-comm_sub updated
34. By Brad Crittenden

Merge from trunk

Subscribers

People subscribed via source and target branches