Question about designators, again.

Tom Ekberg <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.user
Message-ID <MWHPR08MB29417A264F8BB02A79E8BDC1CA320@MWHPR08MB2941.namprd08.prod.outlook.com>
I have a tracker developer using a feature of roundup that appears to not be documented. In the current code, hyperdb.py defines this:

def splitDesignator(designator,
                    dre=re.compile(r'^([A-Za-z](?:[A-Za-z_0-9]*[A-Za-z_]+)?)(\d+)$')):
    """ Take a foo123 and return ('foo', 123)
    """
    m = dre.match(designator)
    if m is None:
        raise DesignatorError(_('"%s" not a node designator') % designator)
    return m.group(1), m.group(2)

Note that the regex doesn't allow the - (dash) charactor. The user has defined this class in schema.py:

idblock = Class(db, "idblock",
                mrn=String(indexme='yes'),
                accession_number=String(indexme='yes'),
                su_number=String(indexme='yes'),
                block_number=String(),
                tissue_type=String(),
                is_control=Boolean(),
                run=String(indexme='yes'),
                comment=String(),
                issue_id=Link('issue'))
idblock.setorderprop('activity')

and also added this property (column) to the issue class:

idblocks=Multilink("idblock")

In issue.item.html he added this code near the top:

 <tal:block tal:define="blocklist python:sorted(context.idblocks, key=lambda x: str(x.activity))">
 <tr tal:repeat="idblock blocklist">
  <td tal:content="idblock/mrn"></td>
  <td tal:content="idblock/accession_number"></td>
  <td tal:content="idblock/su_number"></td>
  <td tal:content="idblock/block_number"></td>
  <td tal:content="idblock/tissue_type"></td>
  <td tal:content="idblock/run"></td>
  <td tal:content="python: 'Control' if path('idblock/is_control') else ''"></td>
  <td tal:content="idblock/comment" colspan="4"></td>
  <td tal:content="idblock/activity"></td>
  <td>
   <a tal:attributes="href string:idblock${idblock/id}">Edit</a>
  </td>
 </tr>
    </tal:block>

This is defines in a small <table> which has column headers for the idblock properties. So far nothing special. In the same file immediately below the list of idblock values is this fragment:

<tr>
 <td ><input type="text" name="idblock-1@mrn" /></td>
 <td ><input type="text" name="idblock-1@accession_number" /></td>
 <td ><input type="text" name="idblock-1@su_number" /></td>
 <td ><input type="text" name="idblock-1@block_number" /></td>
 <td ><input type="text" name="idblock-1@tissue_type" /></td>
 <td ><input type="text" name="idblock-1@run" /></td>
 <td style="text-align:center"><input type="checkbox"  name="idblock-1@is_control" /></td>
 <td colspan="4" ><textarea name="idblock-1@comment" wrap="soft" rows="1" cols="80" ></textarea>
     <input type="hidden" name="@link@idblocks" value="idblock-1"/>
 </td>
</tr>

This fragment defines another small table which has column headers like the previous fragment. This fragment is where the user enters new values to create a new idblock object.

Both of these fragments are within the <form> / </form> block. Note the name attributes in the last code fragment. The idblock-1 looks like a field designator. But the - (dash) character isn't allowed in the hyperdb.splitDesignator function. He says he found code like this somewhere and says it is used to create more idblock instances. I have seen -1 in the search context (issue.search.html) with one of these labels: unassigned, empty, and most frequently not selected.

The file cgi/form_parser.py contains this line:

 classes = '|'.join(db.classes.keys())

and this a few lines later:

self.FV_DESIGNATOR = re.compile(r'(%s)([-\d]+)' % classes)

Note that this regex allows the - (dash) character in a form designator. [This regex is not well formed because it allows crazy deginators like ids like 50-49. A better regex is r'(%s)(-?\d+)', but that is another issue.]

Now for the question: Do you know about allowing a name attribute of the form: className-1@propName in issue.item.html to create new className object?

Tom Ekberg
Senior Computer Specialist
Department of Laboratory Medicine and Pathology
4th Floor, Pat Steel Building, currently WFH
Home: (253) 561-2509
Email: [email protected]

_______________________________________________
Roundup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/roundup-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.