Serving Images through apache without a virtual host
I have been looking around at the forum and how people have been serving their images, but i can't seem to find exactly what i need. I am trying to create a site that produces a slideshow of graph plots in the form of images, so there is a very high volume of pictures that need to be served. So the most efficient method is to let apache take care of serving the images. The problem I am having is that the place i am setting up the site already has a couple of locations. For example, meerkat.sr.unh.edu/ganglia meerkat.sr.unh.edu/yin_grades and i want to add meerkat.sr.unh.edu/plotsite as a location and not a virtual host. I had the following set up: ServerName www.meerkat.sr.unh.edu DocumentRoot /var/www/realtime/plotsite/utils/media/ Alias /site_media/ "/var/www/realtime/plotsite/utils/media/" Allow from all Options all SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE plotsite.settings PythonOption django.root /plotsite PythonDebug On PythonPath "['/var/www/realtime']+sys.path" SetHandler None SetHandler None and it made the plotsite work fine, but it was removing access to the ganglia and yin_grades urls, so I'm wondering if i can serve the images using apache without creating a virtual host for my django project. If any one can help that would be great, thanks in advance for your time. Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Python lists
Hey, this is more of a python question than a django question. I have an XML parser set up to read some files and I want to create a list of dictionaries to pass to the method in the view. When i create the list, all the dictionary items end up being the same, instead of unique like they should be. The following is my endelement code for the content handler and i will include the code from the actual parser after that, thanks for any help that comes my way. def endElement(self, name): if name == 'vidars_search_result': return elif name == 'match': self.datasets.append(self.single) elif name == 'udi': self.single['udi'] = self.udiStr self.udi = 0 elif name == 'url': self.single['url'] = self.urlStr self.url = 0 elif name == 'start_date': self.single['start_date'] = self.start_dateStr self.start_date = 0 elif name == 'end_date': self.single['end_date'] = self.end_dateStr self.end_date = 0 elif name == 'data_set_type': self.single['data_set_type'] = self.data_set_typeStr self.data_set_type = 0 elif name == 'start_time': self.single['start_time'] = self.start_timeStr self.start_time = 0 elif name == 'end_time': self.single['end_time'] = self.end_timeStr self.end_time = 0 elif name == 'metadata': self.single['metadata'] = self.metadataStr self.metadata = 0 here is the parser: from xmlContent import GetSet from xml.sax import make_parser from xml.sax.handler import feature_namespaces class XMLParser: def __init__(self): self.datasets = [] def getDatasets(self): return self.datasets def execute_parser(self, file): f = open(file) parser = make_parser() parser.setFeature(feature_namespaces, 0) handler = GetSet() parser.setContentHandler(handler) parser.parse(f) self.datasets = handler.get_datasetList() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Error Messages
Well im using that API for an error message already, it doesn't create a new box, but it lists the error underneath the form. I am going to have long lists of names that i would like to display in an orderly fashion, and listing them in a box with the error message seems like the best method to me, I just dont know how to possibly combine the listof names with a javascript pop up box other some other type of box. On Jan 31, 1:40 pm, "Alex Ezell" <[EMAIL PROTECTED]> wrote: > Would the user messaging system work for you? > > http://www.djangoproject.com/documentation/authentication/#messages > > On Jan 31, 2008 12:33 PM, jacoberg2 <[EMAIL PROTECTED]> wrote: > > > > > Hey, > > I was wondering if anyone had a neat way to take a list of errors > > created in a template view and put it into an error box that would pop > > up over the webpage should the user cause an issue. Any help would be > > appreciated. Thanks for your time. > > Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Error Messages
Hey, I was wondering if anyone had a neat way to take a list of errors created in a template view and put it into an error box that would pop up over the webpage should the user cause an issue. Any help would be appreciated. Thanks for your time. Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Search MySQL Full-Text
Well i realized after i posted this that i am actually using postgresql and not Mysql. So i am wondering if there is a way to do boolean searches in the same manner as described at the end of th article. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MEDIA_ROOT, MEDIA_URL, ADMIN_MEDIA_PREFIX? Differences?
Hey, You have the media root correct, it points to a file in the system that contains the media. It is good for file upload use. The media url is basically what serves up the files and media for you, it is basically a site url, like if ur in the develpoment server it owuld be something like http://localhost: ... / The admin media prefix is another path to a media folder, this is related to the style of the admin interface i believe, that will just be a path to some folder on ur system. hope some of that helps, i struggled with the first two in my attempts to get a file upload system working. Search my user name a little more and u might find some more examples that might be better than mine, cause i had the same questions. Jacob On Oct 31, 12:17 pm, Stupid Dustbin <[EMAIL PROTECTED]> wrote: > Hi, > > I'm new to django and there is something that is confusing me about > the differences between > > MEDIA_ROOT > MEDIA_URL > ADMIN_MEDIA_PREFIX > > from what I read so far, media_root seem to be the folder that django > upload media files to. > > however for MEDIA_URL seem to be something like url/and > ADMIN_MEDIA_PREFIX i had not much clues. > > Would be nice to provide an easy example. > > Thanks. > > Additional Info that might help: > Using windows with django development server. Only learning, no plans > for site to be on a live site at all. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Search MySQL Full-Text
Hey I was just reading the tutorial about expanding the search capability of django by using the full text search of MySQL. At the end of the articale the author informs us that there is a boolean search operator in the data base api, this is the link he gave: http://www.djangoproject.com/documentation/db_api/#search now i was just wondering exactly what i would have to do to activate this so that i can use boolean operators in the search bar in my template. Im also pretty sure that my copy of django is a little older, so i would also like to know what i may need to update in order to use the search operator. Any help with this would be great! Jacob Berg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Searching the Database
Hey, I have been looking through the discussions and I have seen several different methods of indexing and searching. I was wondering what the best way might be to create a search engine for my django site that allows the user to enter different boolean operators and wildcard operators into the search bar and find matching items in the data base. I keep hearing about swish-e and other indexing programs, but I do not have files to index, just items in the data base that i want to dynamically search and return. Any suggestions on the fastest and simplest way to acomplish this task? Thanks, Jacob Berg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Check box form
Thanks for all the help, I am still using some oldforms because i picked up this project from someone else, so thanks for the html work around. I will keep the newforms method in mind as well when an update rolls around. Again, this was a great help. Jacob On Oct 17, 5:30 pm, rskm1 <[EMAIL PROTECTED]> wrote: > On Oct 17, 1:52 pm, jacoberg2 <[EMAIL PROTECTED]> wrote: > > > I am trying to create a checkbox form so that the user can delete a > > large number of > > registrations at once. I am wondering how I should set up the view in > > order to deal with > > the incoming data. Any suggestions? > > The template can generate its own HTML easily enough without using a > forms.Form, e.g. > > > {% for t in thingylist %} > > {{ t.longname|escape }} > {% endfor %} > > > Then, when you're processing the POST form data, it's absolutely vital > that you call the POST.getlist('thingies') method rather than just > dereferencing POST['thingies'] ! > > if httpreq.POST.has_key('thingies'): > selectedthingies = httpreq.POST.getlist('thingies') > > I struggled with that for quite a while when I made my first checkbox > form in Django; I was expecting a list or tuple to be right there in > the POST for me to grab directly. But nope, you gotta use the > getlist() method. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Check box form
Hey, I am trying to create a checkbox form so that the user can delete a large number of registrations at once. I am wondering how I should set up the view in order to deal with the incoming data. Any suggestions? Thanks for any help i can get. Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Validating Unique filenames and file types
Hey, I finally got a file upload working and now i want to be sure of what people are uploading. I am trying to write some custom validators, but have a little difficulty about starting. One thing that i think should be considered in the file field, is the option 'unique'. when ever i set it equal to true, i get a programming error, that says have a context error. I would think this was the unique at work but i know that there is nothing in the database so it shouldnt be throwing any error, since the file really is unique. So it would be cool if that worked sooner or later. The other major concern is the type of file, i want to check and make sure that each file uploaded is a .ini file for reading. So any suggestions would be greatly appreciated. Jacob Berg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Validators
Thanks for the update! On Oct 9, 1:50 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2007-10-09 at 10:44 -0700, jacoberg2 wrote: > > I have regular and custom validators in my models. > > I also have a custom manipulator in my view, so i can get the field > > data in a > > form. Is it necessary to put the validators in the custom manipulator > > in order > > to dynamically present the errors in the templates, as to alert the > > user of the site what they are doing wrong in the form? If not how > > would this be accomplished? > > At the moment, you probably do have to do some kind of workaround like > that, because we have only partially implemented validate() on models. > > Prior to 1.0 (and hopefully sooner than that), we're going to be adding > a bit more validation to models -- partly to give models access to > "self" if they need it. One of the things that comes out of that will be > a way to feed model validation errors back to forms -- automatically in > the form_for_instance() and form_for_models() cases and by giving the > programmer access to the errors after calling model.validate() in all > other cases. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Validators
I have regular and custom validators in my models. I also have a custom manipulator in my view, so i can get the field data in a form. Is it necessary to put the validators in the custom manipulator in order to dynamically present the errors in the templates, as to alert the user of the site what they are doing wrong in the form? If not how would this be accomplished? Jacob Berg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Syntax error in file upload
Hey, I've been working on this view for a while and I keep hitting road blocks, the newest one actually hits the save method in my view, but stops on a weird syntax error. This is the traceback. Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 74. response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.4/site-packages/django/contrib/auth/ decorators.py" in _checklogin 14. return view_func(request, *args, **kwargs) File "/opt/vidars/cns/vidars/views/pro.py" in bulk_reg 100. fi.save() File "/usr/lib/python2.4/site-packages/django/db/models/base.py" in save 204. ','.join(placeholders)), db_values) File "/usr/lib/python2.4/site-packages/django/db/backends/util.py" in execute 12. return self.cursor.execute(sql, params) ProgrammingError at /provider/dataset/bulkreg/ ERROR: syntax error at or near "{" at character 82 INSERT INTO "vidars_bulkdataregfile" ("user_id","domain_id","bulk") VALUES (10,9, {'content': '[ac.brms]\ntype: timeseries\nurl: http://terra.sr.unh.edu/cgi-bin/dataserver.pl\nstart_date: 1997-08-27\nend_date: 200-12-18\nmetadata: These data have been scraped from the NASA/CDAWEB website:\n http://cdaweb.gsfc.nasa.gov/cdaweb/istp_public/\n They are only meant for internal use and VIDARS testing.\n Use at your own risk! Jimmy Raeder [EMAIL PROTECTED]: timeseries\nurl: http://terra.sr.unh.edu/cgi-bin/dataserver.pl\nstart_date: 1997-08-27\nend_date: 2004-12-31\nmetadata: These data have been scraped from the NASA/\n\t CDAWEB website:http://cdaweb.gsfc.nasa.gov/ \n\t cdaweb/istp_public/ \n They are only meant for internal use and VIDARS\n\t testing.Use at your own risk! Jimmy Raeder\n\n[ac.bygse] \ntype: timeseries\nurl: http://terra.sr.unh.edu/cgi-bin/dataserver.pl\nstart_date: 1997-08-27\nend_date: 2004-12-31\nmetadata: These data have been scraped from the NASA/\n\t CDAWEB website:http://cdaweb.gsfc.nasa.gov/ \n\t cdaweb/istp_public/ \n They are only meant for internal use and VIDARS\n\t testing.Use at your own risk! Jimmy Raeder\n\n\n[ac.bzgse] \ntype: timeseries\nurl: http://terra.sr.unh.edu/cgi-bin/dataserver.pl\nstart_date: 1997-08-27\nend_date: 2004-12-31\nmetadata: These data have been scraped from the NASA/\n\t CDAWEB website:http://cdaweb.gsfc.nasa.gov/ \n\t cdaweb/istp_public/ \n They are only meant for internal use and VIDARS\n\t testing.Use at your own risk! Jimmy Raeder \n\n[ac.he-rat] \ntype: timeseries\nurl: http://terra.sr.unh.edu/cgi-bin/dataserver.pl\nstart_date: 1998-11-01\nend_date: 2000-07-31\nmetadata: These data have been scraped from the NASA/\n\t CDAWEB website:http://cdaweb.gsfc.nasa.gov/ \n\t cdaweb/istp_public/ \n They are only meant for internal use and VIDARS\n\t testing.Use at your own risk! Jimmy Raeder \n', 'content- type': 'application/octet-stream', 'filename': 'testfile.ini'}) This is suppose to be a file upload view and this is the following code for it: @login_required def bulk_reg(request): """Add large numbers of registrations by uploading a file""" manipulator = FileManipulator() data_domain = get_object_or_404(DataDomain, user=request.user.id) new_data = {} errors = {} if request.POST or request.FILES: new_data = request.POST.copy() new_data.update(request.FILES) errors = manipulator.get_validation_errors(new_data) if not errors: manipulator.do_html2python(new_data) fi = BulkDataRegFile(user = request.user, domain = data_domain, bulk = new_data['bulk'],) fi.save() return HttpResponseRedirect('/provider/') form = forms.FormWrapper(manipulator, new_data, errors) return render_to_response('provider/dataset/bulkreg.dht', {'form': form}, context_instance=RequestContext(request),) and this is the file manipulator that i made for this view class FileManipulator(forms.Manipulator): def __init__(self): self.fields = ( forms.FileUploadField(field_name="bulk", is_required=True), ) so is there something im missing or is actually tweeking out about the type of file it is, the file upload works perfectly fine when i use it in the admin interface. Thanks for the help. Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Custom View to save file
Hey, i had issues with this before but i fixed the login problem i believe. I cant seem to get my view to work it is supposed to take the file from the form on the template and save it to my database and directory. saving a file in the admin works just fine so i need some help fixing the view and its interface with the template. The form is created onthe site but it doesnt redirect or save anything to the database when i hit submit. so here is the view: @login_required def bulk_reg(request): """Add large numbers of registrations by uploading a file""" manipulator = FileManipulator() data_domain = get_object_or_404(DataDomain, user=request.user.id) new_data = {} errors = {} if request.POST: new_data = request.POST.copy() new_data.update(request.FILES) errors = manipulator.get_validation_errors(new_data) if not errors: manipulator.do_html2python(new_data) fi = BulkDataRegFile(user = request.user.id, domain = data_domain, bulk = new_data['bulk'],) fi.save() return HttpResponseRedirect('/provider/') form = forms.FormWrapper(manipulator, new_data, errors) return render_to_response('provider/dataset/bulkreg.dht', {'form': form}, context_instance=RequestContext(request)) and the following is the part of the template that concerns the form: {% if form.has_errors %} Please correct the form {% endif %} Select File: {{ form.bulk }}{{ form.bulk_file }} So if anyone can help me out that owuld be great. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Custom View for a file upload
the thing is that i am trying to update this site for a previous developer and he created a base template that extends to all the pages in the site, so i assume that he used those functions and when clicking around the site and seeing his other views, all he did was put at login required, and when i log into the site i can click around all the pages except the one i made and it keeps me logged in, so i dont understand y it doesnt work for my new view and template. On Oct 3, 2:52 pm, fdraft <[EMAIL PROTECTED]> wrote: > "when i connect to the pages that should handle the upload, the person > is no longer logged in" > > If that's true, then the problem isn't with this bulk_reg() function - > presumably it isn't running if you aren't logged in, right? Are you > using the suggested methods for loggin a user in > (http://www.djangoproject.com/documentation/authentication/#how-to-log... > ) ? > > On Oct 3, 11:46 am, jacoberg2 <[EMAIL PROTECTED]> wrote: > > > Hey, > > > I've posted a few times about saving files through the admin and all > > the problems its caused, but i figured out that the save method i > > tried to write was screwing it all up by not completing due to the > > error in opening the file. But since this is occuring it still is > > screwing up what i went out to do. So i am curious if this can be done > > in the view instead of the save method. > > > I can get the file to save to the system through the admin interface, > > but what i cant seem to do is create a view that will save the file. > > the model has user and file fields and i want the view to be > > @login_required. What i have tried doesnt seem to follow with the > > login, meaning in the templates, which extends a base template that > > controls the login, when i connect to the pages that should handle the > > upload, the person is no longer logged in. and when i try the upload i > > dont get any errors, but the file is not saved to the file system or > > registered in the admin, so if anyone has any pointers or code it > > would be a great help. this is the view i have: > > > @login_required > > def bulk_reg(request): > > """Add large numbers of registrations by uploading a file""" > > manipulator = FileManipulator() > > data_domain = get_object_or_404(DataDomain, user=request.user.id) > > new_data = {} > > errors = {} > > > if request.POST: > > new_data = request.POST.copy() > > new_data.update(request.FILES) > > errors = manipulator.get_validation_errors(new_data) > > > if not errors: > > manipulator.do_html2python(new_data) > > > fi = BulkDataRegFile(user = request.user.id, > > domain = data_domain, > > bulk = new_data['bulk'],) > > fi.save() > > > return HttpResponseRedirect('/provider/') > > > form = forms.FormWrapper(manipulator, new_data, errors) > > return render_to_response('provider/dataset/bulkreg.dht', > > {'form': form},) > > > the file manipulator is a custom manipulator that only includes the > > fileuploadfield and is_required is true. > > So i am hoping to get this to work and maybe open the file from the > > view and then parse it for more information if that would work. Any > > suggestions or code would be greatly appreciated. > > > Jaco --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Custom View for a file upload
Hey, I've posted a few times about saving files through the admin and all the problems its caused, but i figured out that the save method i tried to write was screwing it all up by not completing due to the error in opening the file. But since this is occuring it still is screwing up what i went out to do. So i am curious if this can be done in the view instead of the save method. I can get the file to save to the system through the admin interface, but what i cant seem to do is create a view that will save the file. the model has user and file fields and i want the view to be @login_required. What i have tried doesnt seem to follow with the login, meaning in the templates, which extends a base template that controls the login, when i connect to the pages that should handle the upload, the person is no longer logged in. and when i try the upload i dont get any errors, but the file is not saved to the file system or registered in the admin, so if anyone has any pointers or code it would be a great help. this is the view i have: @login_required def bulk_reg(request): """Add large numbers of registrations by uploading a file""" manipulator = FileManipulator() data_domain = get_object_or_404(DataDomain, user=request.user.id) new_data = {} errors = {} if request.POST: new_data = request.POST.copy() new_data.update(request.FILES) errors = manipulator.get_validation_errors(new_data) if not errors: manipulator.do_html2python(new_data) fi = BulkDataRegFile(user = request.user.id, domain = data_domain, bulk = new_data['bulk'],) fi.save() return HttpResponseRedirect('/provider/') form = forms.FormWrapper(manipulator, new_data, errors) return render_to_response('provider/dataset/bulkreg.dht', {'form': form},) the file manipulator is a custom manipulator that only includes the fileuploadfield and is_required is true. So i am hoping to get this to work and maybe open the file from the view and then parse it for more information if that would work. Any suggestions or code would be greatly appreciated. Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Filefield issues with saving
Hey everyone, I have brought up this issue before, and I was able to fix a few things but I am still having a lot of problems. I have a model with a filefield, and i was testing it with the development server and it worked perfectly. When I tried to copy it into the working server is when I started having problems. The following is the model: class BulkDataRegFile(models.Model): """DataProviders can register their data sets in large amounts without having to enter the information into the same form several times. This class takes a file field that uploads the file to the system server and then reads the file and places the data into the database for use by others """ user = models.ForeignKey(User, blank = False) domain = models.ForeignKey(DataDomain, blank = False) bulk = models.FileField(upload_to = 'bulk/', unique = True) def __str__(self): return self.bulk def save(self): super(BulkDataRegFile, self).save() import ConfigParser config = ConfigParser.ConfigParser() file = get_bulk_filename() config.readfp(open(file)) sec = config.sections() for i in sec: set_name = i it = config.items(i) for k in it: tag = k[0] if tag == 'url': url = k[1] elif tag == 'type': type1 = k[1] elif tag == 'end_date': end = k[1] elif tag == 'start_date': start = k[1] elif tag == 'metadata': meta = k[1] if type1 == 'timeseries': type1 = 0 else: type1 = 1 univ = '%s.%s' % (domain.get_udi_prefix(), set_name) b = DataSet(domain = self.domain, data_set_type = type1, udi = univ, start_time = start, end_time = end, metadata = meta, server_url = url,) b.save() class Admin: pass I updated the database to add the table and synced it. Now I go into the Admin and try to upload a file through the admin interface and I get the following error: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 74. response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.4/site-packages/django/contrib/admin/views/ decorators.py" in _checklogin 55. return view_func(request, *args, **kwargs) File "/usr/lib/python2.4/site-packages/django/views/decorators/ cache.py" in _wrapped_view_func 40. response = view_func(request, *args, **kwargs) File "/usr/lib/python2.4/site-packages/django/contrib/admin/views/ main.py" in add_stage 257. new_object = manipulator.save(new_data) File "/usr/lib/python2.4/site-packages/django/db/models/ manipulators.py" in save 101. new_object.save() File "/opt/vidars/cns/vidars/models.py" in save 189. config.readfp(open(file)) IOError at /admin/vidars/bulkdataregfile/add/ [Errno 2] No such file or directory: '' I have no idea what to do from here, for some reason it wont actually save the file to the directory I specified if i configured it correctly, which i am still not sure about. MEDIA_ROOT = '/var/www/media/' MEDIA_URL = 'https://vidars.sr.unh.edu/media/' media is a symbolic link to the media file in my app which contains all the css and images, so the apache server is serving those. other than that i dont know what to do. I am wondering if it is at a django level because when i get the traceback it gives me the values of the variables being used and the field 'bulk' doesnt get an id like the following. auto_now_add False f new_data http://terra.sr.unh.edu/cgi-bin/dataserver.pl\nstart_date: 1997-08-27\nend_date: 200-12-18\nmetadata: These data have been scraped from the NASA/CDAWEB website:\n http://cdaweb.gsfc.nasa.gov/cdaweb/istp_public/\n They are only meant for internal use and VIDARS testing.\n Use at your own risk! Jimmy Raeder [EMAIL PROTECTED]: timeseries\nurl: http://terra.sr.unh.edu/cgi-bin/dataserver.pl\nstart_date: 1997-08-27\nend_date: 2004-12-31\nmetadata: These data have been scraped from the NASA/\n\t CDAWEB website:http://cdaweb.gsfc.nasa.gov/ \n\t cdaweb/istp_public/ \n They are only meant for internal use and VIDARS\n\t testing.Use at your own risk! Jimmy Raeder\n\n[ac.bygse] \ntype: timeseries\nurl: http://terra.sr.unh.edu/cgi-bin/dataserver.pl\nstart_date: 1997-08-27\nend_date: 2004-12-31\nmetadata: These data have been scraped from the NASA/\n\t CDAWEB website:http://cdaweb.gsfc.nasa.gov/ \n\t cdaweb/istp_public/ \n They are only meant for internal use and VIDARS\n\t testing.Use at your own risk! Jimmy Raeder\n\n\n[ac.bzgse] \ntype:
Saving Uploaded files to the Server
Hey everyone, I have brought up this issue before, and I was able to fix a few things but I am still having a lot of problems. I have a model with a filefield, and i was testing it with the development server and it worked perfectly. When I tried to copy it into the working server is when I started having problems. The following is the model: class BulkDataRegFile(models.Model): """DataProviders can register their data sets in large amounts without having to enter the information into the same form several times. This class takes a file field that uploads the file to the system server and then reads the file and places the data into the database for use by others """ user = models.ForeignKey(User, blank = False) domain = models.ForeignKey(DataDomain, blank = False) bulk = models.FileField(upload_to = 'bulk/', unique = True) def __str__(self): return self.bulk def save(self): super(BulkDataRegFile, self).save() import ConfigParser config = ConfigParser.ConfigParser() file = get_bulk_filename() config.readfp(open(file)) sec = config.sections() for i in sec: set_name = i it = config.items(i) for k in it: tag = k[0] if tag == 'url': url = k[1] elif tag == 'type': type1 = k[1] elif tag == 'end_date': end = k[1] elif tag == 'start_date': start = k[1] elif tag == 'metadata': meta = k[1] if type1 == 'timeseries': type1 = 0 else: type1 = 1 univ = '%s.%s' % (domain.get_udi_prefix(), set_name) b = DataSet(domain = self.domain, data_set_type = type1, udi = univ, start_time = start, end_time = end, metadata = meta, server_url = url,) b.save() class Admin: pass I updated the database to add the table and synced it. Now I go into the Admin and try to upload a file through the admin interface and I get the following error: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 74. response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.4/site-packages/django/contrib/admin/views/ decorators.py" in _checklogin 55. return view_func(request, *args, **kwargs) File "/usr/lib/python2.4/site-packages/django/views/decorators/ cache.py" in _wrapped_view_func 40. response = view_func(request, *args, **kwargs) File "/usr/lib/python2.4/site-packages/django/contrib/admin/views/ main.py" in add_stage 257. new_object = manipulator.save(new_data) File "/usr/lib/python2.4/site-packages/django/db/models/ manipulators.py" in save 101. new_object.save() File "/opt/vidars/cns/vidars/models.py" in save 189. config.readfp(open(file)) IOError at /admin/vidars/bulkdataregfile/add/ [Errno 2] No such file or directory: '' I have no idea what to do from here, for some reason it wont actually save the file to the directory I specified if i configured it correctly, which i am still not sure about. MEDIA_ROOT = '/var/www/media/' MEDIA_URL = 'https://vidars.sr.unh.edu/media/' media is a symbolic link to the media file in my app which contains all the css and images, so the apache server is serving those. other than that i dont know what to do. I am wondering if it is at a django level because when i get the traceback it gives me the values of the variables being used and the field 'bulk' doesnt get an id like the following. auto_now_add False f new_data http://terra.sr.unh.edu/cgi-bin/dataserver.pl\nstart_date: 1997-08-27\nend_date: 200-12-18\nmetadata: These data have been scraped from the NASA/CDAWEB website:\n http://cdaweb.gsfc.nasa.gov/cdaweb/istp_public/\n They are only meant for internal use and VIDARS testing.\n Use at your own risk! Jimmy Raeder [EMAIL PROTECTED]: timeseries\nurl: http://terra.sr.unh.edu/cgi-bin/dataserver.pl\nstart_date: 1997-08-27\nend_date: 2004-12-31\nmetadata: These data have been scraped from the NASA/\n\t CDAWEB website:http://cdaweb.gsfc.nasa.gov/ \n\t cdaweb/istp_public/ \n They are only meant for internal use and VIDARS\n\t testing.Use at your own risk! Jimmy Raeder\n\n[ac.bygse] \ntype: timeseries\nurl: http://terra.sr.unh.edu/cgi-bin/dataserver.pl\nstart_date: 1997-08-27\nend_date: 2004-12-31\nmetadata: These data have been scraped from the NASA/\n\t CDAWEB website:http://cdaweb.gsfc.nasa.gov/ \n\t cdaweb/istp_public/ \n They are only meant for internal use and VIDARS\n\t testing.Use at your own risk! Jimmy Raeder\n\n\n[ac.bzgse] \ntype:
Re: File uploading problems
Hey thanks for your help, but i may need a little more. I dont really know anything about apache and without a good background everything i look up is just confusing me. i changed the file system permissions to allow "everyone" to write in the bulk file which is where i have the files directed. And I am pretty sure that the settings file is fine, so i assume that the apache config file is my problem but i have no idea what i am doing. so you know a good reference for that sort of thing or what i need to change? thanks again for all your time. Jacob On Sep 22, 11:33 am, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On 9/22/07, jacoberg2 <[EMAIL PROTECTED]> wrote: > > > > > I tried using the file upload methods like using a filefield in a > > model, and i got it to work on a test program but i can't sem to get > > it to work on my real site and I get a few different errors when it > > comes up. this is my code: > ... > > TemplateSyntaxError: Invalid block tag: 'login_bar' > > --- > > and the other is emailed to me by the debugging setting and is as > > follows: > ... > > IOError: [Errno 2] No such file or directory: '' > > The IO Error suggests that the web server is receiving the file, but > it isn't able to save it. This will often occur if the server doesn't > have write permission to the upload directory, either at a filesystem > level, or as a result of your Apache config restricting access. > Alternatively, your Media settings might be referring to a > non-existent directory. > > I suspect the TemplateSyntaxError is an error being raised when trying > to show you the error message. The IOError should be raising a 500; > this will try to render 500.html, but if this template has an error, > it will raise TemplateSyntaxError instead of the underlying actual > problem. > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MEDIA_URL
Hey Michael, > Not sure exactly what you mean by getting the right url - it should > point somewhere external to django - ie. a separate webserver - > there's no magic there. If you've got apache running on your > development machine, then this can just > behttp://localhost/mydjangoprojectmedia/ > as long as you've then got a directory called mydjangoprojectmedia in > the right spot (/var/www/ on Ubuntu). > > If in a template you then have: > > > everything should work, even if you later deploy your app - all you'll > need to do is change the MEDIA_URL setting. > > -Michael The part you wrote was more helpful i thought than how the site explained it. I fixed that and thanks again. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
File uploading problems
I tried using the file upload methods like using a filefield in a model, and i got it to work on a test program but i can't sem to get it to work on my real site and I get a few different errors when it comes up. this is my code: class BulkDataRegFile(models.Model): user = models.ForeignKey(User, blank = False) domain = models.ForeignKey(DataDomain, blank = False) bulk = models.FileField(upload_to = 'bulk/') def __str__(self): return self.bulk def save(self): super(BulkDataRegFile, self).save() import ConfigParser config = ConfigParser.ConfigParser() file = self.bulk config.readfp(open(file)) sec = config.sections() for i in sec: set_name = i it = config.items(i) for k in it: tag = k[0] if tag == 'url': url = k[1] elif tag == 'type': type1 = k[1] elif tag == 'end_date': end = k[1] elif tag == 'start_date': start = k[1] elif tag == 'metadata': meta = k[1] if type1 == 'timeseries': type1 = 0 else: type1 = 1 univ = '%s.%s' % (domain.get_udi_prefix(), set_name) b = DataSet(domain = self.domain, data_set_type = type1, udi = univ, start_time = start, end_time = end, metadata = meta, server_url = url,) b.save() class Admin: pass that is the model that i am using, it is used to parse the code and use the data in the file to add to the database. now when i go into the admin and try to add a file i get two different traceback errors. one comes up in the browser: Mod_python error: "PythonHandler django.core.handlers.modpython" Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req) File "/usr/lib/python2.4/site-packages/django/core/handlers/ modpython.py", line 161, in handler return ModPythonHandler()(req) File "/usr/lib/python2.4/site-packages/django/core/handlers/ modpython.py", line 133, in __call__ response = self.get_response(req.uri, request) File "/usr/lib/python2.4/site-packages/django/core/handlers/ base.py", line 115, in get_response return self.get_friendly_error_response(request, resolver) File "/usr/lib/python2.4/site-packages/django/core/handlers/ base.py", line 124, in get_friendly_error_response return callback(request, **param_dict) File "/usr/lib/python2.4/site-packages/django/views/defaults.py", line 88, in server_error t = loader.get_template(template_name) File "/usr/lib/python2.4/site-packages/django/template/loader.py", line 79, in get_template return get_template_from_string(*find_template_source(template_name)) File "/usr/lib/python2.4/site-packages/django/template/loader.py", line 86, in get_template_from_string return Template(source, origin) File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line 146, in __init__ self.nodelist = compile_string(template_string, origin) File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line 161, in compile_string return parser.parse() File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line 258, in parse compiled_result = compile_func(self, token) File "/usr/lib/python2.4/site-packages/django/template/ loader_tags.py", line 151, in do_extends nodelist = parser.parse() File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line 258, in parse compiled_result = compile_func(self, token) File "/usr/lib/python2.4/site-packages/django/template/ loader_tags.py", line 130, in do_block nodelist = parser.parse(('endblock',)) File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line 258, in parse compiled_result = compile_func(self, token) File "/usr/lib/python2.4/site-packages/django/template/ loader_tags.py", line 130, in do_block nodelist = parser.parse(('endblock',)) File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line 256, in parse self.invalid_block_tag(token, command) File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line 300, in invalid_block_tag raise self.error( token, "Invalid block tag: '%s'" % command) TemplateSyntaxError: Invalid block tag: 'login_bar' --- and the other is emailed to me by the debugging setting and is as follows: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/ base.py", line 74, in get_response response = callback(request,
'str' has no attribute 'strftime'
Hey, I am trying to read a string from a file and then save it to the database. In doing so I get the error message 'str' has no attribute 'strftime'. the string is a a dat that i am trying to save to the datetimefield in my database. The parser i used returned a string but hen it tries to save this string tothe appropiate place it send that error back. any suggestions? Thanks for your time. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Taking data from and uploaded file and distributing it to the database
I am relatively new to django nad i was wondeirng if anyone knew how to open and read the files taht have been uploaded to the site. I have tried the following code in the save method of my filefield model. The problem is that you have to save the file to the system and then try to manipulate it, but when i try to call the open function on the parser i get an error stating that 'module' object cannot be called so i am stuck, here is the code and thanks to anyone who takes the time to respond to me def save(self): super(BulkDataRegFiles, self).save() import ConfigParser config=ConfigParser.ConfigParser() config.readfp(open('%s' % (self.bulk_file))) sec=config.sections() for i in sec: set_name = i it = config.items(i) for k in it: tag = k[0] if tag == 'url': url = k[1] elif tag == 'type': type1 = k[1] elif tag == 'end_date': end = k[1] elif tag == 'start_date': start = k[1] elif tag == 'metadata': meta = k[1] # else # raise validators.ValidationError('.INI file not formatted # properly') b=DataSetRegistration(data_set_type=type1, data_set_name=set_name, server_url=url, start_date=start, end_date=end, metadata=meta) b.save() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---