|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
reading txt files..I'm trying to create some python code to make it READ the contents of
a text [plainfiles.href] file and then display it in the "folder" of an album. I'm having a difficult time figuring out where "plainfiles.href" is defined. This is the variable name that gets passed to the default.ezt to be displayed in html format. Can anyone assist me? I think the type of python code I'm looking at is something like: print open(plainfiles.href).read() I'm guessing it'd be better to pass that to another variable: plainfilecontent = open(plainfiles.href).read() I just dont' know how to do this, nor where to put it in the .py code. I've been looking at it for a few days, and have become flustered :( Please halp! :) Ryan _______________________________________________ edna mailing list edna@... http://mailman.lyra.org/mailman/listinfo/edna |
|
|
Re: reading txt files..plainfiles starts life as a list of "objects" set in these lines:
if plainfiles_extensions.has_key(ext): plainfiles.append(_datablob(href=href, is_new=is_new, text=base)) continue inside a loop checking each file in the folder. What this does is make a list of 'object-looking things' in datablobs (which i distinctly do not like) that looks something like this: file1 -- file1.href = "server/readme.txt" file1.text = "readme" and then passes that list to the template rendering code (which is defined at line 691), where the template loops through that list and prints the URL and name for each file. If you wanted to output the contents of all text files you'd change it to something like this: plainfiles.append(_datablob(href=href, is_new=is_new, text=base, contents=open(fullpath+name).read())) Then you should be able to access the text from the template (probably default.ezt) and do whatever you need to with it. You should be able to get the value inside this section: [for plainfiles] as [plainfiles.contents]. You'll want to put it in a preformatted HTML tag to preserve normal linebreaks and spacing, like so:: <pre>[plainfiles.contents]</pre> It's a little confusing, and I can't say I entirely like the path getting from a folder URL request to the template, but it's a little less confusing if you just trace it through front to back (maybe with an open Python interpreter to mess about with). -Yoni p.s. I didn't test this. It should more or less work, but I just meant it to help you along, not solve it entirely. Good luck. On 3/30/07, MaxSteel <maxsteel@...> wrote: > I'm trying to create some python code to make it READ the contents of > a text [plainfiles.href] file and then display it in the "folder" of > an album. > > I'm having a difficult time figuring out where "plainfiles.href" is > defined. This is the variable name that gets passed to the > default.ezt to be displayed in html format. > > Can anyone assist me? I think the type of python code I'm looking at > is something like: > > print open(plainfiles.href).read() > > I'm guessing it'd be better to pass that to another variable: > > plainfilecontent = open(plainfiles.href).read() > > I just dont' know how to do this, nor where to put it in the .py code. > > I've been looking at it for a few days, and have become flustered :( > > Please halp! > :) > Ryan > _______________________________________________ > edna mailing list > edna@... > http://mailman.lyra.org/mailman/listinfo/edna > edna mailing list edna@... http://mailman.lyra.org/mailman/listinfo/edna |
|
|
Re: reading txt files..Thanks for replying Yoni.. I tried it.. but got this error:
Traceback (most recent call last): File "C:\Python24\lib\SocketServer.py", line 463, in process_request_thread self.finish_request(request, client_address) File "C:\Python24\lib\SocketServer.py", line 254, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Python24\lib\SocketServer.py", line 521, in __init__ self.handle() File "C:\Python24\lib\BaseHTTPServer.py", line 314, in handle self.handle_one_request() File "C:\Python24\lib\BaseHTTPServer.py", line 308, in handle_one_request method() File "D:\edna_xspf\edna.py", line 361, in do_GET self._perform_GET() File "D:\edna_xspf\edna.py", line 571, in _perform_GET plainfiles.append(_datablob(href=href, is_new=is_new, text=base, contents=op en(fullpath+name).read())) UnboundLocalError: local variable 'fullpath' referenced before assignment ---------------------------------------- You are right, this is a bit confusing.. I'm still plugging away, but if you get the chance in the meantime to assist, it'd be appreciated as usual, .\\ax On 3/31/07, Yoni Samlan <ysamlan@...> wrote: > plainfiles starts life as a list of "objects" set in these lines: > > if plainfiles_extensions.has_key(ext): > plainfiles.append(_datablob(href=href, is_new=is_new, text=base)) > continue > > inside a loop checking each file in the folder. > > What this does is make a list of 'object-looking things' in datablobs > (which i distinctly do not like) that looks something like this: > > file1 -- file1.href = "server/readme.txt" file1.text = "readme" > > and then passes that list to the template rendering code (which is > defined at line 691), where the template loops through that list and > prints the URL and name for each file. > > If you wanted to output the contents of all text files you'd change it > to something like this: > > plainfiles.append(_datablob(href=href, is_new=is_new, text=base, > contents=open(fullpath+name).read())) > > Then you should be able to access the text from the template (probably > default.ezt) and do whatever you need to with it. You should be able > to get the value inside this section: > > [for plainfiles] > > as [plainfiles.contents]. You'll want to put it in a preformatted HTML > tag to preserve normal linebreaks and spacing, like so:: > <pre>[plainfiles.contents]</pre> > > It's a little confusing, and I can't say I entirely like the path > getting from a folder URL request to the template, but it's a little > less confusing if you just trace it through front to back (maybe with > an open Python interpreter to mess about with). > > -Yoni > > p.s. I didn't test this. It should more or less work, but I just meant > it to help you along, not solve it entirely. Good luck. > > > On 3/30/07, MaxSteel <maxsteel@...> wrote: > > I'm trying to create some python code to make it READ the contents of > > a text [plainfiles.href] file and then display it in the "folder" of > > an album. > > > > I'm having a difficult time figuring out where "plainfiles.href" is > > defined. This is the variable name that gets passed to the > > default.ezt to be displayed in html format. > > > > Can anyone assist me? I think the type of python code I'm looking at > > is something like: > > > > print open(plainfiles.href).read() > > > > I'm guessing it'd be better to pass that to another variable: > > > > plainfilecontent = open(plainfiles.href).read() > > > > I just dont' know how to do this, nor where to put it in the .py code. > > > > I've been looking at it for a few days, and have become flustered :( > > > > Please halp! > > :) > > Ryan > > _______________________________________________ > > edna mailing list > > edna@... > > http://mailman.lyra.org/mailman/listinfo/edna > > > edna mailing list edna@... http://mailman.lyra.org/mailman/listinfo/edna |
|
|
Re: reading txt files..Ok I figured it out fullpath wasn't declared until after that line. I
just added a new declaration before "fullpathtemp" and this works: fullpathtemp = os.path.join(curdir, name) if plainfiles_extensions.has_key(ext): plainfiles.append(_datablob(href=href, is_new=is_new, text=base, contents=open(fullpathtemp).read())) continue I do now have a weird error coming up on the "server" screen... ---------------------------------------- Exception happened during processing of request from ('32.97.110.142', 44182) Traceback (most recent call last): File "C:\Python24\lib\SocketServer.py", line 463, in process_request_thread self.finish_request(request, client_address) File "C:\Python24\lib\SocketServer.py", line 254, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Python24\lib\SocketServer.py", line 521, in __init__ self.handle() File "C:\Python24\lib\BaseHTTPServer.py", line 314, in handle self.handle_one_request() File "C:\Python24\lib\BaseHTTPServer.py", line 308, in handle_one_request method() File "D:\edna_xspf\edna.py", line 361, in do_GET self._perform_GET() File "D:\edna_xspf\edna.py", line 606, in _perform_GET self.display_page(title, subdirs, pictures, plainfiles, songs, playlists) File "D:\edna_xspf\edna.py", line 722, in display_page template.generate(self.wfile, data) File "D:\edna_xspf\ezt.py", line 117, in generate self._execute(self.program, fp, ctx) File "D:\edna_xspf\ezt.py", line 124, in _execute step[0](step[1], fp, ctx) File "D:\edna_xspf\ezt.py", line 134, in _cmd_if_any self._do_if(value, t_section, f_section, fp, ctx) File "D:\edna_xspf\ezt.py", line 158, in _do_if self._execute(section, fp, ctx) File "D:\edna_xspf\ezt.py", line 124, in _execute step[0](step[1], fp, ctx) File "D:\edna_xspf\ezt.py", line 168, in _cmd_for self._execute(section, fp, ctx) File "D:\edna_xspf\ezt.py", line 124, in _execute step[0](step[1], fp, ctx) File "D:\edna_xspf\ezt.py", line 128, in _cmd_print fp.write(_get_value(refname, ref, ctx)) File "D:\edna_xspf\edna.py", line 1045, in write return self.wfile.write(s_buf) File "C:\Python24\lib\socket.py", line 256, in write self.flush() File "C:\Python24\lib\socket.py", line 243, in flush self._sock.sendall(buffer) error: (10053, 'Software caused connection abort') ---------------------------------------- any idea what is causing this? Thanks to all! .\\ax On 4/2/07, MaxSteel <maxsteel@...> wrote: > Thanks for replying Yoni.. I tried it.. but got this error: > > Traceback (most recent call last): > File "C:\Python24\lib\SocketServer.py", line 463, in process_request_thread > self.finish_request(request, client_address) > File "C:\Python24\lib\SocketServer.py", line 254, in finish_request > self.RequestHandlerClass(request, client_address, self) > File "C:\Python24\lib\SocketServer.py", line 521, in __init__ > self.handle() > File "C:\Python24\lib\BaseHTTPServer.py", line 314, in handle > self.handle_one_request() > File "C:\Python24\lib\BaseHTTPServer.py", line 308, in handle_one_request > method() > File "D:\edna_xspf\edna.py", line 361, in do_GET > self._perform_GET() > File "D:\edna_xspf\edna.py", line 571, in _perform_GET > plainfiles.append(_datablob(href=href, is_new=is_new, text=base, contents=op > en(fullpath+name).read())) > UnboundLocalError: local variable 'fullpath' referenced before assignment > ---------------------------------------- > > You are right, this is a bit confusing.. I'm still plugging away, but > if you get the chance in the meantime to assist, it'd be appreciated > as usual, > .\\ax > > On 3/31/07, Yoni Samlan <ysamlan@...> wrote: > > plainfiles starts life as a list of "objects" set in these lines: > > > > if plainfiles_extensions.has_key(ext): > > plainfiles.append(_datablob(href=href, is_new=is_new, text=base)) > > continue > > > > inside a loop checking each file in the folder. > > > > What this does is make a list of 'object-looking things' in datablobs > > (which i distinctly do not like) that looks something like this: > > > > file1 -- file1.href = "server/readme.txt" file1.text = "readme" > > > > and then passes that list to the template rendering code (which is > > defined at line 691), where the template loops through that list and > > prints the URL and name for each file. > > > > If you wanted to output the contents of all text files you'd change it > > to something like this: > > > > plainfiles.append(_datablob(href=href, is_new=is_new, text=base, > > contents=open(fullpath+name).read())) > > > > Then you should be able to access the text from the template (probably > > default.ezt) and do whatever you need to with it. You should be able > > to get the value inside this section: > > > > [for plainfiles] > > > > as [plainfiles.contents]. You'll want to put it in a preformatted HTML > > tag to preserve normal linebreaks and spacing, like so:: > > <pre>[plainfiles.contents]</pre> > > > > It's a little confusing, and I can't say I entirely like the path > > getting from a folder URL request to the template, but it's a little > > less confusing if you just trace it through front to back (maybe with > > an open Python interpreter to mess about with). > > > > -Yoni > > > > p.s. I didn't test this. It should more or less work, but I just meant > > it to help you along, not solve it entirely. Good luck. > > > > > > On 3/30/07, MaxSteel <maxsteel@...> wrote: > > > I'm trying to create some python code to make it READ the contents of > > > a text [plainfiles.href] file and then display it in the "folder" of > > > an album. > > > > > > I'm having a difficult time figuring out where "plainfiles.href" is > > > defined. This is the variable name that gets passed to the > > > default.ezt to be displayed in html format. > > > > > > Can anyone assist me? I think the type of python code I'm looking at > > > is something like: > > > > > > print open(plainfiles.href).read() > > > > > > I'm guessing it'd be better to pass that to another variable: > > > > > > plainfilecontent = open(plainfiles.href).read() > > > > > > I just dont' know how to do this, nor where to put it in the .py code. > > > > > > I've been looking at it for a few days, and have become flustered :( > > > > > > Please halp! > > > :) > > > Ryan > > > _______________________________________________ > > > edna mailing list > > > edna@... > > > http://mailman.lyra.org/mailman/listinfo/edna > > > > > > edna mailing list edna@... http://mailman.lyra.org/mailman/listinfo/edna |
|
|
Re: reading txt files..judging from the fact that it's ezt raising the exception, it looks
like something's wrong in your template or the values going into it. Throw some print statements in before you get to the template to be sure you're passing the right values over to it, and check your syntax in the templates (EZT doesn't really throw useful errors -- the port i'm working on for Pylons/WSGI is using Mako for the templates instead). -Yoni On 4/2/07, MaxSteel <maxsteel@...> wrote: > Ok I figured it out fullpath wasn't declared until after that line. I > just added a new declaration before "fullpathtemp" and this works: > > fullpathtemp = os.path.join(curdir, name) > if plainfiles_extensions.has_key(ext): > plainfiles.append(_datablob(href=href, is_new=is_new, > text=base, contents=open(fullpathtemp).read())) > continue > > I do now have a weird error coming up on the "server" screen... > > ---------------------------------------- > Exception happened during processing of request from ('32.97.110.142', 44182) > Traceback (most recent call last): > File "C:\Python24\lib\SocketServer.py", line 463, in process_request_thread > self.finish_request(request, client_address) > File "C:\Python24\lib\SocketServer.py", line 254, in finish_request > self.RequestHandlerClass(request, client_address, self) > File "C:\Python24\lib\SocketServer.py", line 521, in __init__ > self.handle() > File "C:\Python24\lib\BaseHTTPServer.py", line 314, in handle > self.handle_one_request() > File "C:\Python24\lib\BaseHTTPServer.py", line 308, in handle_one_request > method() > File "D:\edna_xspf\edna.py", line 361, in do_GET > self._perform_GET() > File "D:\edna_xspf\edna.py", line 606, in _perform_GET > self.display_page(title, subdirs, pictures, plainfiles, songs, playlists) > File "D:\edna_xspf\edna.py", line 722, in display_page > template.generate(self.wfile, data) > File "D:\edna_xspf\ezt.py", line 117, in generate > self._execute(self.program, fp, ctx) > File "D:\edna_xspf\ezt.py", line 124, in _execute > step[0](step[1], fp, ctx) > File "D:\edna_xspf\ezt.py", line 134, in _cmd_if_any > self._do_if(value, t_section, f_section, fp, ctx) > File "D:\edna_xspf\ezt.py", line 158, in _do_if > self._execute(section, fp, ctx) > File "D:\edna_xspf\ezt.py", line 124, in _execute > step[0](step[1], fp, ctx) > File "D:\edna_xspf\ezt.py", line 168, in _cmd_for > self._execute(section, fp, ctx) > File "D:\edna_xspf\ezt.py", line 124, in _execute > step[0](step[1], fp, ctx) > File "D:\edna_xspf\ezt.py", line 128, in _cmd_print > fp.write(_get_value(refname, ref, ctx)) > File "D:\edna_xspf\edna.py", line 1045, in write > return self.wfile.write(s_buf) > File "C:\Python24\lib\socket.py", line 256, in write > self.flush() > File "C:\Python24\lib\socket.py", line 243, in flush > self._sock.sendall(buffer) > error: (10053, 'Software caused connection abort') > ---------------------------------------- > > any idea what is causing this? > > Thanks to all! > .\\ax > > > > On 4/2/07, MaxSteel <maxsteel@...> wrote: > > Thanks for replying Yoni.. I tried it.. but got this error: > > > > Traceback (most recent call last): > > File "C:\Python24\lib\SocketServer.py", line 463, in process_request_thread > > self.finish_request(request, client_address) > > File "C:\Python24\lib\SocketServer.py", line 254, in finish_request > > self.RequestHandlerClass(request, client_address, self) > > File "C:\Python24\lib\SocketServer.py", line 521, in __init__ > > self.handle() > > File "C:\Python24\lib\BaseHTTPServer.py", line 314, in handle > > self.handle_one_request() > > File "C:\Python24\lib\BaseHTTPServer.py", line 308, in handle_one_request > > method() > > File "D:\edna_xspf\edna.py", line 361, in do_GET > > self._perform_GET() > > File "D:\edna_xspf\edna.py", line 571, in _perform_GET > > plainfiles.append(_datablob(href=href, is_new=is_new, text=base, contents=op > > en(fullpath+name).read())) > > UnboundLocalError: local variable 'fullpath' referenced before assignment > > ---------------------------------------- > > > > You are right, this is a bit confusing.. I'm still plugging away, but > > if you get the chance in the meantime to assist, it'd be appreciated > > as usual, > > .\\ax > > > > On 3/31/07, Yoni Samlan <ysamlan@...> wrote: > > > plainfiles starts life as a list of "objects" set in these lines: > > > > > > if plainfiles_extensions.has_key(ext): > > > plainfiles.append(_datablob(href=href, is_new=is_new, text=base)) > > > continue > > > > > > inside a loop checking each file in the folder. > > > > > > What this does is make a list of 'object-looking things' in datablobs > > > (which i distinctly do not like) that looks something like this: > > > > > > file1 -- file1.href = "server/readme.txt" file1.text = "readme" > > > > > > and then passes that list to the template rendering code (which is > > > defined at line 691), where the template loops through that list and > > > prints the URL and name for each file. > > > > > > If you wanted to output the contents of all text files you'd change it > > > to something like this: > > > > > > plainfiles.append(_datablob(href=href, is_new=is_new, text=base, > > > contents=open(fullpath+name).read())) > > > > > > Then you should be able to access the text from the template (probably > > > default.ezt) and do whatever you need to with it. You should be able > > > to get the value inside this section: > > > > > > [for plainfiles] > > > > > > as [plainfiles.contents]. You'll want to put it in a preformatted HTML > > > tag to preserve normal linebreaks and spacing, like so:: > > > <pre>[plainfiles.contents]</pre> > > > > > > It's a little confusing, and I can't say I entirely like the path > > > getting from a folder URL request to the template, but it's a little > > > less confusing if you just trace it through front to back (maybe with > > > an open Python interpreter to mess about with). > > > > > > -Yoni > > > > > > p.s. I didn't test this. It should more or less work, but I just meant > > > it to help you along, not solve it entirely. Good luck. > > > > > > > > > On 3/30/07, MaxSteel <maxsteel@...> wrote: > > > > I'm trying to create some python code to make it READ the contents of > > > > a text [plainfiles.href] file and then display it in the "folder" of > > > > an album. > > > > > > > > I'm having a difficult time figuring out where "plainfiles.href" is > > > > defined. This is the variable name that gets passed to the > > > > default.ezt to be displayed in html format. > > > > > > > > Can anyone assist me? I think the type of python code I'm looking at > > > > is something like: > > > > > > > > print open(plainfiles.href).read() > > > > > > > > I'm guessing it'd be better to pass that to another variable: > > > > > > > > plainfilecontent = open(plainfiles.href).read() > > > > > > > > I just dont' know how to do this, nor where to put it in the .py code. > > > > > > > > I've been looking at it for a few days, and have become flustered :( > > > > > > > > Please halp! > > > > :) > > > > Ryan > > > > _______________________________________________ > > > > edna mailing list > > > > edna@... > > > > http://mailman.lyra.org/mailman/listinfo/edna > > > > > > > > > > edna mailing list edna@... http://mailman.lyra.org/mailman/listinfo/edna |
|
|
Re: reading txt files..What's even more odd is that now the error doesn't come up.. lol
although, now, I do have a weird ? (question mark) on my page that's displayed.. I can't figure out where it's coming from.. ..although I haven't tried that much yet.. that'll come next/now :) Thanks a bunch Yoni, I'm obviously rusty, and wasn't understanding the code very much, and to be honest, didn't have enough time to really sit there and figure it out. I just want it to be functional.....then i'll make it purdy and be done with it (until the next thing i want to add to it).. It's definately starting to take shape! .\\ax On 4/2/07, Yoni Samlan <ysamlan@...> wrote: > judging from the fact that it's ezt raising the exception, it looks > like something's wrong in your template or the values going into it. > Throw some print statements in before you get to the template to be > sure you're passing the right values over to it, and check your syntax > in the templates (EZT doesn't really throw useful errors -- the port > i'm working on for Pylons/WSGI is using Mako for the templates > instead). > > -Yoni > > On 4/2/07, MaxSteel <maxsteel@...> wrote: > > Ok I figured it out fullpath wasn't declared until after that line. I > > just added a new declaration before "fullpathtemp" and this works: > > > > fullpathtemp = os.path.join(curdir, name) > > if plainfiles_extensions.has_key(ext): > > plainfiles.append(_datablob(href=href, is_new=is_new, > > text=base, contents=open(fullpathtemp).read())) > > continue > > > > I do now have a weird error coming up on the "server" screen... > > > > ---------------------------------------- > > Exception happened during processing of request from ('32.97.110.142', 44182) > > Traceback (most recent call last): > > File "C:\Python24\lib\SocketServer.py", line 463, in process_request_thread > > self.finish_request(request, client_address) > > File "C:\Python24\lib\SocketServer.py", line 254, in finish_request > > self.RequestHandlerClass(request, client_address, self) > > File "C:\Python24\lib\SocketServer.py", line 521, in __init__ > > self.handle() > > File "C:\Python24\lib\BaseHTTPServer.py", line 314, in handle > > self.handle_one_request() > > File "C:\Python24\lib\BaseHTTPServer.py", line 308, in handle_one_request > > method() > > File "D:\edna_xspf\edna.py", line 361, in do_GET > > self._perform_GET() > > File "D:\edna_xspf\edna.py", line 606, in _perform_GET > > self.display_page(title, subdirs, pictures, plainfiles, songs, playlists) > > File "D:\edna_xspf\edna.py", line 722, in display_page > > template.generate(self.wfile, data) > > File "D:\edna_xspf\ezt.py", line 117, in generate > > self._execute(self.program, fp, ctx) > > File "D:\edna_xspf\ezt.py", line 124, in _execute > > step[0](step[1], fp, ctx) > > File "D:\edna_xspf\ezt.py", line 134, in _cmd_if_any > > self._do_if(value, t_section, f_section, fp, ctx) > > File "D:\edna_xspf\ezt.py", line 158, in _do_if > > self._execute(section, fp, ctx) > > File "D:\edna_xspf\ezt.py", line 124, in _execute > > step[0](step[1], fp, ctx) > > File "D:\edna_xspf\ezt.py", line 168, in _cmd_for > > self._execute(section, fp, ctx) > > File "D:\edna_xspf\ezt.py", line 124, in _execute > > step[0](step[1], fp, ctx) > > File "D:\edna_xspf\ezt.py", line 128, in _cmd_print > > fp.write(_get_value(refname, ref, ctx)) > > File "D:\edna_xspf\edna.py", line 1045, in write > > return self.wfile.write(s_buf) > > File "C:\Python24\lib\socket.py", line 256, in write > > self.flush() > > File "C:\Python24\lib\socket.py", line 243, in flush > > self._sock.sendall(buffer) > > error: (10053, 'Software caused connection abort') > > ---------------------------------------- > > > > any idea what is causing this? > > > > Thanks to all! > > .\\ax > > > > > > > > On 4/2/07, MaxSteel <maxsteel@...> wrote: > > > Thanks for replying Yoni.. I tried it.. but got this error: > > > > > > Traceback (most recent call last): > > > File "C:\Python24\lib\SocketServer.py", line 463, in process_request_thread > > > self.finish_request(request, client_address) > > > File "C:\Python24\lib\SocketServer.py", line 254, in finish_request > > > self.RequestHandlerClass(request, client_address, self) > > > File "C:\Python24\lib\SocketServer.py", line 521, in __init__ > > > self.handle() > > > File "C:\Python24\lib\BaseHTTPServer.py", line 314, in handle > > > self.handle_one_request() > > > File "C:\Python24\lib\BaseHTTPServer.py", line 308, in handle_one_request > > > method() > > > File "D:\edna_xspf\edna.py", line 361, in do_GET > > > self._perform_GET() > > > File "D:\edna_xspf\edna.py", line 571, in _perform_GET > > > plainfiles.append(_datablob(href=href, is_new=is_new, text=base, contents=op > > > en(fullpath+name).read())) > > > UnboundLocalError: local variable 'fullpath' referenced before assignment > > > ---------------------------------------- > > > > > > You are right, this is a bit confusing.. I'm still plugging away, but > > > if you get the chance in the meantime to assist, it'd be appreciated > > > as usual, > > > .\\ax > > > > > > On 3/31/07, Yoni Samlan <ysamlan@...> wrote: > > > > plainfiles starts life as a list of "objects" set in these lines: > > > > > > > > if plainfiles_extensions.has_key(ext): > > > > plainfiles.append(_datablob(href=href, is_new=is_new, text=base)) > > > > continue > > > > > > > > inside a loop checking each file in the folder. > > > > > > > > What this does is make a list of 'object-looking things' in datablobs > > > > (which i distinctly do not like) that looks something like this: > > > > > > > > file1 -- file1.href = "server/readme.txt" file1.text = "readme" > > > > > > > > and then passes that list to the template rendering code (which is > > > > defined at line 691), where the template loops through that list and > > > > prints the URL and name for each file. > > > > > > > > If you wanted to output the contents of all text files you'd change it > > > > to something like this: > > > > > > > > plainfiles.append(_datablob(href=href, is_new=is_new, text=base, > > > > contents=open(fullpath+name).read())) > > > > > > > > Then you should be able to access the text from the template (probably > > > > default.ezt) and do whatever you need to with it. You should be able > > > > to get the value inside this section: > > > > > > > > [for plainfiles] > > > > > > > > as [plainfiles.contents]. You'll want to put it in a preformatted HTML > > > > tag to preserve normal linebreaks and spacing, like so:: > > > > <pre>[plainfiles.contents]</pre> > > > > > > > > It's a little confusing, and I can't say I entirely like the path > > > > getting from a folder URL request to the template, but it's a little > > > > less confusing if you just trace it through front to back (maybe with > > > > an open Python interpreter to mess about with). > > > > > > > > -Yoni > > > > > > > > p.s. I didn't test this. It should more or less work, but I just meant > > > > it to help you along, not solve it entirely. Good luck. > > > > > > > > > > > > On 3/30/07, MaxSteel <maxsteel@...> wrote: > > > > > I'm trying to create some python code to make it READ the contents of > > > > > a text [plainfiles.href] file and then display it in the "folder" of > > > > > an album. > > > > > > > > > > I'm having a difficult time figuring out where "plainfiles.href" is > > > > > defined. This is the variable name that gets passed to the > > > > > default.ezt to be displayed in html format. > > > > > > > > > > Can anyone assist me? I think the type of python code I'm looking at > > > > > is something like: > > > > > > > > > > print open(plainfiles.href).read() > > > > > > > > > > I'm guessing it'd be better to pass that to another variable: > > > > > > > > > > plainfilecontent = open(plainfiles.href).read() > > > > > > > > > > I just dont' know how to do this, nor where to put it in the .py code. > > > > > > > > > > I've been looking at it for a few days, and have become flustered :( > > > > > > > > > > Please halp! > > > > > :) > > > > > Ryan > > > > > _______________________________________________ > > > > > edna mailing list > > > > > edna@... > > > > > http://mailman.lyra.org/mailman/listinfo/edna > > > > > > > > > > > > > > > edna mailing list edna@... http://mailman.lyra.org/mailman/listinfo/edna |
|
|
Flash player - revisitedHi everybody,
I thought I'd point out that if you are interested in running an embedded flash player on your edna pages, this script works amazingly well: http://del.icio.us/help/playtagger I briefly had the xspf web music player (http://musicplayer.sourceforge.net/) installed but found that my browser would freeze while loading a lengthy list of files. Playtagger doesn't have the same effect and loads exceptionally quickly. Only drawbacks I've noticed: mp3 only and it doesn't handle special characters at all (ö,ó,etc) rendering a file that contains these characters unplayable. Not too big of a deal. The buttons can be customized a bit as the play and stop buttons are just small gifs. I don't use delicious so I don't know how useful it is in regards to bookmarking. Good luck! _______________________________________________ edna mailing list edna@... http://mailman.lyra.org/mailman/listinfo/edna |
| Free Forum Powered by Nabble | Forum Help |