Re: [Django] #24476: Allow using set_script_prefix as a contextmanager

2015-03-18 Thread Django
#24476: Allow using set_script_prefix as a contextmanager
-+-
 Reporter:  timgraham|Owner:  bpeschier
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Core (URLs)  |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

 * has_patch:  0 => 1
 * stage:  Accepted => Ready for checkin


Comment:

 Don't forget to check "Has patch" so the ticket appears in the review
 queue.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.17f2988519f01c4010902b4c93a3763c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24476: Allow using set_script_prefix as a contextmanager

2015-03-18 Thread Django
#24476: Allow using set_script_prefix as a contextmanager
-+-
 Reporter:  timgraham|Owner:  bpeschier
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Core (URLs)  |  Version:  master
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Graham ):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"0339844b70895d6162b4595ae615e6edf843c6cd" 0339844b]:
 {{{
 #!CommitTicketReference repository=""
 revision="0339844b70895d6162b4595ae615e6edf843c6cd"
 Fixed #24476 -- Added context manager/decorator for overriding script
 prefix.

 Tests were using an undocumented keyword argument for easily overriding
 script prefix while reversing. This is now changed into a test utility
 which can be used as decorator or context manager.
 }}}

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.47e43d96f2afdb515f177d8eeb9a7235%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24476: Allow using set_script_prefix as a contextmanager

2015-03-18 Thread Django
#24476: Allow using set_script_prefix as a contextmanager
-+-
 Reporter:  timgraham|Owner:  bpeschier
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Core (URLs)  |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by bpeschier):

 It is! :-)

 The PR uses ContextDecorator, but since a decorator gets called before you
 do anything, it would set the script prefix while importing the module if
 you put the meat in {{{__init__}}} which is required to make a direct call
 work.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.9966e5fd55bc5869276ae1d2404ddf7c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24476: Allow using set_script_prefix as a contextmanager

2015-03-17 Thread Django
#24476: Allow using set_script_prefix as a contextmanager
-+-
 Reporter:  timgraham|Owner:  bpeschier
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Core (URLs)  |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by bmispelon):

 You can probably use `contextlib.ContextDecorator` (backported in
 `django.utils.decorators`) to make it into a decorator as well.

 I don't have a particular opinion as to which approach is better though, I
 just liked the challenge of trying to make it work :)

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.31e2be4f8f0952d387fd0b2c87f30d3f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24476: Allow using set_script_prefix as a contextmanager

2015-03-17 Thread Django
#24476: Allow using set_script_prefix as a contextmanager
-+-
 Reporter:  timgraham|Owner:  bpeschier
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Core (URLs)  |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by bpeschier):

 Ah, yes. Combining context manager + call is doable, but not also with a
 decorator.

 I like the current implementation because it leaves the original code
 simple. It only defines a helper for the test use case.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.12f6154c595601742d9f59779fd95d7b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24476: Allow using set_script_prefix as a contextmanager

2015-03-15 Thread Django
#24476: Allow using set_script_prefix as a contextmanager
-+-
 Reporter:  timgraham|Owner:  bpeschier
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Core (URLs)  |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by bmispelon):

 Something like this should work:
 {{{#!python
 class set_script_prefix(object):
 """
 Sets the script prefix for the current thread.
 Can be called directly or used as a context manager.
 """
 def __init__(self, prefix):
 if not prefix.endswith('/'):
 prefix += '/'

 self._old_prefix = get_script_prefix()
 self._prefix = prefix
 self._set_prefix(prefix)

 def __enter__(self):
 return self._prefix

 def __exit__(self, exc_type, exc_val, exc_tb):
 self._set_prefix(self._old_prefix)

 def _set_prefix(self, prefix):
 _prefixes.value = prefix
 }}}

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.33724262e81c8b63447576c7d1a7433f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24476: Allow using set_script_prefix as a contextmanager

2015-03-15 Thread Django
#24476: Allow using set_script_prefix as a contextmanager
-+-
 Reporter:  timgraham|Owner:  bpeschier
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Core (URLs)  |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by bpeschier):

 Combining a contextmanager while allowing a normal function call turned
 out to be less trivial than thought. Changed it into a test util.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.55e15d3ea0bd7569a700bfe0d2abadaf%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24476: Allow using set_script_prefix as a contextmanager

2015-03-13 Thread Django
#24476: Allow using set_script_prefix as a contextmanager
-+-
 Reporter:  timgraham|Owner:  bpeschier
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Core (URLs)  |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

 * stage:  Unreviewed => Accepted


--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.56fc6cee34db786f510cbaf71ec857f1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24476: Allow using set_script_prefix as a contextmanager

2015-03-12 Thread Django
#24476: Allow using set_script_prefix as a contextmanager
-+-
 Reporter:  timgraham|Owner:  bpeschier
 Type:   |   Status:  assigned
  Cleanup/optimization   |
Component:  Core (URLs)  |  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by bpeschier):

 * owner:  nobody => bpeschier
 * status:  new => assigned


--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.6a0afeebedf37646e426e07dbc5bc383%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.