ReadInputFromCache with Projects tip

Everything to do with the DnpUtils plugin for MyGeneration

ReadInputFromCache with Projects tip

Postby -nanook- on Wed Feb 13, 2008 11:55 am

I'm sure I can't be the only person who has had issues with this feature when implemented as described in the help files etc.

Please correct me if I've assumed something or misunderstood something.

Issue:
--------
When implementing the ReadInputFromCache the documentation instructs you to put the following line at the top of the \"Interface Code\":
Code: Select all
DnpUtils.ReadInputFromCache(context);

and the following line at the top of the \"Template Code\":
Code: Select all
DnpUtils.SaveInputToCache(context);


This works fine when running templates and generating code. I found that this gave me problems when working with Projects. Projects have their own settings so when you want change their settings you cannot edit them because the \"Record Template Input\" window always displays the last settings executed by the template. To work around this I have always executed the Project item before editing it to ensure the cached settings are correct.



Solution:
-----------
The solution is not to retrieve the settings from the cache when editing the Project item.

The only way I have found to do this is to check to see if the context.Gui.Defaults are already populated (by MyGeneration). If it is empty is indicates the template has been executed directly. If it contains items it indicates that it is a Project item.

So in the \"Interface Code\" instead of:

Code: Select all
DnpUtils.ReadInputFromCache(context);


Use the following 2 lines:


Code: Select all
  if (context.Gui.Defaults.Count == 0)
    DnpUtils.ReadInputFromCache(context);


------------------------

Please let me know if this helps anyone.
-nanook-
Lurker
 
Posts: 1
Joined: Wed Feb 13, 2008 11:34 am

Return to DnpUtils Plugin

Who is online

Users browsing this forum: No registered users and 1 guest