Modify

Opened 2 years ago

Last modified 14 months ago

#10116 new defect

SyntaxError in rules.py (ln: 222)

Reported by: vemundha Owned by: robguttman
Priority: normal Component: DynamicFieldsPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

Trying to run setup but get syntax error on line 222 in rules.py

byte-compiling build/bdist.linux-i686/egg/dynfields/rules.py to rules.pyc
  File "build/bdist.linux-i686/egg/dynfields/rules.py", line 222
    return 'type' if groups1.intersection(groups2) else None
                   ^
SyntaxError: invalid syntax

Last checkin added

# group rule
rule_re = re.compile(r"%s.(?P<op>(show|hide))_if_group" % target)
match = rule_re.match(key)
if match:
    groups1 = set(opts[key].split('|'))
    groups2 = set(self._get_groups(req.authname))
    if match.groupdict()['op'] == 'hide':
        return 'type' if groups1.intersection(groups2) else None
    else:
        return None if groups1.intersection(groups2) else 'type'

This is line 222

return 'type' if groups1.intersection(groups2) else None

Attachments (0)

Change History (8)

comment:1 follow-up: Changed 2 years ago by robguttman

vemundha, that is a python 2.6+ construct. Are you running Trac on < python 2.6?

comment:2 follow-up: Changed 2 years ago by vemundha

Using 2.4. So we maybe need to upgrade python then..

comment:3 in reply to: ↑ 2 Changed 2 years ago by robguttman

Replying to vemundha:

Using 2.4. So we maybe need to upgrade python then..

Actually it's a 2.5 feature:

http://en.wikipedia.org/wiki/Conditional_operator#Python

If upgrading your python version is an option, that would be best. There may be other plugins that also presume at least a 2.5 version. (2.4 as you know is quite old.)

comment:4 Changed 2 years ago by rjollos

Just thought I'd throw this out there since it's something I've encountered previously ... #9800 and Trac's source suggest a way to restrict the version of Python during plugin installation.

comment:5 in reply to: ↑ 1 ; follow-up: Changed 2 years ago by vemundha

Replying to robguttman:

vemundha, that is a python 2.6+ construct. Are you running Trac on < python 2.6?

We're running 2.4.
What is the latest DynamicFieldsPlugin version supporting this (or svn rev)? We currently run 1.2.1. But it don't work in IE. Works ok with Chrome, FF and Opera.

comment:6 in reply to: ↑ 5 ; follow-up: Changed 2 years ago by robguttman

Replying to vemundha:

What is the latest DynamicFieldsPlugin version supporting this (or svn rev)? We currently run 1.2.1. But it don't work in IE. Works ok with Chrome, FF and Opera.

Use the latest 0.11 branch (not the 0.12 branch).

I try to support all major browsers but I don't use and rarely get to test on IE. If you submit a detailed defect ticket with s specific IE issue, I will take a look.

Regarding the issue defined by this ticket, do you intend to upgrade your python to at least 2.5?

comment:7 in reply to: ↑ 6 Changed 2 years ago by vemundha

Replying to robguttman:

Regarding the issue defined by this ticket, do you intend to upgrade your python to at least 2.5?

No. We have to upgrade a lot of other egg 2.4 connections. So if it's possible to get the latest 0.11 branch working with 2.4 it would be great.

comment:8 Changed 14 months ago by rjollos

You could just change the line to (untested),

return groups1.intersection(groups2) and 'type' or None

and similarly for the else body,

return groups1.intersection(groups2) and None or 'type'

Add Comment

Modify Ticket

Action
as new .
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.