Re: [Tutor] Help search files

2007-07-05 Thread Alejandro Decchi

Yes i am a newbie in web design but i understand the concept of CGI. My
problem is that I do not know how to do a search based in binary
files.Forexample a user conect to my webpage and dicide to search
windows.iso he write in the textbox and put submit and must appear the
result to download the link.
Thz



On 7/5/07, Alan Gauld [EMAIL PROTECTED] wrote:


Alejandro Decchi [EMAIL PROTECTED] wrote

 Yes I have a debian server runing apache. Can you give me a link?

I could give you lots of links but which is most useful will depend
on your level of knowledge. I get the impression that you are not
experienced in Web development and so may not even understand
concepts like CGI? If so the best place to start is by searching for
a Web tutorial on how to write CGI applications. There are many
of these and probably one in your native language, read that first.

Then look at the CGI tutorial onthe Python web site:

http://wiki.python.org/moin/CgiScripts

as well as the documentation on the cgi module:

http://docs.python.org/lib/module-cgi.html

 do not how to make the search and list the files found to download

The list of files is just plain HTML. Here is some very
primitive code:

print ul
for name in ['foo.txt','bar.txt', 'baz.txt']:
  print li %s /li % name
print /ul

In your case you need to surround the name with an anchor link too.
None of this is Python specific it is just basic web programming in
HTML.

HTH,

Alan G.


 On 7/4/07, Alan Gauld [EMAIL PROTECTED] wrote:

 Alejandro Decchi [EMAIL PROTECTED] wrote

  Ok  but i have this form:
  body
  form id=form1 name=form1 method=post
  action=/cgi-bin/search.py

 OK, You didn't make it clear that you meant a CGI program,
 I was assuming you meant a GUI program. That adds a whole
 heap of extra complexity. A lot depends on what web
 mechanism/framework you are using. If we assume the
 standard cgi module then you need to get the submited
 data out of the request with the field_storage dictionary.
 Then you need to call your search function and finally
 format the results as HTML. Either offer to downoad a
 particular file and have a second request start the download
 or just send the file back, but that could be an unexpected result.
 I'd offer the file as a link and let the user click on it to fetch
 it
 from the server.

 But web programming is a whole different ball game.
 You should look up some simple examples first.

 Alan G.


 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor








 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Help search files

2007-07-04 Thread Alejandro Decchi

Hello Someone can help me how to search file in a directory. I need to do a
form where the user write the word to search and if the file was found the
user must could download the file making click in the link
Sorry my english
thz
Alex
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help search files

2007-07-04 Thread Alejandro Decchi

The user put the word or the regular expresion in a textbox i need to do
when ther user press the buttom submit call the file for example search.py .
I need to do this search.py file to find the file looking for ther user. If
the file or files are found i want to the user can download the files found
making click in the link listed in ther form

On 7/4/07, Alan Gauld [EMAIL PROTECTED] wrote:



Alejandro Decchi [EMAIL PROTECTED] wrote

 form where the user write the word to search
 and if the file was found

Do you mean the word is the filename (use glob module)
or the word is inside the file (use os.walk)?

Amnd do you need an exact match or a wild card search.
The latter will use either glob or regular expressions(re module)

 user must could download the file making click in the link

You can use the ftlib module for that.

HTH,

Alan G

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help search files

2007-07-04 Thread Alejandro Decchi

Is the word or part of the word that the user enters in the texbox .And this
word is the name of the file to be found



On 7/4/07, Alan Gauld [EMAIL PROTECTED] wrote:



Alejandro Decchi [EMAIL PROTECTED] wrote

 The user put the word or the regular expresion in a textbox i need
 to do
 when ther user press the buttom submit call the file for example
 search.py .
 I need to do this search.py file to find the file looking for ther
 user.

Is the word the user enters the name of the file to be found?
Or is it a word that we must search for inside the files?


Alan G


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help search files

2007-07-04 Thread Alejandro Decchi

perfect but can you give me a link to find a file in a directory.Because i
do not the function to search files in some directory. Can you give an
example :

On 7/4/07, Alan Gauld [EMAIL PROTECTED] wrote:



Alejandro Decchi [EMAIL PROTECTED] wrote

 Is the word or part of the word that the user enters in the texbox .
 And this word is the name of the file to be found

Ok, In that case use the glob function in the glob module.
It returns a list of all files that match a pattern:

 import glob
 files = glob.glob(*.txt)
 print files

For more powerful searches you can use os.walk()

See the OS topic in my tutorial for more examples of
using glob and os.walk

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help search files

2007-07-04 Thread Alejandro Decchi

Ok  but i have this form:
head
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /
titleDocumento sin tiacute;tulo/title
/head

body
form id=form1 name=form1 method=post action=/cgi-bin/search.py
 labelstrong search/strong
 input type=text name=textfield align=center /
 /label
 pnbsp;/p
 labelstrongfind it/strong
 input type=submit name=Submit value=Enviar /
 /label
 pnbsp;/p
/form
/body
/html



And i do not how to find the file looking for the user and list the file to
can download it.Can you give me an example 

Sorry to be a newbie !!!



On 7/4/07, Alan Gauld [EMAIL PROTECTED] wrote:


Just set the current directory to the one you want to search using

os.chdir(myPath)

or pass a full path to glob:

glob.glob(/some/path/to/search/*.txt)

HTH,

Alan G.

Alejandro Decchi [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 perfect but can you give me a link to find a file in a
 directory.Because i
 do not the function to search files in some directory. Can you give
 an
 example :

 On 7/4/07, Alan Gauld [EMAIL PROTECTED] wrote:


 Alejandro Decchi [EMAIL PROTECTED] wrote

  Is the word or part of the word that the user enters in the
  texbox .
  And this word is the name of the file to be found

 Ok, In that case use the glob function in the glob module.
 It returns a list of all files that match a pattern:

  import glob
  files = glob.glob(*.txt)
  print files

 For more powerful searches you can use os.walk()

 See the OS topic in my tutorial for more examples of
 using glob and os.walk

 HTH,

 --
 Alan Gauld
 Author of the Learn to Program web site
 http://www.freenetpages.co.uk/hp/alan.gauld


 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor








 ___
 Tutor maillist  -  Tutor@python.org
 http://mail.python.org/mailman/listinfo/tutor



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help search files

2007-07-04 Thread Alejandro Decchi

Yes I have a debian server runing apache. Can you give me a link ? Because i
do not how to make the search and list the files found to download

On 7/4/07, Alan Gauld [EMAIL PROTECTED] wrote:


Alejandro Decchi [EMAIL PROTECTED] wrote

 Ok  but i have this form:
 body
 form id=form1 name=form1 method=post
 action=/cgi-bin/search.py

OK, You didn't make it clear that you meant a CGI program,
I was assuming you meant a GUI program. That adds a whole
heap of extra complexity. A lot depends on what web
mechanism/framework you are using. If we assume the
standard cgi module then you need to get the submited
data out of the request with the field_storage dictionary.
Then you need to call your search function and finally
format the results as HTML. Either offer to downoad a
particular file and have a second request start the download
or just send the file back, but that could be an unexpected result.
I'd offer the file as a link and let the user click on it to fetch it
from the server.

But web programming is a whole different ball game.
You should look up some simple examples first.

Alan G.


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor