Can't create new entities #2896

Closed
opened 2016-03-04 17:00:10 +00:00 by wjt · 2 comments
In [3]: Entity(type='participants', name='testy mctest').save()
---------------------------------------------------------------------------
<TypeError>                                 Traceback (most recent call last)
<ipython-input-3-9f2beaf78ba0> in <module>()
----> 1 Entity(type='participants', name='testy mctest').save()

/srv/pandora/pandora/entity/models.py in save(self, *args, **kwargs)
     56         else:
     57             self.name_sort = ox.sort_string(self.name or u'')[:255].lower() or None
---> 58         self.name_find = '|' + '|'.join((self.name,) + self.alternativeNames) + '|
     59         super(Entity, self).save(*args, **kwargs)
     60         self.update_matches()

<TypeError>: can only concatenate tuple (not "list") to tuple

Patch incoming…

``` In [3]: Entity(type='participants', name='testy mctest').save() --------------------------------------------------------------------------- <TypeError> Traceback (most recent call last) <ipython-input-3-9f2beaf78ba0> in <module>() ----> 1 Entity(type='participants', name='testy mctest').save() /srv/pandora/pandora/entity/models.py in save(self, *args, **kwargs) 56 else: 57 self.name_sort = ox.sort_string(self.name or u'')[:255].lower() or None ---> 58 self.name_find = '|' + '|'.join((self.name,) + self.alternativeNames) + '| 59 super(Entity, self).save(*args, **kwargs) 60 self.update_matches() <TypeError>: can only concatenate tuple (not "list") to tuple ``` Patch incoming…
0x2620 added the
general
label 2016-03-04 17:00:10 +00:00
0x2620 added this to the 14.04 milestone 2016-03-04 17:00:10 +00:00
0x2620 self-assigned this 2016-03-04 17:00:10 +00:00
0x2620 added the
normal
defect
labels 2016-03-04 17:00:10 +00:00
Author

Attachment 0001-Entity.alternativeNames-default-to-not-fixes-2896.patch (6670 bytes) added

Also in https://gitlab.com/wjt/pandora.git branch 2896-tuplefield

**Attachment** 0001-Entity.alternativeNames-default-to-not-fixes-2896.patch (6670 bytes) added Also in <https://gitlab.com/wjt/pandora.git> branch 2896-tuplefield
Will Thompson commented 2016-03-05 09:00:11 +00:00
Owner

In 0c98cd0/pandora:

#!CommitTicketReference repository="pandora" revision="0c98cd080e280899d44d42b7ab5c6c86f188622b"
Entity.alternativeNames: default to () not [] (fixes #2896)

Otherwise this:

    self.name_find = '||' + '||'.join((self.name,) + self.alternativeNames) + '||'
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

fails because () + [] is an error. I guess this must have been
introduced by the DictField/TupleField rewrite.

Without this fix, it is impossible to create a new entity.

Basically the same logic is used for Event and Place too so I've made
the same change to those, and, in passing, fix another copy of the bug
fixed for Entity.name_find in fe7f961.
In [0c98cd0/pandora](https://code.0x2620.org/0x2620/pandora/commit/0c98cd080e280899d44d42b7ab5c6c86f188622b): ``` #!CommitTicketReference repository="pandora" revision="0c98cd080e280899d44d42b7ab5c6c86f188622b" Entity.alternativeNames: default to () not [] (fixes #2896) Otherwise this: self.name_find = '||' + '||'.join((self.name,) + self.alternativeNames) + '||' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ fails because () + [] is an error. I guess this must have been introduced by the DictField/TupleField rewrite. Without this fix, it is impossible to create a new entity. Basically the same logic is used for Event and Place too so I've made the same change to those, and, in passing, fix another copy of the bug fixed for Entity.name_find in fe7f961. ```
0x2620 added the
fixed
label 2016-03-05 09:00:11 +00:00
Will Thompson closed this issue 2016-03-05 09:00:11 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: 0x2620/pandora#2896
No description provided.