Sorry...

Field('fieldname',type=gae.ReferenceProperty(db.auth_user._tableobj,....)

On 1 Lug, 03:23, Carles Gonzalez <carle...@gmail.com> wrote:
> Tested and now the error is:
>
> Traceback (most recent call last):
>   File "/Users/lauer/web2py/gluon/restricted.py", line 178, in restricted
>     exec ccode in environment
>   File "/Users/lauer/web2py/applications/web2pytodo/models/db.py",
> line 76, in <module>
>     Field(gae.ReferenceProperty(db.auth_user._tableobj))
>   File "/Users/lauer/web2py/gluon/sql.py", line 2648, in __init__
>     self.name = fieldname = cleanup(fieldname)
>   File "/Users/lauer/web2py/gluon/sql.py", line 574, in cleanup
>     if re.compile('[^0-9a-zA-Z_]').findall(text):
> TypeError: expected string or buffer
>
> On Thu, Jul 1, 2010 at 7:32 AM, mdipierro <mdipie...@cs.depaul.edu> wrote:
> > I think,
>
> >                         Field(gae.ReferenceProperty(auth_user,...)
>
> > should be
>
> > Field(gae.ReferenceProperty(db.auth_user._tableobj,....)
>
> > On 30 Giu, 16:15, Carles Gonzalez <carle...@gmail.com> wrote:
> >> Sorry, but I've encontured another error.
>
> >> The relevant part of my code is following:
>
> >> if request.env.web2py_runtime_gae:            # if running on Google App 
> >> Engine
> >>     from gluon.contrib.login_methods.gae_google_account import 
> >> GaeGoogleAccount
> >>     auth.settings.login_form = GaeGoogleAccount()
> >>     from gluon.contrib.gql import gae
>
> >> auth.define_tables()                           # creates all needed tables
>
> >> db.define_table('todos', Field('name','string'),
> >>                          Field(gae.ReferenceProperty(auth_user, 
> >> required=True,
> >>                               collection_name='todos'))
> >>                 )
>
> >> And the traceback is this:
>
> >> Traceback (most recent call last):
> >>   File "/Users/lauer/web2py/gluon/restricted.py", line 178, in restricted
> >>     exec ccode in environment
> >>   File "/Users/lauer/web2py/applications/web2pytodo/models/db.py",
> >> line 76, in <module>
> >>     Field(gae.ReferenceProperty(auth_user, required=True,
> >> NameError: name 'auth_user' is not defined
>
> >> Maybe the entity class is not defined at the time of the reference? I
> >> created an user, but still isn't working.
>
> >> When this mini-project is finished I plan to release the source. I
> >> think that a working example of this technique woukd be interesting
> >> for reference.
>
> >> On Wed, Jun 30, 2010 at 10:56 PM, Carles Gonzalez <carle...@gmail.com> 
> >> wrote:
> >> > Now is working. Thanks, let's continue testing...
>
> >> > On Wed, Jun 30, 2010 at 10:39 PM, mdipierro <mdipie...@cs.depaul.edu> 
> >> > wrote:
> >> >> You are right... fixing it in trunk..1..2..3..done. Please check it.
>
> >> >> Massimo
>
> >> >> On 30 Giu, 15:25, Carles Gonzalez <carle...@gmail.com> wrote:
> >> >>> Hi, i was trying this technique but i'm getting this traceback when
> >> >>> using gae_google_account:
>
> >> >>> Traceback (most recent call last):
> >> >>>   File "/Users/lauer/web2py/gluon/restricted.py", line 178, in 
> >> >>> restricted
> >> >>>     exec ccode in environment
> >> >>>   File 
> >> >>> "/Users/lauer/web2py/applications/web2pytodo/controllers/default.py:user",
> >> >>> line 56, in <module>
> >> >>>   File "/Users/lauer/web2py/gluon/globals.py", line 96, in <lambda>
> >> >>>     self._caller = lambda f: f()
> >> >>>   File 
> >> >>> "/Users/lauer/web2py/applications/web2pytodo/controllers/default.py:user",
> >> >>> line 35, in user
> >> >>>   File "/Users/lauer/web2py/gluon/tools.py", line 966, in __call__
> >> >>>     return self.login()
> >> >>>   File "/Users/lauer/web2py/gluon/tools.py", line 1419, in login
> >> >>>     self.log_event(log % self.user)
> >> >>>   File "/Users/lauer/web2py/gluon/tools.py", line 1180, in log_event
> >> >>>     origin=origin, user_id=user_id)
> >> >>>   File "/Users/lauer/web2py/gluon/contrib/gql.py", line 281, in insert
> >> >>>     self._last_reference = tmp
> >> >>>   File "/Users/lauer/web2py/gluon/sql.py", line 1611, in __setattr__
> >> >>>     raise SyntaxError, 'Object exists and cannot be redefined: %s' % 
> >> >>> key
> >> >>> SyntaxError: Object exists and cannot be redefined: _last_reference
>
> >> >>> On Mon, Jun 28, 2010 at 7:04 AM, dlypka <dly...@gmail.com> wrote:
> >> >>> > OK I downloaded the trunk and tested this mod.
>
> >> >>> >  myParent = db.ParentTable.insert(name='Bill')
> >> >>> >  myParentNativeRef = myParent._table._last_reference
>
> >> >>> >     works
>
> >> >>> > Thanks again.
>
> >> >>> > On Jun 27, 3:28 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> >> >>> >> > Maybe just add a new property dynamically to the row
> >> >>> >> > We could call it 'nativeRef'
>
> >> >>> >> > Would it be something like:
> >> >>> >> >     self.nativeRef = tmp     # Python can add new properties 
> >> >>> >> > 'on-the-fly', right?
>
> >> >>> >> > as the new 2nd last statement of insert()?
>
> >> >>> >> If that is useful we can do it. I just did it in trunk so you can 
> >> >>> >> test
> >> >>> >> it but I called self._last_reference to avoid possible naming
> >> >>> >> conflicts.
>
> >> >>> >> Massimo
>
> >> >>> Any thoughts?

Reply via email to