[web2py] Re: Not sure of the etiquette for asking about an issue...

2011-03-31 Thread Mike Peper
Christian-

Thanks for the reply, I am very sorry I could not respond sooner.

Providing a full example for web2py issue #150 is hard, as my code runs
against a MS  SQL database (hence the "primarykey" kind of table definition
instead of one that uses the normal "id" field for the key).

Maybe if I point out the type mismatch in the web2py source code, it will be
clear.

 In gluon\dal.py, in the definition of the class Table, there is a method
called "insert" that is called to insert a record into a table:

def insert(self, **fields):
return self._db._adapter.insert(self, self._listify(fields))

The parameter in red above, being passed to the adapter's "insert" method,
is a list created from the "fields" dictionary by the _listify() function.

The code being called (self._db._adapter.insert) is also in gluon\dal.py, in
the definition of the class BaseAdapter:

   def insert(self,table,fields):
   query = self._insert(table,fields)
   try:
   self.execute(query)
   except Exception, e:
   if isinstance(e,self.integrity_error_class()):
   return None
   raise e
   if hasattr(table,'_primarykey'):
   return dict( [ (k,fields[k]) for k in table._primarykey ])
   id = self.lastrowid(table)
   if not isinstance(id,int):
   return id
   rid = Reference(id)
   (rid._table, rid._record) = (table, None)
   return rid


 The line of code that throws the exception is in blue.  The reason this
exception is thrown is that the variable "fields" is a list, not a
dictionary, but the contents of table._primarykey are string field names,
not integers.  When the list 'fields' is indexed with the field name string
values, the exception is thrown stating the list must be indexed by
integers.

This problem will only be seen if the table has a PrimaryKey, rather than
using a normal field named "id" as the key.

If this is still not helpful, let me know and I can try a different way to
describe the issue.

Thank you very much for your attention,

--Mike Peper
m...@peper.org


On Sun, Mar 27, 2011 at 3:27 PM, howesc  wrote:
> Mike,
> asking is always a good thing.  lots of stuff flys by and sometimes things
> fall through the cracks.
> i just looked at your bug report, and honestly am having trouble following
> it (which might be why it has not been addressed yet).  can you post the
> table definition and a post that fails?  A full example so we can
reproduce
> the problem will help get an answer faster.
> thanks,
> christian


[web2py] Re: Not sure of the etiquette for asking about an issue...

2011-03-27 Thread Massimo Di Pierro
I am pretty sure I responded to this but my response disappeared!

My response was something like: I apologize this was overlooked. We
will take care of it asap.

Massimo

On Mar 26, 3:35 pm, tiny  wrote:
> Hi-
>
> I reported an issue on the Google projects issues list (#150) on Jan
> 6, and I am wondering how to find out if/when the issue might be
> addressed.  I believe the issue is pretty simple (an esception occurs
> when a record is inserted into a table with a legacy primary key,
> which I unfortunately have quite a few of), but I have not proposed a
> solution because I do not know the logic around that area, and I
> suspect someone who knows that area of code will know quickly what
> needs to be done.
>
> I am about to deploy to a customer, and I cannot just have them
> download the latest stable version as the defect causes a fatal error
> in my system.  Right now, I have a hacked local version that does not
> return the right status info, but it works.
>
> I would welcome being told how best to query status like this, I did
> not see anything other than the ability to add a comment on the issues
> page, and was not sure that would get attention (monitoring all the
> issues might be difficult).  I have no intention of causing hassle,
> and will follow any directions given!
>
> Again, I will end by saying I have very much enjoyed using web2py, my
> compliments and gratitude go to Massimo and all others who maintain
> the project!
>
> --Mike


[web2py] Re: Not sure of the etiquette for asking about an issue...

2011-03-27 Thread howesc
Mike,

asking is always a good thing.  lots of stuff flys by and sometimes things 
fall through the cracks.

i just looked at your bug report, and honestly am having trouble following 
it (which might be why it has not been addressed yet).  can you post the 
table definition and a post that fails?  A full example so we can reproduce 
the problem will help get an answer faster.

thanks,

christian