Script Console - Jython - Getting the max index of actual history table

32 views
Skip to first unread message

Gábor

unread,
May 22, 2013, 11:30:34 AM5/22/13
to zaproxy...@googlegroups.com
Hi,

Could someone please let me know how to access max index of actual history table?

Here's what I do in Jython:

import org.parosproxy.paros.db.TableHistory as th
idx = th.lastIndex()

I'm getting the following message:
TypeError: lastIndex(): expected 1 args; got 0 in <script> at line number

I checked the source of TableHistory.java
Method lastIndex() is defined without arguments.

Not much I know about Java, just started with Jython to make scripts for ZAP.
Got some exposure to Python, though.
Maybe I'm missing some very basic thing.

Regards,

Gábor



thc202

unread,
May 22, 2013, 3:01:53 PM5/22/13
to zaproxy...@googlegroups.com
Hi.

Example script to access the history table being used by ZAP (and get the last index):

from org.parosproxy.paros.db import Database

Database.getSingleton().getTableHistory().lastIndex()


About the error message, in Python the first argument to an instance method (user-defined method) is the class instance. That's why it's saying that it expects 1 argument.
For more information (and better explanation) take a look at the entry "9.3.4 Method Objects" [1] of "The Python Tutorial" in the Python documentation.

[1] http://docs.python.org/2/tutorial/classes.html#method-objects

Best regards.

Gábor

unread,
May 23, 2013, 10:34:35 AM5/23/13
to zaproxy...@googlegroups.com
Hi,

Thanks for the help.


Regards,

Gábor
Reply all
Reply to author
Forward
0 new messages