Closed Bug 530972 Opened 11 years ago Closed 11 years ago

Create an appropriately-named view that returns the xml for a domain.

Categories

(Webtools :: ISPDB Server, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: bwinton, Assigned: bwinton)

References

Details

Attachments

(1 file, 1 obsolete file)

Basically just like export_xml, but located at the right place so that Thunderbird could find it.  Actually maybe we can just use export_xml with a different parameter type.

With this fix, and the fix for bug 522253, we can set the "mailnews.auto_config_url" pref in Thunderbird to test our configs before we approve them.
Depends on: 522253
The patch to the tests will need to change, but I think the patches for the other two files should be good.

Oh, and this is based off of Louie's patch for bug 522253, which is part of the reason it's a WIP.

Later,
Blake.
Whiteboard: [wip-patch up, blocked on 526559]
There's some cleanup in here as well, to let me actually run the tests under Python 2.4 which I've been told is what the production site uses.

The main feature change is to config/views.py's export_xml function, and urls.py's urlpatterns.

The cleanup is
a) to use lxml everywhere, now that we're requiring it from Louie's patch;
b) to remove the ispdb -> . link that was causing a lot of problems with the test discovery; and
c) to update convert.py to accept the XML that the ispdb used to emit, so that we can import stuff like the Japanese configs, if they crop up in the future.

Thanks,
Blake.
Attachment #414530 - Attachment is obsolete: true
Attachment #416352 - Flags: review?(david.ascher)
Whiteboard: [wip-patch up, blocked on 526559] → [patch up, needs r davida]
Nice!

You could have 2 URLs: One for the newest non-invalid config for the domain, and one for the approved config (given that there's a significant delay between approval in ispdb and live.momo, see bug 526559).
We could, but since the approved configs will show up in autoconfig.mozillamessaging.com "shortly" after approval, I think it might be simpler to just have the url return the newest non-invalid config for the domain, and leave the only-approved-configs to autoconfig.mozillamessaging.com.

Also, that will give us an incentive to update autoconfig more frequently.  :)

(The back-end code to let us do that more easily is in place, we just need a script that Gozer can run to update the configs, and it could possibly be a nightly task.)

Later,
Blake.
Attachment #416352 - Flags: review?(david.ascher) → review+
Comment on attachment 416352 [details] [diff] [review]
A patch to look up the xml by domain.

can't find anything wrong =)
Comment on attachment 416352 [details] [diff] [review]
A patch to look up the xml by domain.

Hi Andy,

David mentioned that you'ld be willing to do some django reviews.

If you have any questions about the patch, or getting ISPDB set up, please feel free to email me or ping me on IRC.

Thank you,
Blake.
Attachment #416352 - Flags: review?(andy)
Whiteboard: [patch up, needs r davida] → [patch up, needs r andy]
Comment on attachment 416352 [details] [diff] [review]
A patch to look up the xml by domain.

Works for me, no new failing tests.

>--- a/config/views.py
>+++ b/config/views.py

>-def export_xml(request, id):
>-    config = Config.objects.filter(id=int(id))[0]
>+def export_xml(request, id=None, domain=None):
>+    config = None
>+    if id is not None:
>+        config = Config.objects.filter(id=int(id))[0]
>+    elif domain is not None:
>+        config = Domain.objects.filter(name=domain)[0].config
>     data = config.as_xml()

If id is None and domain is None, you're going to have an AttributeError there.  I haven't reached the urlconf yet, maybe that case isn't possible?


>--- a/convert.py
>+++ b/convert.py

>+    incoming_username_form = incoming.find('username')
>+    if incoming_username_form is None:
>+        incoming_username_form = incoming.find('usernameForm')
>+    incoming_username_form = incoming_username_form.text

Are you guaranteed to have username or usernameForm available?  The outgoing processing doesn't think so.  Does this warrant a function?

>-    url(r'^export_xml/(?P<id>\d+)', 'ispdb.config.views.export_xml', name='ispdb_export_xml'),
>+    url(r'^export_xml/(?P<id>\d+)$', 'ispdb.config.views.export_xml', name='ispdb_export_xml'),
>+    url(r'^export_xml/(?P<domain>.+)$', 'ispdb.config.views.export_xml', name='ispdb_export_xml'),

reverse can figure out which one you mean?  Cool!  Or maybe it's only looking at the latter url?
Attachment #416352 - Flags: review?(andy) → review+
(In reply to comment #7)
> >+    if id is not None:
> >+        config = Config.objects.filter(id=int(id))[0]
> >+    elif domain is not None:
> >+        config = Domain.objects.filter(name=domain)[0].config
> >     data = config.as_xml()
> If id is None and domain is None, you're going to have an AttributeError there.
>  I haven't reached the urlconf yet, maybe that case isn't possible?

Nope, it's not possible.

> >--- a/convert.py
> >+++ b/convert.py
> >+    incoming_username_form = incoming.find('username')
> Are you guaranteed to have username or usernameForm available?  The outgoing
> processing doesn't think so.  Does this warrant a function?

We are for incoming, but it's easier to put it in a function, so I did.

> >+    url(r'^export_xml/(?P<id>\d+)$', 'ispdb.config.views.export_xml', name='ispdb_export_xml'),
> >+    url(r'^export_xml/(?P<domain>.+)$', 'ispdb.config.views.export_xml', name='ispdb_export_xml'),
> reverse can figure out which one you mean?  Cool!  Or maybe it's only looking
> at the latter url?

It appears to figure out which one I mean, based on the tests, and the fact that we don't have domains named "1".  :)

Checked in as http://viewvc.svn.mozilla.org/vc?view=revision&revision=58258

Thanks,
Blake.
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [patch up, needs r andy]
Component: ispdb → ISPDB Server
Product: Mozilla Messaging → Webtools
You need to log in before you can comment on or make changes to this bug.