Example #1
0
            def _give_me_waffles(*args, **kwargs):
                origvalue = None
                # Avoid circular imports
                from waffle.models import Flag
                try:
                    flag = Flag.objects.filter(name=flagname)[0]
                    origvalue = flag.everyone
                    flag.everyone = flagvalue
                except waffle.Flag.DoesNotExist:
                    flag = Flag(name=flagname, everyone=True)
                flag.save()

                try:
                    return func(*args, **kwargs)
                except Exception:
                    # FIXME: This breaks if saving the flag also
                    # raises an exception, but that really shouldn't
                    # happen in our test suite and if it does, we've
                    # probably got other more serious issues to deal
                    # with.
                    if origvalue is not None:
                        flag.everyone = origvalue
                        flag.save()
                    raise
Example #2
0
            def _give_me_waffles(*args, **kwargs):
                origvalue = None
                # Avoid circular imports
                from waffle.models import Flag
                try:
                    flag = Flag.objects.filter(name=flagname)[0]
                    origvalue = flag.everyone
                    flag.everyone = flagvalue
                except waffle.Flag.DoesNotExist:
                    flag = Flag(name=flagname, everyone=True)
                flag.save()

                try:
                    return func(*args, **kwargs)
                except Exception:
                    # FIXME: This breaks if saving the flag also
                    # raises an exception, but that really shouldn't
                    # happen in our test suite and if it does, we've
                    # probably got other more serious issues to deal
                    # with.
                    if origvalue is not None:
                        flag.everyone = origvalue
                        flag.save()
                    raise