Thanks very much - it looks like you were right, using the file on a 'normal' filepath works fine!
On Thursday, 19 July 2012 08:11:07 UTC+1, Cooke, Mark wrote: > > > -----Original Message----- > > From: [email protected] On Behalf Of paul.wilding > > Sent: 18 July 2012 11:21 > > To: [email protected] > > Subject: Re: [Trac] Writing to a JSON file > > > > 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 may be barking up the wrong tree but my understanding is that your > plugin's `htdocs` is not a real folder, so you cannot write to it (it is a > convenience internal redirect into the contents of your egg file)... > > I have stored a similar file in the `attachments` folder but that was a > data file read only by the plugin. You would probably need to provide your > own sub-path of your plugin interface that returns the data file in an > appropriate way. > > In another case, I used a configurable path in the plugin conf so that the > server admin could setup a secure accessible area (may need extra apache > conf to allow the download). > > Hope that helps, > > ~ mark c > > > 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. > > > > -- 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/-/l_mj26cUeVgJ. 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.
