Call perl to store data in DB

2012-08-31 Thread Mulla
hey,

when i submit the form in html , the entered data (fname,lanme,uname.)all 
have to come in perl script to store that data in DB.


Python View.py


def ProfileRegistration(request):
if request.user.is_authenticated():
return HttpResponseRedirect('/profile/')
if request.method == 'POST':
form = RegistrationForm(data=request.POST, files=request.FILES)
if form.is_bound and form.is_valid():
user = 
User.objects.create_user(username=form.cleaned_data['username'],
email=form.cleaned_data['email'],

password=form.cleaned_data['password'],)
new_user= user.save()
profile = 
Profile(user=user,firstname=form.cleaned_data['firstname'],
  lastname=form.cleaned_data['lastname'],
  telephone=form.cleaned_data['telephone'],
  service=form.cleaned_data['service'],
  servicetype=form.cleaned_data['servicetype'],)
new_user = profile.save()
   # messages.info(request, "Thank you for registration.Please login to 
continue")
   # login(request, new_user)
return HttpResponseRedirect('/dashboard/')
else:
return render_to_response('register.html',{'form': 
form},context_instance=RequestContext(request))
else:
form = RegistrationForm()
context = {'form':form}
return render_to_response('register.html',context, 
context_instance=RequestContext(request))

Below in my perl script 


#!/usr/bin/perl

use strict;
use warnings;
use user;



my $tempuser = new user ();

if ($tempuser->readbyfirstname('Pervez') eq 1) {
# Continue processing since we found a match
 if($tempuser->{lastname} eq 'Noel')
{
print "Name already exists, \n";
}
}

my $tempuser1 = new user();
$tempuser1->readbyemail_id('[email protected]'); 
if($tempuser1->{email_id} eq '[email protected]')
{
print "email_id is in use \n";
}



my $tempuser2 = new user();
$tempuser2->readbyusername('Tim_sir');
if ($tempuser2->{username} eq 'Mulla') 
{
print "username is already present\n";
}
else {
print "we have no match\n";
}

my $tempuser4 = new user('pervez', '', 'mulla', '[email protected]', 
'193274198');
my $string = $tempuser4->{firstname};
my @c = split(//, $string);
my $userhash = "00$c[0]$c[-1]";
print "$userhash \n";
#$tempuser4->{userhash} = $userhash;
$tempuser4->setuserhash( "$userhash" );
$tempuser4->write;

 
when I submit data , that data must come in place "my $tempuser4 = new 
user('pervez', '', 'mulla', '[email protected]', '193274198');" ...

how can I do this ...>>?

Look forward for hear from you soon

Thank You
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Call perl to store data in DB

2012-08-31 Thread Mulla
On Friday, August 31, 2012 2:49:32 PM UTC+5:30, Octavian Rasnita wrote:
> Maybe I didn't understand well, but if you want your Perl program to get and 
> store the data submitted by the form, then the action of the form should 
> point to the Perl script something like:
> 
> 
> 
> 
> 
> 
> 
> So your "form" object in Python should set the action as the path to the Perl 
> program.
> 
> 
> 
> --
> Octavian
> 
> 
> - Original Message - 
> 
> From: "Mulla" 
> 
> Newsgroups: comp.lang.python
> 
> To: 
> 
> Sent: Friday, August 31, 2012 11:40 AM
> 
> Subject: Call perl to store data in DB
> 
> 
> 
> 
> 
> > hey,
> 
> > 
> 
> > when i submit the form in html , the entered data 
> > (fname,lanme,uname.)all have to come in perl script to store that data 
> > in DB.
> 
> > 
> 
> > 
> 
> > Python View.py
> 
> > 
> 
> > 
> 
> > def ProfileRegistration(request):
> 
> >if request.user.is_authenticated():
> 
> >return HttpResponseRedirect('/profile/')
> 
> >if request.method == 'POST':
> 
> >form = RegistrationForm(data=request.POST, files=request.FILES)
> 
> >if form.is_bound and form.is_valid():
> 
> >user = 
> > User.objects.create_user(username=form.cleaned_data['username'],
> 
> >email=form.cleaned_data['email'],
> 
> >
> > password=form.cleaned_data['password'],)
> 
> >new_user= user.save()
> 
> >profile = 
> > Profile(user=user,firstname=form.cleaned_data['firstname'],
> 
> >  lastname=form.cleaned_data['lastname'],
> 
> >  telephone=form.cleaned_data['telephone'],
> 
> >  service=form.cleaned_data['service'],
> 
> >  servicetype=form.cleaned_data['servicetype'],)
> 
> >new_user = profile.save()
> 
> >   # messages.info(request, "Thank you for registration.Please login 
> > to continue")
> 
> >   # login(request, new_user)
> 
> >return HttpResponseRedirect('/dashboard/')
> 
> >else:
> 
> >return render_to_response('register.html',{'form': 
> > form},context_instance=RequestContext(request))
> 
> >else:
> 
> >form = RegistrationForm()
> 
> >context = {'form':form}
> 
> >return render_to_response('register.html',context, 
> > context_instance=RequestContext(request))
> 
> > 
> 
> > Below in my perl script 
> 
> > 
> 
> > 
> 
> > #!/usr/bin/perl
> 
> > 
> 
> > use strict;
> 
> > use warnings;
> 
> > use user;
> 
> > 
> 
> > 
> 
> > 
> 
> > my $tempuser = new user ();
> 
> > 
> 
> > if ($tempuser->readbyfirstname('Pervez') eq 1) {
> 
> > # Continue processing since we found a match
> 
> > if($tempuser->{lastname} eq 'Noel')
> 
> >{
> 
> >print "Name already exists, \n";
> 
> >}
> 
> > }
> 
> > 
> 
> > my $tempuser1 = new user();
> 
> > $tempuser1->readbyemail_id('[email protected]'); 
> 
> >if($tempuser1->{email_id} eq '[email protected]')
> 
> >    {
> 
> >print "email_id is in use \n";
> 
> >}
> 
> >
> 
> > 
> 
> > 
> 
> > my $tempuser2 = new user();
> 
> > $tempuser2->readbyusername('Tim_sir');
> 
> >if ($tempuser2->{username} eq 'Mulla') 
> 
> >{
> 
> >print "username is already present\n";
> 
> >}
> 
> > else {
> 
> > print "we have no match\n";
> 
> > }
> 
> > 
> 
> >my $tempuser4 = new user('pervez', '', 'mulla', '[email protected]', 
> > '193274198');
> 
> >my $string = $tempuser4->{firstname};
> 
> >my @c = split(//, $string);
> 
> >my $userhash = "00$c[0]$c[-1]";
> 
> >print "$userhash \n";
> 
> >#$tempuser4->{userhash} = $userhash;
> 
> >$tempuser4->setuserhash( "$userhash" );
> 
> >$tempuser4->write;
> 
> >
> 
> > 
> 
> > when I submit data , that data must come in place "my $tempuser4 = new 
> > user('pervez', '', 'mulla', '[email protected]', '193274198');" ...
> 
> > 
> 
> > how can I do this ...>>?
> 
> > 
> 
> > Look forward for hear from you soon
> 
> > 
> 
> > Thank You
> 
> > -- 
> 
> > http://mail.python.org/mailman/listinfo/python-list
Thank You Octavian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to call perl script from html using python

2012-08-13 Thread Pervez Mulla
On Tuesday, August 14, 2012 10:42:48 AM UTC+5:30, Pervez Mulla wrote:
> Hi,
> 
> 
> 
> I wanna call perl script in HTML form n store that data in DB using Python.
> 
> 
> 
> How can i do this...??
> 
> 
> 
> Please help me
> 
> 
> 
> Thank you
> 
> Pervez

Thank you for your advice steven,

I am beginner to this language, I have exp in JAVA and C

I wanna call perl objects using Python . I checked in internet ,I can make use 
of inline function for this, But in HTML..??

Thank You  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to call perl script from html using python

2012-08-16 Thread Pervez Mulla
On Tuesday, August 14, 2012 10:42:48 AM UTC+5:30, Pervez Mulla wrote:
> Hi,
> 
> 
> 
> I wanna call perl script in HTML form n store that data in DB using Python.
> 
> 
> 
> How can i do this...??
> 
> 
> 
> Please help me
> 
> 
> 
> Thank you
> 
> Pervez



On Tuesday, August 14, 2012 10:42:48 AM UTC+5:30, Pervez Mulla wrote:
> Hi,
> 
> 
> 
> I wanna call perl script in HTML form n store that data in DB using Python.
> 
> 
> 
> How can i do this...??
> 
> 
> 
> Please help me
> 
> 
> 
> Thank you
> 
> Pervez



On Tuesday, August 14, 2012 10:42:48 AM UTC+5:30, Pervez Mulla wrote:
> Hi,
> 
> 
> 
> I wanna call perl script in HTML form n store that data in DB using Python.
> 
> 
> 
> How can i do this...??
> 
> 
> 
> Please help me
> 
> 
> 
> Thank you
> 
> Pervez



On Tuesday, August 14, 2012 10:42:48 AM UTC+5:30, Pervez Mulla wrote:
> Hi,
> 
> 
> 
> I wanna call perl script in HTML form n store that data in DB using Python.
> 
> 
> 
> How can i do this...??
> 
> 
> 
> Please help me
> 
> 
> 
> Thank you
> 
> Pervez

Hey Steven ,

Thank you for your response,

I will in detail now about my project,

Actually the project entire backend in PERL language , Am using Django 
framework for my front end .

I have written code for signup page in python , which is working perfectly .

In HTml when user submit POST method, it calling Python code Instead of 
this I wanna call perl script for sign up ..
 
below in form for sign up page in python 

form.py
from django import forms
from django.contrib.auth.models import User
from django.forms import ModelForm
from user_profile.models import Profile

class RegistrationForm(ModelForm):
username= forms.CharField(label=(u'User Name'))
email   = forms.EmailField(label=(u'E-mail'))
password= 
forms.CharField(label=(u'Password'),widget=forms.PasswordInput(render_value=False))
password1   = forms.CharField(label=(u'Verify 
Password'),widget=forms.PasswordInput(render_value=False))

class Meta:
model = Profile
exclude = ('user',)

def clean_username(self):
username = self.cleaned_data['username']
try:
User.objects.get(username==username)
except User.DoesNotExist:
return username
raise forms.ValidationError("That username is already taken. Please 
select another.")

def clean_password(self):
if self.cleaned_data['password'] != self.cleaned_data['password1']:
raise forms.ValidationError("Password didnt match... Please try 
again")
return self.cleaned_data
-

view.py


def ProfileRegistration(request):
if request.user.is_authenticated():
return HttpResponseRedirect('/profile/')
if request.method =="POST":
form = RegistrationForm(request.POST)
if form.is_valid():
user = User.objects.create_user(username = 
form.cleaned_data['username'],
email = form.cleaned_data['email'],
password = 
form.cleaned_data['password'])
user.save()
profile = Profile(user=user, 
firstname=form.cleaned_data['firstname'],
 lastname=form.cleaned_data['lastname'],
 phone=form.cleaned_data['phone'],
 title=form.cleaned_data['title'],
 
companyname=form.cleaned_data['companyname'])
profile.save()
return HttpResponseRedirect('/profile/')
else:
return render_to_response 
('register.html',{'form':form},context_instance=RequestContext(request))
else: 
form = RegistrationForm()
context = {'form':form}
return render_to_response('register.html', context, 
context_instance=RequestContext(request))


In view instead invoking python script I wanna invoke Perl script .for the 
signup page 


Thank You


   
-- 
http://mail.python.org/mailman/listinfo/python-list


Calling External (Perl)Script in Python

2012-08-26 Thread Pervez Mulla
Hi,

I am trying to call perl script in my python view.py and store that data in 
logfile 

On shell I am able to display data. I wanna call that data on logfile , How can 
i do this ...?

I wanna call perl objects in python ... So , How can I pass all that stuff in 
python(firstname, lastname, username)

Please help
Pervez
-- 
http://mail.python.org/mailman/listinfo/python-list