On Mon, May 11, 2009 at 4:10 AM, [email protected] <
[email protected]> wrote:

>
> Hi,
>
> > New users are moderated to avoid spam... on weekends, it may take up to a
> > day for postings to appear on list.
> Ok, sorry for the spam then ;)
>
> > You should be able to do:
> >
> > myUserInstance.id(55L)
> >
> > That should set it to 55.
>
> I try to do this in my unit test:
>
> val u2 = User.create
> u2.id(20)
>
> I gent an exception:
> "Do not have permission to set this field"
>
> It is thrown by the code:
>
> #   def set(value: FieldType): FieldType = {
> #     if (safe_? || writePermission_?) i_set_!(value)
> #     else throw new Exception("Do not have permissions to set this
> field")
> #   }
>
> in MappedField
>
> I check and it seams that the writePermission returns false


A hah!  I had forgotten that I'd done this.  Try the following:

myUser.runSafe {
  myUser.id(55L)
}

Mapper supports read and write access control on a field by field bases.
 You can put in complex logic (e.g., a taxpayer ID field can only be read by
the person who owns the record) into the code and the logic will be enforced
unless you are running in a "safe" code block.  This makes code reviews a
lot easier... you check the logic for the access control and you check for
places that the code is in "safe mode" (should be almost nowhere... and
should be marked with big comments) and that's the code review rather than
every point in the code where the field in question is being accessed.  See
http://blog.lostlake.org/index.php?/archives/19-Keeping-the-meaning-with-the-bytes.html

Thanks,

David

>
>
> Should I run my test in different run.mode? test?
>
> br,
> - Erik
>
> >
> > Please give that a try.
> >
> > Thanks,
> >
> > David
> >
> >
> >
> > > Thanks beforehand,
> >
> > > - Erik
> >
> > --
> > Lift, the simply functional web frameworkhttp://liftweb.net
> > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > Follow me:http://twitter.com/dpp
> > Git some:http://github.com/dpp
>
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to