I will try this soon Alexei - thank you. May I ask why one has to rerun the
install command? Also, will have to rerun the install whenever I modify the
resource.py?
On Friday, May 6, 2016 at 7:50:07 AM UTC+1, Alexei Peters wrote:
>
> Andrea,
> I was able to achieve what you wanted by creating a resource.py file that
> inherits from arches_hip.
> I then only overwrite the function that you're interested in and made the
> changes you mentioned (entity_data = _('None')).
> I've attached the file here.
>
> in my settings file, nothing unusual:
> RESOURCE_MODEL = {'default': 'arches_la.models.resource.Resource'}
>
> I re-ran the install (python manage.py packages -o install) after adding
> this file and I got the result you expected.
> Hope any of this helps.
> Cheers,
> Alexei
>
>
> Director of Web Development - Farallon Geographics, Inc. - 971.227.3173
>
> On Thu, May 5, 2016 at 9:22 AM, Adam Cox <[email protected] <javascript:>
> > wrote:
>
>> Oh, sure. In fact, you can see them here (and the rest of the app):
>> https://github.com/mradamcox/afrh/blob/master/afrh/models/resource.py
>>
>> The forms imports reference the new forms I've made for this project, so
>> leave those out...
>>
>> On Thu, May 5, 2016 at 10:17 AM, <[email protected] <javascript:>>
>> wrote:
>>
>>> Thanks for this Adam. I tried applying your fixes, but clearly I must be
>>> missing some imports out, cause I get a DoesNotExist error on
>>> eamena.models.resource.Resource and, once that happens for the first time,
>>> even if I roll things back I am forced to raze elasticsearch and replace it
>>> with a backup copy. Could you by any chance post me the complete list of
>>> your imports on your app's resource.py.
>>>
>>> Thanks,
>>>
>>> Andrea
>>>
>>> On Wednesday, May 4, 2016 at 7:44:37 PM UTC+1, Adam Cox wrote:
>>>>
>>>> Ok, here's how I just got this to work:
>>>>
>>>> If you go back to the arches.models.resource file, you'll find that
>>>> there are a set of functions that should be moved together, in order for
>>>> them to correctly reference each other. The first two are bulk_index() and
>>>> index(). Both of these functions call four other indexing functions, one
>>>> of which is prepare_documents_for_map_index(), which you are trying to
>>>> modify. So, I'd recommend copying and pasted these six functions into
>>>> your
>>>> resource.py file.
>>>> bulk_index()
>>>> index()
>>>> prepare_documents_for_search_index()
>>>> prepare_documents_for_map_index()
>>>> prepare_terms_for_search_index()
>>>> prepare_documents_for_report_index()
>>>>
>>>> You'll also have to add (at least)
>>>> from arches.app.models.entity import Entity
>>>> to the top of your resource.py file. I already had some extra import
>>>> statements in mine when I did this, so there may something missing for you
>>>> when you try this.
>>>>
>>>> After adding those functions to my resource.py file, the map popup info
>>>> was updated as desired. Note that the index() function is called on a
>>>> resource any time you save a new node to it, so if it's not working right
>>>> away, edit the resource, save it, and return to the map view.
>>>>
>>>> Let me know if that works.
>>>>
>>>> Adam
>>>>
>>>> On Wed, May 4, 2016 at 12:06 PM, Adam Cox <[email protected]> wrote:
>>>>
>>>>> Sounds good. The .pyc file is a compiled version of a .py file which
>>>>> means that your resource.py file has been used by the app. One thing I
>>>>> do
>>>>> all the time is add print statements within functions to double check
>>>>> that
>>>>> they are being called. Just inside the prepare_documents_for_map_index
>>>>> function, try adding print "prepare_documents_for_map_index IS BEING
>>>>> USED"
>>>>> or something. Then watch the server console output.
>>>>>
>>>>> I haven't had to modify that function yet, but if a simple
>>>>> modification to it is not reflected, you may need to do a little
>>>>> sleuthing,
>>>>> because it's possible that it is only called from inside the arches
>>>>> "site-package", in which case you may need to migrate more functions to
>>>>> your own app and change some import statements. Alexei would have a
>>>>> better
>>>>> handle on that right now than I do...
>>>>>
>>>>> Adam
>>>>>
>>>>> On Wed, May 4, 2016 at 11:51 AM, <[email protected]> wrote:
>>>>>
>>>>>> Not only did I do that Adam, I also tried deleting both resource.py
>>>>>> files from my app and the Arches-HIP folder structure. No effect
>>>>>> whatsoever.
>>>>>>
>>>>>> A small update though. It would appear that, by setting up the
>>>>>> RESOURCE_MODEL path as you indicated and after restarting Postgres.app,
>>>>>> I
>>>>>> finally got django to re-render resource.pyc in my app folder (which I
>>>>>> had
>>>>>> deleted) - so the source file was finally accessed. However, once again
>>>>>> there has been no change in the entity_data default string, which still
>>>>>> gets displayed in the Resource map popup as 'None specified' despite my
>>>>>> having changed it to 'None' in resource.py.
>>>>>>
>>>>>> I look forward to more ideas,
>>>>>>
>>>>>> Andrea
>>>>>>
>>>>>>
>>>>>> On Wednesday, May 4, 2016 at 6:39:30 PM UTC+1, Adam Cox wrote:
>>>>>>>
>>>>>>> That's very strange. Just to confirm: you copied the
>>>>>>> arches_hip/models/resource.py file, pasted it into the corresponding
>>>>>>> directory of your own app, and then changed the RESOURCE_MODEL as
>>>>>>> described
>>>>>>> above, correct? That's all you should need to do...
>>>>>>>
>>>>>>> On Wed, May 4, 2016 at 11:23 AM, <[email protected]> wrote:
>>>>>>>
>>>>>>>> Hi Alexei, I am not using Apache. I edit our app on a Mac Yosemite
>>>>>>>> installation with Postgres.app. I should add that other .py files,
>>>>>>>> like
>>>>>>>> settings.py, can be modified 'on the fly' and changes are recognised
>>>>>>>> by the
>>>>>>>> app. It would appear that resource.py is an exception. I thought it
>>>>>>>> could
>>>>>>>> be a Django cache issue, but the MIDDLEWARE parameters in the
>>>>>>>> settings.py
>>>>>>>> file of Arches do not seem to include the caching ones, so this also
>>>>>>>> proved
>>>>>>>> to be a dead end.
>>>>>>>>
>>>>>>>> Any other ideas?
>>>>>>>>
>>>>>>>> Andrea
>>>>>>>>
>>>>>>>>
>>>>>>>> On Wednesday, May 4, 2016 at 6:02:40 PM UTC+1, Alexei Peters wrote:
>>>>>>>>>
>>>>>>>>> Hi Andrea,
>>>>>>>>> If you're using Apache, make sure to restart it after editing any
>>>>>>>>> .py file.
>>>>>>>>> Cheers,
>>>>>>>>> Alexei
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Director of Web Development - Farallon Geographics, Inc. -
>>>>>>>>> 971.227.3173
>>>>>>>>>
>>>>>>>>> On Wed, May 4, 2016 at 8:54 AM, <[email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> Thanks Adam, I have tried adding the string below, - still no
>>>>>>>>>> *.pyc. I even tried commenting off the RESOURCE_MODEL in the HIP
>>>>>>>>>> settings
>>>>>>>>>> (the default there is: RESOURCE_MODEL = {'default':
>>>>>>>>>> 'arches_hip.models.resource.Resource'}), still nothing. This is what
>>>>>>>>>> the
>>>>>>>>>> top of my settings.py in my app looks like now:
>>>>>>>>>>
>>>>>>>>>> PACKAGE_ROOT =
>>>>>>>>>> os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
>>>>>>>>>> PACKAGE_NAME = PACKAGE_ROOT.split(os.sep)[-1]
>>>>>>>>>> DATABASES['default']['NAME'] = 'arches_%s' % (PACKAGE_NAME)
>>>>>>>>>> DATABASES['default']['POSTGIS_TEMPLATE'] = 'template_postgis'
>>>>>>>>>>
>>>>>>>>>> ROOT_URLCONF = '%s.urls' % (PACKAGE_NAME)
>>>>>>>>>>
>>>>>>>>>> INSTALLED_APPS = INSTALLED_APPS + (PACKAGE_NAME,)
>>>>>>>>>> STATICFILES_DIRS = (os.path.join(PACKAGE_ROOT, 'media'),) +
>>>>>>>>>> STATICFILES_DIRS
>>>>>>>>>> TEMPLATE_DIRS = (os.path.join(PACKAGE_ROOT,
>>>>>>>>>> 'templates'),os.path.join(PACKAGE_ROOT, 'templatetags')) +
>>>>>>>>>> TEMPLATE_DIRS
>>>>>>>>>>
>>>>>>>>>> # Absolute filesystem path to the directory that will hold
>>>>>>>>>> user-uploaded files.
>>>>>>>>>> MEDIA_ROOT = os.path.join(PACKAGE_ROOT, 'uploadedfiles')
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> RESOURCE_MODEL = {'default':
>>>>>>>>>> '{}.models.resource.Resource'.format(PACKAGE_NAME)}
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Thanks for your help.
>>>>>>>>>>
>>>>>>>>>> Andrea
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Wednesday, May 4, 2016 at 3:00:46 PM UTC+1, Adam Cox wrote:
>>>>>>>>>>>
>>>>>>>>>>> Hi Andrea, you need to explicitly set your resource model in
>>>>>>>>>>> your settings.py file. Something like this:
>>>>>>>>>>>
>>>>>>>>>>> RESOURCE_MODEL = {'default':
>>>>>>>>>>> '{}.models.resource.Resource'.format(PACKAGE_NAME)}
>>>>>>>>>>>
>>>>>>>>>>> Once you run the app, you should see a .pyc file appear next to
>>>>>>>>>>> your app's models/resource.py file, meaning that it's now in use.
>>>>>>>>>>>
>>>>>>>>>>> Adam
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Wed, May 4, 2016 at 6:53 AM, <[email protected]> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hello All,
>>>>>>>>>>>>
>>>>>>>>>>>> I am having an issue with modifying resource.py both in my
>>>>>>>>>>>> installation of Arches and on the Arches-HIP. I am trying to
>>>>>>>>>>>> modify the
>>>>>>>>>>>> fields that are mapped as geojson (i.e. the section covered by the
>>>>>>>>>>>> function prepare_documents_for_map_index()). However, whenever I
>>>>>>>>>>>> modify
>>>>>>>>>>>> something within this function, it would appear that Django does
>>>>>>>>>>>> not
>>>>>>>>>>>> re-read my .py source file. I even tried to delete resource.py and
>>>>>>>>>>>> its .pyc
>>>>>>>>>>>> , and did the same with the corresponding files in the HIP. Still
>>>>>>>>>>>> nothing.
>>>>>>>>>>>> It would seem that the py file is not called. I thought it might
>>>>>>>>>>>> be an
>>>>>>>>>>>> elasticsearch issue, but then I re-ran it and nothing changed. It
>>>>>>>>>>>> would
>>>>>>>>>>>> appear that resource.py does not get called, which is strange
>>>>>>>>>>>> since I would
>>>>>>>>>>>> have expected prepare_documents_for_map_index() to be called when
>>>>>>>>>>>> visualising records with the Location Filter.
>>>>>>>>>>>>
>>>>>>>>>>>> Please note that I tried to modify static strings such as the
>>>>>>>>>>>> default entity_data=_('None specified'), to no avail.
>>>>>>>>>>>>
>>>>>>>>>>>> Can you help?
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks,
>>>>>>>>>>>>
>>>>>>>>>>>> Andrea
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> -- To post, send email to [email protected]. To
>>>>>>>>>>>> unsubscribe, send email to [email protected].
>>>>>>>>>>>> For more information, visit
>>>>>>>>>>>> https://groups.google.com/d/forum/archesproject?hl=en
>>>>>>>>>>>> ---
>>>>>>>>>>>> You received this message because you are subscribed to the
>>>>>>>>>>>> Google Groups "Arches Project" group.
>>>>>>>>>>>> To unsubscribe from this group and stop receiving emails from
>>>>>>>>>>>> it, send an email to [email protected].
>>>>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>> -- To post, send email to [email protected]. To
>>>>>>>>>> unsubscribe, send email to [email protected]. For
>>>>>>>>>> more information, visit
>>>>>>>>>> https://groups.google.com/d/forum/archesproject?hl=en
>>>>>>>>>> ---
>>>>>>>>>> You received this message because you are subscribed to the
>>>>>>>>>> Google Groups "Arches Project" group.
>>>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>>>> send an email to [email protected].
>>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>> -- To post, send email to [email protected]. To
>>>>>>>> unsubscribe, send email to [email protected]. For
>>>>>>>> more information, visit
>>>>>>>> https://groups.google.com/d/forum/archesproject?hl=en
>>>>>>>> ---
>>>>>>>> You received this message because you are subscribed to the Google
>>>>>>>> Groups "Arches Project" group.
>>>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>>>> send an email to [email protected].
>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>> -- To post, send email to [email protected]. To
>>>>>> unsubscribe, send email to [email protected]. For
>>>>>> more information, visit
>>>>>> https://groups.google.com/d/forum/archesproject?hl=en
>>>>>> ---
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Arches Project" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it,
>>>>>> send an email to [email protected].
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>
>>>> --
>>> -- To post, send email to [email protected] <javascript:>. To
>>> unsubscribe, send email to [email protected]
>>> <javascript:>. For more information, visit
>>> https://groups.google.com/d/forum/archesproject?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Arches Project" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected] <javascript:>.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> -- To post, send email to [email protected] <javascript:>. To
>> unsubscribe, send email to [email protected] <javascript:>.
>> For more information, visit
>> https://groups.google.com/d/forum/archesproject?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Arches Project" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
-- To post, send email to [email protected]. To unsubscribe, send
email to [email protected]. For more information,
visit https://groups.google.com/d/forum/archesproject?hl=en
---
You received this message because you are subscribed to the Google Groups
"Arches Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.