I'm having a problem using upload fields within forms that are used
within jDiv containers. Testing edit() below by itself provides a form
that I can successfully select and update an image. When I encapsulate
the same edit() within a jDiv, all fields update with the exception of
the upload field, even though form.accepts is successful.

The code below contains the essential elements of what I am doing.
Updating the profile edit form correctly forces a refresh of the other
jDiv that is displaying the profile info, and all fields are updated
correctly when changed, with the exception of the upload field.

Any help with this is appreciated.

P.S. - Despite this hiccup, I am enthusiastic about this addition of
the jDiv container.


db.py model:
--------------------------

db.define_table('user_profile',
    SQLField('nickname', type='string'),
    SQLField('bio', type='text'),
    SQLField('owner', db.auth_user, notnull=True, required=True,
writable=False),
    SQLField('image', 'upload', uploadfield='image_data'),
    SQLField('image_data', type='blob', default='', writable=False)
    )


profile.py controller:
-----------------------------
def index():
    # create profile form and profile info containers
    profile_form = jDiv('',URL(r=request,f='edit'),_id='1')
    user_profile = jDiv('',URL
(r=request,f='profile'),timeout=0.01,_id='2')

return (profile_form = profile_form )

def edit():

    user_profile=db(db.user_profile.owner==auth.user.id).select()[0]

    form=SQLFORM(db.user_profile, user_profile, deletable=False)

    if form.accepts(request.vars,session):
       # refresh profile container
        jDiv.set(jDiv.trigger('#target_2','load'))
    return dict(form=form,user_profile=user_profile)

def profile():
    # first get our profile, if we don't yet
    # have one, then create it
    try:
        profile=db(db.user_profile.owner==auth.user.id).select()[0]
    except:
        db.user_profile.insert(owner=auth.user.id,nickname='n00by')
        profile=db(q_profile).select()[0]
    return dict(profile=profile)

index.html view:
-----------------------------
{{extend 'layout.html'}}

{{=user_profile}}
<hr/>
{{=profile_form}}

profile.html view:
-------------------------

<img width="100", height="100" src="{{ =URL
(r=request,f='download',args=[profile.image]) }}" />
<h4>{{=auth.user.first_name + " " + auth.user.last_name}}'s Profile</
h4>
<hr/><strong>Nickname: {{ =profile.nickname }}</strong><br/>
email: {{=auth.user.email}}<br/>
{{ =profile.bio }}

edit.html view:
-----------------------
<h3>Edit profile</h3>
{{=form}}
<hr/>



On Apr 6, 12:45 pm, mdipierro <[email protected]> wrote:
> I stole it on the web. Not my artwork. Hope the author does not mind.
>
> Massimo
>
> On Apr 6, 2:37 pm, desfrenes <[email protected]> wrote:
>
> > liking the background :-)
>
> > On 6 avr, 21:34, mdipierro <[email protected]> wrote:
>
> > > This can already be done. Here is a better layout and absolute Divs.
>
> > >http://www.web2py.com/events/default/index
>
> > > On Apr 6, 1:52 pm, ceej <[email protected]> wrote:
>
> > > > I think there should defiantly be a way to specify what div the
> > > > response is loaded in and also the option to load different parts of
> > > > the response in different divs.
>
> > > > On Apr 6, 1:42 pm, desfrenes <[email protected]> wrote:
>
> > > > > ok, I understand.
>
> > > > > On 6 avr, 18:17, mdipierro <[email protected]> wrote:
>
> > > > > > because, as far as I understand, this does something different.
>
> > > > > > the main point is thatjDivcatches the self-submitting forms and
> > > > > > prevents from reloading the entire page. I can use this with 
> > > > > > existing
> > > > > > web2py actions.
>
> > > > > > taconite has a flexible mechanism for allowing one page to embed 
> > > > > > code
> > > > > > into the page (using a new XML based syntax) but I prefer to use the
> > > > > > native publisher/subscriber mechanism in jQuery and let the server
> > > > > > always send the HTML to each component. I am ok with one component
> > > > > > triggering an aciton in a different component (like "load" or 
> > > > > > "flash"
> > > > > > or "slideToggle") but I am not ok with a component editing the 
> > > > > > content
> > > > > > of another component (something that taconite is for). I believe the
> > > > > > latter approach become un-manageble for complex systems.
>
> > > > > > Massimo
>
> > > > > > On Apr 6, 3:54 am, desfrenes <[email protected]> wrote:
>
> > > > > > > Hi,
>
> > > > > > > It's nice but how about using existing plugins for the ajax stuff 
> > > > > > > ?
> > > > > > > jquery.taconite.js and jquery.form.js are great (see page test 
> > > > > > > here:http://www.desfrenes.com/playground/carnet_adresse/)
>
> > > > > > > Taconite plugin:http://malsup.com/jquery/taconite/
>
> > > > > > > Regards,
>
> > > > > > > Mickaël.
>
> > > > > > > On Apr 6, 8:09 am, mdipierro <[email protected]> wrote:
>
> > > > > > > > I just changed the layout....
>
> > > > > > > >http://www.web2py.com/events/default/indexhttp://www.web2py.com/examp...
>
> > > > > > > > try:
> > > > > > > > - click on "form"
> > > > > > > > - type a= 2 [enter]
> > > > > > > > - type b= 3 [enter]
>
> > > > > > > > - click on "post a message"
> > > > > > > > - type something and see the "list messages" open up 
> > > > > > > > automatically
>
> > > > > > > > - click on "register" and "login" and "logout"
>
> > > > > > > > - click on watch the movie!
>
> > > > > > > > - move jDivs (the windows) around.
>
> > > > > > > > - look at the source code on default.py
>
> > > > > > > > Isn't this cool?
> > > > > > > > Pros? Cons? Suggestions for improvement?
>
> > > > > > > > Massimo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to