Thanks for the replies. I put the JSON file in htdocs as once it is written 
to it will be read from by a JQuery UI library that I am using (it needs to 
be stored in a file to allow for editing of the data). I see where you're 
coming from though so where would be best to put the file?

Both of the Itemplates methods are implemented as below:

>     def get_templates_dirs(self):
>
>         from pkg_resources import resource_filename
>
>         return [resource_filename(__name__, 'templates')]
>
>
>>     def get_htdocs_dirs(self):
>
>         from pkg_resources import resource_filename
>
>         return [('buildrequests', resource_filename(__name__, 'htdocs'))]
>
>
I tried changing the slashes to backward slahes but all that occurred was a 
different error message:

>  

Trac[buildrequests] ERROR: Exception occured writing to file: [Errno 2] No 
> such file or directory: 'buildrequests\\json\x08reqs.json'

Traceback (most recent call last):

  File "build\bdist.win32\egg\buildrequests\buildrequests.py", line 103, in 
> process_request

    file = open(breq_file, 'w')

IOError: [Errno 2] No such file or directory: 
> 'buildrequests\\json\x08reqs.json'


Slight confused as to why it interpreted the name of the file as it did! I 
use forward slashes to add the scripts and templates to the plugin so I 
think that's the correct way to go anyway. 

On Wednesday, 18 July 2012 03:57:57 UTC+1, olemis wrote:
>
> On 7/17/12, Steffen Hoffmann <[email protected]> wrote: 
> > Am 17.07.2012 18:45, wrote paul.wilding: 
> >> I'm trying to write a json serialization of data to a json file 
> >> stored in my plugin directory. The plugin is called buildrequests and 
> >> the file is found at 
> >> buildrequestsplugin\buildrequestsplugin\buildrequests\htdocs\json 
> > 
> > As a side-note I think it's poor design to write into htdocs, since this 
> > is meant to be served by web servers as static, cache-able content. 
> > 
>
> <OT?> 
>
> Exactly ! E.g. afaicr Graphviz plugin caches generated drawings due to 
> the fact that generating them is a time-consuming , resource intensive 
> task . 
>
> ... don't know exactly about the json files in this thread though ... 
>
> </OT?> 
>
> >> The error message written to the log is: 
> >> 
> >> Trac[buildrequests] ERROR: Exception occured writing to file: [Errno 
> >> 2] No such file or directory: 'buildrequests/json/breqs.json' 
> >> Traceback (most recent call last): File 
> >> "build\bdist.win32\egg\buildrequests\buildrequests.py", line 109, in 
> >> process_request file = open(breq_file, 'w') IOError: [Errno 2] No 
> >> such file or directory: 'buildrequests/json/breqs.json' 
> >> 
>
> ... if you ask me ... maybe it's that you are in Windows (<= ouch ! ;) 
> and you are not using the right path delimiter e.g. 
> buildrequests/json/breqs.json vs buildrequests\json\breqs.json 
>
> -- 
> Regards, 
>
> Olemis. 
>
> Blog ES: http://simelo-es.blogspot.com/ 
> Blog EN: http://simelo-en.blogspot.com/ 
>
> Featured article: 
>

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/trac-users/-/VIZSxikRzZsJ.
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/trac-users?hl=en.

Reply via email to