Hi guys,
Here's what I'm trying to do:
I want an upload page based on a widget with 2 fields, one being a file
field, and the other an autocomplete field for users to specify which
folder to put the uploaded file in. The autocomplete field will draw
its data from my database, listing only directories that the logged-in
user has in their directory.
Here's what I've tried so far:
I have autocomplete working just fine from the example in the trac
docs.
I've tried to modify the example so that it draws the info from my
database. Here's my code (from controllers.py, located directly above
my root controller):
class UploadFile(controllers.Controller):
def __init__(self):
super(UploadFile,self).__init__()
user=identity.current.user.user_name
folderdblist=list(Folder.select(Folder.q.user==user))
folders=[]
for folder in folderdblist:
folders+=[folder]
self.upload_form=widgets.TableForm(fields=[
widgets.FileField('file',label="File to
upload:"),
widgets.AutoCompleteField('folder',
only_suggest=True,
label="Folder to put file in:",
search_controller="search",
search_param="input",
result_name="matches")
],
submit_text="Upload file",
action="/save_file",
method="POST")
@expose(template="photogal.templates.upload")
def index(self):
return dict(upload_form=self.upload_form)
@expose(format = "json")
def search(self,input):
input=input.lower()
matches = [folder for folder in self.folders \
if folder.lower().find(input)!=-1]
return dict(matches=matches)
I then mount this controller in my root controller using
upload=UploadFile()
When I try to start my project, I get this message:
turbogears.identity.exceptions.RequestRequiredException: An attempt was
made to use a facility of the TurboGears Identity Management framework
that relies on an HTTP request outside of a request.
I am also not sure that my code is the correct way to do it - I don't
know whether this will work for each user, or just one. Any
suggestions on how to accomplish this?
Thanks,
Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
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/turbogears
-~----------~----~----~----~------~----~------~--~---