> The code you have given is incapable of producing that error - request > is passed as a parameter, so will always be defined within the > function. Are you sure the error is coming from within the function? > Give us the actual traceback that is being produced. > -- > DR.
def GetRequestId(request): curpath=request.path return curpath # setup a subclass for URL on add form which will be used by the ADD and CLONE views. # the purpose is ti screen for urls goign into the system (non-preview urls) and class ExistingUrl (forms.Field): def clean(self, value): i=GetRequestId(request) <<<<<< error is here assert False, i <<< just trying to print out the value of i here rs=WebPage.objects.filter(url_slug=value) thislength=str(len(value)) if rs.count()!=0: raise forms.ValidationError ('This URL is already in use.') if not value: raise forms.ValidationError ('Please enter a url such as / my-page/') if len(value)>254: raise forms.ValidationError ('254 Characters Max. The current length is %s' % thislength) return value Traceback being produced: global name 'request' is not defined Request Method: POST Request URL: http://sasquatch.beta.ornlfcu.mediapulse.com/manage/content/web-pages/edit/11/ Exception Type: NameError Exception Value: global name 'request' is not defined Here's what i'm trying to do. I've got a module that allows us to add new items and edit new items to the database. I was going to use a url slug which has to be unique anyway, but that will not work for this application. As a result i'm allowing users to enter a url path (ie /whatever/this/page/is/) and it's being served up fine through a middleware class I wrote to substitute for flatpges (it does more than standard flatpages). In my form above I'm trying to find a way to check and see on form submission if the url has been changed to another URL which is in the database already and not for the current record. That part I can handle. I think the key to this is getting request.path into my form field subclass above so that I can get the record id which is passed through the url. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---