On Sat, Jul 7, 2012 at 9:23 PM, Matt Chaput <
ma...@whoosh.ca> wrote:
>> FYI. There are some whoosh patches in here; I'd love to hear what I
>> would have to do to get these accepted.
>>
>> --Guido
>
> I'll apply the patches in compound.py (guard if mmap is unavailable) and gae (add file_modified method).
Great! Thanks for getting back to me so quickly.
Some remarks about these patches:
- The mmap problem is probably an indication of some confusion about
the abstraction that is implemented in filedb/compound.py. It seems
you actually use the mmap module only in one place; perhaps you could
move the import there so it fails more clearly when it is needed? (If
you get to that place when mmap is unavailable you'd get a rather
confusing AttributeError: 'NoneType' object has no attribute ...)
- I didn't immediately see any negative effects in Moin from always
returning 0 from file_modified(), but perhaps we can do better. It
shouldn't be hard to extend the DatastoreFile model class with a
'modified' property giving a int or float that is set to time.time()
whenever the entity is written, so we can return the actual mtime.
(I'd propose to use DateTimeProperty(auto_now=True), which
automatically takes care of this, but it returns a datetime value
which is somewhat problematic to convert to to seconds as you expect.)
- Let me know if you want me to send you improved patches for either
of these. (Do you use
codereview.appspot.com or some other code review
tool?)
> The patches in whoosh.index that make DatastoreStorage the default are less generally useful ;) I assume you modified whoosh.index.create_in() and whoosh.index.open_dir() because Moin is using them to create and open the index?
Heh, this was definitely a hack to get it working while I was fighting
other fires... TBH I had initially expected there to be some
configuration option that determines what storage backend to use. Are
there others besides the regular file storage and gae.py? I'm not sure
that whoosh has configuration of that kind, or whether the caller is
supposed to handle this by simply not calling those convenience
functions, or whether perhaps it would make sense to have an option
passed into all three functions (and their callers...?) to determine
what kind of storage to create or expect.
> If so, I think Moin should be modified to not use these convenience functions, which are hardwired to use FileStorage. Instead Moin should create/accept a storage object (through some configuration or API) and then use
>
> ix = storage.create_index(schema)
>
> and
>
> ix = storage.open_index()
>
> to create and open the index.
If that's your final answer I'll look into implementing this into Moin.
> Matt
>
> PS: Oops, the code in whoosh.index.create_in() is goofy; I think I got distracted in the middle of changing how it worked! Another thing to patch ;)
I'm not sure I understand the goofiness. But I'm not sure that matters. :)