Modify

Opened 15 years ago

Closed 12 years ago

Last modified 12 years ago

#7299 closed defect (duplicate)

[Patch] Can't install plugin (Trac 0.12)

Reported by: dnedelchev Owned by: David Francos Cuartero
Priority: normal Component: TicketBackLinksMacro
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

On WinXP:

C:\...>easy_install http://trac-hacks.org/svn/ticketbacklinksmacro/0.11
Downloading http://trac-hacks.org/svn/ticketbacklinksmacro/0.11
Doing subversion checkout from http://trac-hacks.org/svn/ticketbacklinksmacro/0.11 to c:\docume~1\...\temp\easy_install-5vqhe8\0.11
Processing 0.11
Running setup.py -q bdist_egg --dist-dir c:\docume~1\...\temp\easy_install-5vqhe8\0.11\egg-dist-tmp-g_hk32
SyntaxError: ("'return' outside function", ('build\\bdist.win32\\egg\\TicketBackLinksDescription\\macro.py', 79, None, 'return buf.getvalue()\n'))

SyntaxError: ("'return' outside function", ('c:\\python26\\lib\\site-packages\\ticketbacklinksdescription-0.1-py2.6.egg\\TicketBackLinksDescription\\macro.py', 79, None, 'return buf.getvalue()\n'))

Adding ticketbacklinksdescription 0.1 to easy-install.pth file

Installed c:\python26\lib\site-packages\ticketbacklinksdescription-0.1-py2.6.egg

Processing dependencies for ticketbacklinksdescription==0.1
Finished processing dependencies for ticketbacklinksdescription==0.1

Attachments (1)

SQLWithLinkModification.zip (1.5 KB) - added by astaldo1977 14 years ago.

Download all attachments as: .zip

Change History (22)

comment:1 Changed 15 years ago by Kamil Kisiel

Line 78 and 79 need another four spaces in front of them.

comment:2 in reply to:  1 ; Changed 15 years ago by anonymous

Replying to kamil@kamilkisiel.net:

Line 78 and 79 need another four spaces in front of them.


With your patch install went OK. However after enabling the two present components of the plugin it still doesn't work.

Now [[TicketBackLinks(ticket)]] results in nothing that can be seen on the wiki page. (Before it resulted in a reference to an non-existent wiki page named TicketBackLinks(ticket)? )

comment:3 Changed 14 years ago by astaldo1977

Im not much into developing trac/python, but I tweaked with your source and with that ugly SQL script and I get it working. If someone is interested or tell me how to check it in you can contact me: astaldo1977@hotmail.com

comment:4 in reply to:  2 Changed 14 years ago by alex

Replying to anonymous:

With your patch install went OK. However after enabling the two present components of the plugin it still doesn't work.

Now [[TicketBackLinks(ticket)]] results in nothing that can be seen on the wiki page. (Before it resulted in a reference to an non-existent wiki page named TicketBackLinks(ticket)? )

I also repaired the source, build an egg, installed it and enabled the components. Now I am stuck with exactly the symptoms you described.

The returned HTML contains a closing ul-element at the macros position. This proves that it gets called, because the closing ul is outputted in any case, with or without elements to iterate: source:ticketbacklinksmacro/0.11/TicketBackLinksDescription/macro.py#L78

comment:5 Changed 14 years ago by alex

Trac Release: 0.110.12

comment:6 Changed 14 years ago by alex

It was my fault - I expected Links between Tickets and notice my error the moment I examined the SQL being built... :]

comment:7 Changed 14 years ago by Ryan J Ollos

#7489 is a duplicate.

comment:8 in reply to:  3 ; Changed 14 years ago by dnedelchev

I installed the plugin (patched in the way described above in #comment:1) on 0.12 but it works capriciously: Some references of a ticket are listed in the "Mentioned in" section generated by the macro, while other (including pretty new) references are not listed. I've had no time to find a repetitive pattern of that anomaly yet so I can't say how to reproduce it. (Once it's confirmed a real bug, a new ticket could be open for that)

Replying to astaldo1977:

Im not much into developing trac/python, but I tweaked with your source and with that ugly SQL script and I get it working. If someone is interested or tell me how to check it in you can contact me: astaldo1977@hotmail.com

Why not you just attach a patch here? So anyone could test it and when the plugin developer(s) are confident it's OK they could apply the patch to the trunk.

comment:9 in reply to:  8 Changed 14 years ago by Ryan J Ollos

Replying to dnedelchev:

Why not you just attach a patch here? So anyone could test it and when the plugin developer(s) are confident it's OK they could apply the patch to the trunk.

Often these patches don't upload due to an issue with the spam filter (see #7539), but if that's the case the patch author should compress (zip or tar) and upload the patch.

comment:10 in reply to:  8 Changed 14 years ago by dnedelchev

Replying to dnedelchev:

... Some references of a ticket are listed in the "Mentioned in" section generated by the macro, while other (including pretty new) references are not listed. ...

Yes, that's the SQL query again. I've tried fixing it with some success but it's not finished yet so I'll not post it now. I also think it's better if someone gets to fully rewrite it. I can try but I'm neither python nor SQL developer so I may not do it as fine as someone else would do.
I've just opened #7559 for that.

Changed 14 years ago by astaldo1977

Attachment: SQLWithLinkModification.zip added

comment:11 in reply to:  8 ; Changed 14 years ago by astaldo1977

Replying to dnedelchev:

Replying to astaldo1977:

Im not much into developing trac/python, but I tweaked with your source and with that ugly SQL script and I get it working. If someone is interested or tell me how to check it in you can contact me: astaldo1977@hotmail.com

Why not you just attach a patch here? So anyone could test it and when the plugin developer(s) are confident it's OK they could apply the patch to the trunk.

Ok here we go. I attached the patch as a zip file, so you have to download it. The reason I didnt uploaded it is that I added a function to the SQL Database to make my life easier. But.. look for yourself. Its basically a change of the SQL script with some modifications to the creation of the links. The SQL Statement looks for #123 pattern

comment:12 in reply to:  11 Changed 14 years ago by anonymous

Replying to astaldo1977@hotmail.com:

Ok here we go. I attached the patch as a zip file, so you have to download it. The reason I didnt uploaded it is that I added a function to the SQL Database to make my life easier. But.. look for yourself. Its basically a change of the SQL script with some modifications to the creation of the links. The SQL Statement looks for #123 pattern

Thanks! I'll try it. I tried to clean up the query using only "LIKE" functionality but it's likely impossible with that poor semi-regular-expressions syntax...
Your patch looks more complex than just fixing the database usage. It looks like you've added some extra functionality too.

comment:13 Changed 14 years ago by Ryan J Ollos

Summary: Can't install plugin (Trac 0.12)[Patch] Can't install plugin (Trac 0.12)

comment:14 Changed 14 years ago by dnedelchev

I applied the new patch (of course along with the one from 1 since else as we know plugin can't be loaded at all)
But for sorry I got runtime error. Did you tested it with SQLite? Or maybe there is some prerequisite required that is present in your Trac configuration and isn'e in mine?
The error message for ticket 16 was:

Error: Macro TicketBackLinks(16) failed
near "RLIKE": syntax error

and details in the trac.log:

OperationalError: near "RLIKE": syntax error
2010-08-29 09:27:33,342 Trac[formatter] ERROR: Macro TicketBackLinks(16) failed: 
Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg\trac\wiki\formatter.py", line 710, in _macro_formatter
    return macro.process(args, in_paragraph=True)
  File "C:\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg\trac\wiki\formatter.py", line 304, in process
    text = self.processor(text)
  File "C:\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg\trac\wiki\formatter.py", line 291, in _macro_processor
    text)
  File "C:\Python26\lib\site-packages\ticketbacklinksdescription-0.1-py2.6.egg\TicketBackLinksDescription\macro.py", line 93, in expand_macro
    cursor.execute(sql)
  File "C:\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg\trac\db\util.py", line 66, in execute
    return self.cursor.execute(sql)
  File "C:\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg\trac\db\sqlite_backend.py", line 78, in execute
    result = PyFormatCursor.execute(self, *args)
  File "C:\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg\trac\db\sqlite_backend.py", line 56, in execute
    args or [])
  File "C:\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg\trac\db\sqlite_backend.py", line 48, in _rollback_on_error
    return function(self, *args, **kwargs)
OperationalError: near "RLIKE": syntax error

comment:15 in reply to:  14 ; Changed 14 years ago by astaldo1977

Replying to dnedelchev:

I applied the new patch (of course along with the one from 1 since else as we know plugin can't be loaded at all)
But for sorry I got runtime error. Did you tested it with SQLite? Or maybe there is some prerequisite required that is present in your Trac configuration and isn'e in mine?
The error message for ticket 16 was: Error: Macro TicketBackLinks(16) failed near "RLIKE": syntax error

If you use SQLLite, you'll have to rename RLIKE with the name of the function used in SQLLite. After googleing around i found that replacing RLIKE with REGEXP should work for MySQL and SQLLite. Could you please check?

comment:16 in reply to:  15 Changed 14 years ago by dnedelchev

Replying to astaldo1977@hotmail.com:

If you use SQLLite, you'll have to rename RLIKE with the name of the function used in SQLLite. After googleing around i found that replacing RLIKE with REGEXP should work for MySQL and SQLLite. Could you please check?

I did it and that's the result:

Error: Macro TicketBackLinks(16) failed
near "(": syntax error
2010-08-29 15:00:55,296 Trac[formatter] ERROR: Macro TicketBackLinks(16) failed: 
Traceback (most recent call last):
  File "C:\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg\trac\wiki\formatter.py", line 710, in _macro_formatter
    return macro.process(args, in_paragraph=True)
  File "C:\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg\trac\wiki\formatter.py", line 304, in process
    text = self.processor(text)
  File "C:\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg\trac\wiki\formatter.py", line 291, in _macro_processor
    text)
  File "C:\Python26\lib\site-packages\ticketbacklinksdescription-0.1-py2.6.egg\TicketBackLinksDescription\macro.py", line 93, in expand_macro
    cursor.execute(sql)
  File "C:\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg\trac\db\util.py", line 66, in execute
    return self.cursor.execute(sql)
  File "C:\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg\trac\db\sqlite_backend.py", line 78, in execute
    result = PyFormatCursor.execute(self, *args)
  File "C:\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg\trac\db\sqlite_backend.py", line 56, in execute
    args or [])
  File "C:\Python26\lib\site-packages\trac-0.12-py2.6-win32.egg\trac\db\sqlite_backend.py", line 48, in _rollback_on_error
    return function(self, *args, **kwargs)
OperationalError: near "(": syntax error

P.S. I already have tried replacing LIKE with REGEXP but obviously it's not implemented, see trac:#8914 and http://www.sqlite.org/lang_expr.html#regexp :

The REGEXP operator is a special syntax for the regexp() user function. No regexp() user function is defined by default and so use of the REGEXP operator will normally result in an error message. If a application-defined SQL function named "regexp" is added at run-time, that function will be called in order to implement the REGEXP operator.

I also tried using GLOB instead of LIKE but only achieved the same effect as when using LIKE.

comment:17 Changed 14 years ago by dnedelchev

BTW, There are two different topics discussed here with two different patches suggested and they must be handled individually:

  • The patch from comment:1 which actually is a fix for the "Can't install plugin" issue. Obviously this issue is blocker / higher-priority. It's not explicitely attached as patch-file and is described verbously instead probably since the author decided it's quite simple (just indentation is affected)... This patch probably could be applied to the trunk as it is.

  • The second one is the patch attached as patch-file. It should be to fix the plugin's incorrect database query. And that's what we are discussing now.

I tried to separate these two issues creating the #7559 for the data-base-request but the discussion went on here...

comment:18 Changed 12 years ago by Ryan J Ollos

#10042 closed as a duplicate.

comment:19 Changed 12 years ago by Ryan J Ollos

Some of the issues in this ticket were fixed in #7832.

comment:20 in reply to:  17 Changed 12 years ago by Ryan J Ollos

Resolution: duplicate
Status: newclosed

Replying to dnedelchev:

I tried to separate these two issues creating the #7559 for the data-base-request but the discussion went on here...

Duplicate of #7559 and #7832 then. I'm patching up this plugin, and then merging the code into the BackLinksMacro.

I appreciate anyone that is willing to test out and code review recent versions of the TicketBackLinksMacro and BackLinksMacro.

comment:21 in reply to:  11 Changed 12 years ago by Ryan J Ollos

Replying to astaldo1977@hotmail.com:

Ok here we go. I attached the patch as a zip file, so you have to download it. The reason I didnt uploaded it is that I added a function to the SQL Database to make my life easier. But.. look for yourself. Its basically a change of the SQL script with some modifications to the creation of the links. The SQL Statement looks for #123 pattern

The patch won't work across SQLite, PostgreSQL and MySQL. For example, you use RLIKE, which isn't defined in SQLite. Making the query database agnostic is non-trivial. I made some comments about this in ticket/9175.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain David Francos Cuartero.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.