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, *callback_args, **callback_kwargs)

  File "/usr/lib/python2.4/site-packages/django/contrib/admin/views/
decorators.py", line 55, in _checklogin
    return view_func(request, *args, **kwargs)

  File "/usr/lib/python2.4/site-packages/django/views/decorators/
cache.py", line 40, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)

  File "/usr/lib/python2.4/site-packages/django/contrib/admin/views/
main.py", line 257, in add_stage
    new_object = manipulator.save(new_data)

  File "/usr/lib/python2.4/site-packages/django/db/models/
manipulators.py", line 101, in save
    new_object.save()

  File "/opt/vidars/cns/vidars/models.py", line 189, in save
    config.readfp(open(file))

IOError: [Errno 2] No such file or directory: ''


<ModPythonRequest
path:/admin/vidars/bulkdataregfile/add/,
GET:<MultiValueDict: {}>,
POST:<MultiValueDict: {'bulk': [''], 'domain': ['9'], 'user':
['10']}>,
COOKIES:{'UNH_SSO_CTX':
'5E8E5B502371B80308B72ADB57A5615F5D7FFC91108D61F63D5DD687BACCF0D9',
 'sessionid': '972004989e2298ffa497f2448c611ec8'},
META:{'AUTH_TYPE': None,
 'CONTENT_LENGTH': 0L,
 'CONTENT_TYPE': None,
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT': 'text/xml,application/xml,application/xhtml+xml,text/
html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
 'HTTP_ACCEPT_ENCODING': 'gzip,deflate',
 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
 'HTTP_CONNECTION': 'keep-alive',
 'HTTP_CONTENT_LENGTH': '2494',
 'HTTP_CONTENT_TYPE': 'multipart/form-data;
boundary=---------------------------50357816718996702551032125477',
 'HTTP_COOKIE': 'sessionid=972004989e2298ffa497f2448c611ec8;
UNH_SSO_CTX=5E8E5B502371B80308B72ADB57A5615F5D7FFC91108D61F63D5DD687BACCF0D9',
 'HTTP_HOST': 'vidars.sr.unh.edu',
 'HTTP_KEEP_ALIVE': '300',
 'HTTP_REFERER': 'https://vidars.sr.unh.edu/admin/vidars/
bulkdataregfile/add/',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:
1.8.0.12) Gecko/20070731 Ubuntu/dapper-security Firefox/1.5.0.12',
 'PATH_INFO': '/vidars/bulkdataregfile/add/',
 'PATH_TRANSLATED': None,
 'QUERY_STRING': None,
 'REMOTE_ADDR': '132.177.248.191',
 'REMOTE_HOST': None,
 'REMOTE_IDENT': None,
 'REMOTE_USER': None,
 'REQUEST_METHOD': 'POST',
 'SCRIPT_NAME': None,
 'SERVER_NAME': 'vidars.sr.unh.edu',
 'SERVER_PORT': 0,
 'SERVER_PROTOCOL': 'HTTP/1.1',
 'SERVER_SOFTWARE': 'mod_python'}>


so obviously its not actually getting the file and uploading it to the
designated area.
The thing is that i am not sure of what could be causing it, i have a
feeling its the media URL or the media root, but im not clear on how i
should be setting those up either. Tahnks to anyone who spends time
looking at this, its greatly appreciated.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to