Hi Malcom,
> Please post a small example fragment demonstrating what you're trying to
> do.
Here's the problem code:
class Xeme(models.Model):
"""Grapheme, phoneme, morpheme, etc - any linguistic entity
representable by a string."""
text = models.CharField(max_length=150, db_index=True)
type = models.PositiveSmallIntegerField(choices=XEME_TYPES)
language = models.ForeignKey(Language, db_index=True)
components = models.ManyToManyField('self',
symmetrical = False,
blank = True,
related_name = 'component_of')
class Meta:
unique_together = ('text', 'type', 'language')
def tokenize(self):
"""Break the text field into fragments which might match the
text
fields of
other Xemes. Returns an iterator."""
return TokenizerFactory.create(self.language.name)(self.text)
def update_components(self):
"""Find any xemes contained by this one (according to tokenize)
and
add
references to them in the components field."""
q_objects = [models.Q(text=text) for text in self.tokenize()]
if q_objects:
components = Xeme.objects.filter(reduce(lambda x, y: x
| y,
q_objects))
self.components.add(*components)
I've tried running the update_components method in Xeme.save (both
before and after calling Model.save), using the post_save signal and
using the Xeme's ModelAdmin.save_model() method, to no avail.
I tried printing the contents of db.connection.queries within
Xeme.save and saw the expected INSERT calls for update_components, but
without the expected result appearing in the database. I also noticed
that if I entered values for components myself in the admin interface,
they would appear, but I couldn't see any reference to them in the SQL
printed from Xeme.save(). That's how I got the idea it may be
happening elsewhere.
thanks for your help,
David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---