No module name tests

2011-06-01 Thread SONAL ...
Hey i have directory structure as
gkwebapp/gnukhata-webapp/gnukhata/tests/functional in which we have our test
files.

When i run tests, get following error:

Traceback (most recent call last):
  File test_account.py, line 1, in module
from gnukhata.tests import *
ImportError: No module named gnukhata.tests

Why do this error come?? I have searched a lot but no use. Can you please
help me to sort it out???
-- 
http://mail.python.org/mailman/listinfo/python-list


Problem running pylons webtests. ImportError and TestController is not defined error.

2011-05-20 Thread SONAL ...
I have directory structure as gnukhata/tests/functional. In functional
folder I have web tests files. Following is the sample tests:

*from gnukhata.tests import *

class TestVendorController(TestController):

def test_index(self):
response = self.app.get(url(controller='vendor', action='index'**))*

After running tests, it gives me following error:
*Traceback (most recent call last):
  File /usr/lib/python2.6/dist-packages/twisted/trial/runner.py,
line 651, in   loadByNames
things.append(self.findByName(name))
  File /usr/lib/python2.6/dist-packages/twisted/trial/runner.py,
line 460, in findByName
return filenameToModule(name)
  File /usr/lib/python2.6/dist-packages/twisted/trial/runner.py,
line 98, in filenameToModule
return _importFromFile(fn)
  File /usr/lib/python2.6/dist-packages/twisted/trial/runner.py,
line 117, in _importFromFile
module = imp.load_source(moduleName, fn, fd)
  File test_vendor.py, line 1, in module
from gnukhata.tests import *
exceptions.ImportError: No module named tests*

Instead of gnukhata.tests if I write gnukhata then it shows the following error:
*Traceback (most recent call last):
File /usr/lib/python2.6/dist-packages/twisted/trial/runner.py,
line 651, in loadByNames
things.append(self.findByName(name))
File /usr/lib/python2.6/dist-packages/twisted/trial/runner.py,
line 460, in findByName
return filenameToModule(name)
File /usr/lib/python2.6/dist-packages/twisted/trial/runner.py,
line 98, in filenameToModule
return _importFromFile(fn)
File /usr/lib/python2.6/dist-packages/twisted/trial/runner.py,
line 117, in _importFromFile
module = imp.load_source(moduleName, fn, fd)
File test_vendor.py, line 3, in module
class TestVendorController(TestController):
exceptions.NameError: name 'TestController' is not defined
*
How to remove these errors??? Suggest me solution... Thanks in advance...
-- 
http://mail.python.org/mailman/listinfo/python-list


xmlrpclib fault 8002

2011-03-26 Thread SONAL ...
I Sonal Dolas work on python for project.
We connect to server as follows:
*self.server = xmlrpclib.Server(http://localhost:7081;, allow_none=True)*

I get following errror when the particular file is run:

 * File /usr/lib/python2.6/xmlrpclib.py, line 1199, in __call__*
*return self.__send(self.__name, args)*
*  File /usr/lib/python2.6/xmlrpclib.py, line 1489, in __request*
*verbose=self.__verbose*
*  File /usr/lib/python2.6/xmlrpclib.py, line 1253, in request*
*return self._parse_response(h.getfile(), sock)*
*  File /usr/lib/python2.6/xmlrpclib.py, line 1392, in _parse_response*
*return u.close()*
*  File /usr/lib/python2.6/xmlrpclib.py, line 838, in close*
*raise Fault(**self._stack[0])*
*xmlrpclib.Fault: Fault 8002: 'error'*
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to link foreign keys primary keys using python?

2006-06-13 Thread sonal
Hi Mr. Steve,
The *indexes* i am using are lists...
The code for creation of the PartionedPK is given below...
***
class PartitionedPK(object):
def __init__(self, name, save_to, fields):
self.name= name
self.idx_name= save_to
self.part_name   = save_to + PARTITION_SUFFIX
self.fields  = fields
self.digester= sha.new

def setup(self, schema):
self.partitions  = [[] for i in range(256)]
self.flush_pos   = [[] for i in range(256)]
self.flush_count = 0
self.index   = {}
self.offsets = field_offsets(self.fields, schema)
if not self.offsets:
raise ValueError('One or more index field names are
invalid')

self.idx_file= open(self.idx_name,  'wb+')
self.part_file   = open(self.part_name, 'wb+')

def save(self):
pickle.dump(self.flush_count, self.part_file, -1)
pickle.dump(self.flush_pos,   self.part_file, -1)
self.idx_file.close()
self.part_file.close()

def flush(self):
self.flush_count += 1
for i in range(256):
self.flush_pos[i].append(self.idx_file.tell())
pickle.dump(self.partitions[i], self.idx_file, -1)
self.partitions[i] = []

def valid(self, record, data):
key = self.digester(''.join( [data[i] for i in self.offsets]
)).digest()
self.partitions[ ord(key[0]) ].append( (key, record) )
# defer checking till later
return True

def finalize(self):
self.flush()
errors = []
for bin in range(256):
#show('Checking %s, bin %d/256 ... ' % (self.name, bin))
seen = {}
has  = seen.has_key
for flush in range(self.flush_count):
self.idx_file.seek( self.flush_pos[bin][flush] )
records = pickle.load(self.idx_file)
for key, value in records:
if has(key):
errors.append(value)
else:
seen[key] = value
return errors
***
the PK definition is as follows:
vol_pk = PartitionedPK( name  = 'VOL_PK',
   save_to  = '../Index/vol.idx',
   fields = ['ID','Type','Curr_Code','Tenor'])

The code for the Foreign Key declaration (referencing to the indexes)
is as given below...
***
class HashedFK(object):
def __init__(self, name, load_from, fields):
self.name   = name
self.filename   = load_from
self.fields = fields
self.digester   = sha.new

def setup(self, schema):
self.index  = {}
self.offsets= field_offsets(self.fields, schema)

if not self.offsets:
raise ValueError('One or more index field names are
invalid')

file = open(self.filename, 'rb+')
self.index = pickle.load(file)
file.close()

def valid(self, record, fields):
key = self.digester(''.join( [fields[i] for i in self.offsets]
)).digest()

return self.index.has_key(key)

def flush(self):
pass

def finalize(self):
return None
***
the FK definition is as follows:
vol_fk = HashedFK( name  = ' VOL_FK,
   load_from = '../Index/vol.idx',
   fields= ['ID','Type','Curr_Code','Tenor'])

The code is working fine when the foreign key is referenced to the
complete primary key

But if the FK were to be on only 'ID'
the FK defn would have been like =

vol_fk = HashedFK( name= ' VOL_FK,
   load_from = '../Index/vol.idx',
   fields= ['ID'] )
This is were the problem lies...
it shows AttributeError: 'list' object has no attribute 'has_key'

I have also tried defining another PK with a single field as follows =
Tvol_pk = PartitionedPK( name = 'TVOL_PK',
 save_to  = '../Index/tvol.idx',
 fields   = ['ID'] )
The index ''tvol.idx'' is being created at the given location(path
specified)
but referencing to this index(i.e., tvol.idx) with the vol_fk given
above also gives 
the same error.

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


Re: How to link foreign keys primary keys using python?

2006-06-12 Thread sonal . patankar
Hi Mr. George,

Let me try it again...

 I am not using any relational database to store the required tables
with primary keys  foreign keys

When I say PRIMARY KEY =
1. It means an index is created on the specified fields
(Out of various fields given in the comma separated txt file)
FileFormat: CODE, FIRST_NAME, last_name, area_of_expertise, country
Eg:  A1,Harry,George, python, XYZCOUNTRY(1st record)

2. The index can be formed on a single field or on multiple fields
Eg: a. 'CODE' (single field ) {pk_code}
  b. 'CODE'  'NAME' (multiple fields ) {pk_code_fname}

Now when I say FOREIGN KEY =
1. If the foreign Key is formed on the field 'CODE' in another text
file
 Format: subsriber_code,CODE,first_name, no_of_posts,active(Y/N)
 Eg:   SUB_001, A1, Harry, 50, Y

   This means the CODE (A1) given here is checked in the index formed
above
   with primary key: pk_code...

2. If the foreign Key is formed on the fields 'CODE'  'FIRST_NAME'
Format: subsriber_code,CODE,FIRST_NAME, no_of_posts,active(Y/N)
Eg:   SUB_001, A1, Harry, 50, Y

   This means the CODE (A1)  FIRST_NAME (Harry) given here
   are checked in the index formed above with primary key:
pk_code_fname...

I am done till here.

The problem starts if I have defined an index on multiple fields
(composite PK)
say: CODE  FIRST_NAME (pk_code_fname)
and if I need to define a FK on a single field out of these
say: CODE

I am unable to do that...
Mr. George, I thought i must explain the code i am dealin with,
for better understanding.., but i am sorry i confused you all the more
(incase, u want to view the code please refer to the code snippets in
my first query posted)

I hope you atleast get an idea of what i am hunting for :(

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


Re: How to link foreign keys primary keys using python?

2006-06-12 Thread sonal . patankar

MTD wrote:
 Your post is confusing. Here is my advice: investigate the use of
 dictionaries. Dictionaries can allow you to define data in the form {
 key:data }, e.g.

 { area_code : area_data }

 { (area_code,school_code) : school_data }

 { (school_code,student_code) : student_data }

Thanx Mr. Marc...
I am surely investigating the dictionaries... but the problem is that
I have to use the existing code...
and thas what is creating problems for me...  :(

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


Re: How to link foreign keys primary keys using python?

2006-06-12 Thread sonal
Hi Mr. George,
Sorry for confusing u so much...
Let me try it again...

 I am not using any relational database to store the required tables
with primary keys  foreign keys

When I say PRIMARY KEY =
1. It means an index is created on the specified fields
(Out of various fields given in the comma separated txt file)
FileFormat: CODE, FIRST_NAME, last_name, area_of_expertise, country
Eg:  A1,Harry,George, python, XYZCOUNTRY(1st record)

2. The index can be formed on a single field or on multiple fields
Eg: a. 'CODE' (single field ) {pk_code}
  b. 'CODE'  'NAME' (multiple fields ) {pk_code_fname}

Now when I say FOREIGN KEY =
1. If the foreign Key is formed on the field 'CODE' in another text
file
 Format: subsriber_code,CODE,first_name, no_of_posts,active(Y/N)
 Eg:   SUB_001, A1, Harry, 50, Y

   This means the CODE (A1) given here is checked in the index formed
above
   with primary key: pk_code...

2. If the foreign Key is formed on the fields 'CODE'  'FIRST_NAME'
Format: subsriber_code,CODE,FIRST_NAME, no_of_posts,active(Y/N)
Eg:   SUB_001, A1, Harry, 50, Y

   This means the CODE (A1)  FIRST_NAME (Harry) given here
   are checked in the index formed above with primary key:
pk_code_fname...

I am done till here.

The problem starts if I have defined an index on multiple fields
(composite PK)
say: CODE  FIRST_NAME (pk_code_fname)
and if I need to define a FK on a single field out of these
say: CODE

I am unable to do that...
Mr. George, I thought i must explain the code i am dealin with,
for better understanding.., but i am sorry i confused you all the more
(incase, u want to view the code please refer to the code snippets in
my first query posted) 

Thanks  regards,
sonal

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


Re: How to link foreign keys primary keys using python?

2006-06-12 Thread sonal

MTD wrote:
 Your post is confusing. Here is my advice: investigate the use of
 dictionaries. Dictionaries can allow you to define data in the form {
 key:data }, e.g.

 { area_code : area_data }

 { (area_code,school_code) : school_data }

 { (school_code,student_code) : student_data }

Thanx Mr. Marc...
I am surely investigating the dictionaries... but the problem is that
I have to use the existing code...
and thats what is creating problems for me...  :(

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


How to link foreign keys primary keys using python?

2006-06-09 Thread sonal
Hi all,
I hv started with python just recently... and have been assigned to
make an utility which would be used for data validations...
In short we take up various comma separated  data files
for eg: area.txt, school.txt, students.txt and so on (ok?!?)
now,
1. area code used in the school.txt must be defined in the area.txt
(Primary key in area = area_code defined in area.txt
 Foreign key on school = area_code defined in school.txt)

i hv created primary key using the following piece of code:

# primary key for area.txt (index created on the column AREACODE as per
the
# schema defined earlier )
area_pk = PartitionedPK( name = 'Area PK ',
save_to  =
'../Index/area_code.idx',
fields   = ['A_AREACODE'] )
 # col name in area schema

# foreign key is defined as follows...
school_fk = HashedFK( name  = ' School code FK',
   load_from = '../Index/area_code.idx',
   fields= ['S_AREACODE'] )
  # col name in school schema

Description for abv code:
1.  An index {area_code.idx } is formed on the field AREACODE in the
area.txt
 (i.e.,A_AREACODE)
2.  The data values in the S_AREACODE field in the school.txt are
checked in the index {area_code.idx}
If the area code given in school.txt is not present in the area
code, then the record is not validated(as foreign key constraint
fails.)

Now if the Primary key is on mutiple columns...the foreign key, which
is also definedon the same no. of columns works..
for eg..

# primary key for school.txt (index created on the columns AREACODE 
SCHOOLCODE as per the
# schema defined earlier )
school_pk = PartitionedPK( name = 'School PK ',
save_to  = '../Index/school.idx',
fields   =
['S_AREACODE','S_SCHOOLCODE'] )  # col names in school schema

# foreign key for students is defined as follows...
student_fk = HashedFK( name  = ' STUDENT code FK',
   load_from = '../Index/student.idx',
   fields=
['STUD_AREACODE','STUD_SCHOOLCODE'] )   # col name in
student schema

Now if I hv to define foreign key on student.txt but with only one
field, school code, so as to make sure that the school name given in
the student.txt exists in the school.txt whatever be the area code...
I am unable to do this...

Say, if the AREACODE field is not present in the student.txt file
then???
I tried using the foll code

student_fk = HashedFK( name  = ' Student FK',
   load_from = '../Index/school.idx',
   fields= ['STUD_SCHOOLCODE'] )

Its showing an AttributeError : 'list' object has no attribute
'has_key'

I also tried making another index with only SCHOOLCODE field (another
PK for school.txt) and the foreign key on student.txt to be loaded from
this index...
it still shows the same error
That's may be becoz... one SCHOOLCODE may repeat often, with a
different AREACODE... so may be we need to index on distinct
SCHOOLCODES in school.txt...
how do i do that??

I hope i am not confusing the genious' ... plz help me...
till get my hands on python... :)

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