Re: [web2py] Re: About crud.update to edit or update a user's profile info !
thank you for the response Massimo, I do agree with your thoughts regarding the vulnerability exposed upon a new registration ! that can easily be arranged by adding an additional table to manage all users profile pics ! ... that way, a user can only upload his avatar ( or picture ) only when they are already registered and when they decide to edit their profile, they will be able to upload their own pic ... However, I still foresee the same problem, when it comes to edit that profile pic, with the crud.update for that eventual userimage table that will referenced the appropriate auth_user table record... I come to realize that there are many issues or challenges regarding pictures, uploading pictures, *viewing pictures upon uploads before submitting or updating a form (or crud)* etc .. throughout the web2py forum This is a matter that needs to be addressed head on, through a slice or a how to article, we know that it certainly involves ajax ... but many before me had experienced that problem and though out this web2py user forum, no effective solutions or how tos really stands out .. there is no solid approach to this ! .. if there is one, then I have not found it ! ...or if someone knows ... please point me in a that direction ! Can someone stand up take the time and share or write a good slice about this ! ... a lot of users will benefit from this ! .. the few slices that exist about file uploads and ajax are not well explained or outdated or simply do not work ! thank you Don --
Re: [web2py] I am looking for specifics : how to db.define_table in sub directories in the MODELS directory !
Definitely clearer ! ... Thanks a bunch guys ! ... in conclusion : whenever one decides to do the conditional model approach for performance concerns or else ... database tables better be defined first ! even more so if there are reference fields in the tables involved! in which case a table creation logic would need to be in place prior to the deployment of a conditional model scheme ! --
Re: [web2py] formwizard with 2 tables : - not working ! .. please help !
After a night sleep ... I woke up ... read the code again .. and bingo .. no errors .. it is almost fixed with this : > ... > if isinstance(fields,tuple): > mytables = ['auth_user','user_info'] > form_fields = [] > [form_fields.extend([db[t][f] for f in db[t].fields if f in > fields]) for t in mytables] > form = SQLFORM.factory(*form_fields) > if form.accepts(request,session): > session.register.update(form.vars) > redirect(URL(args=step+1)) >else : > for n in xrange (0, 3): > if db.user_info.user_image == defaultuserpics[n]: >db.user_info.user_picture.default = lambda: > open(os.path.join(request.folder, 'static','images/'+ defaultfoto[n]), > 'rb') > > db.auth_user.insert(**db.auth_user._filter_fields(session.register)) > > db.user_info.insert(**db.user_info._filter_fields(session.register)) > session.flash = T('Signup completed') > redirect(fields) >return dict(form=form,step=step) > > now ...the data made it to both tables .. but the image chosen by the subscriber does not make it to the table !!??? ... and the value of db.user_info.the_useris "None" when I checked in the tables values ... it should not be so ... !??? ... the tables should be linked or properly referenced ! --
Re: [web2py] formwizard with 2 tables : - not working ! .. please help !
Here is another controller I tried, and I still get the same results ( no data is recorder in the tables, no errors or ticket given ) and on the last submit button .. nothing happens : def register(): >import os >STEPS = {0: > ('Iagreeto','first_name','last_name','email','email_check','password','sex','birth_date','usertype','user_adress','user_city','user_prov','user_postalcode','Country'), > 1: > ('the_user','user_speaks','more_Lang','user_image','user_picture','user_description','user_soccerstory'), > # final step > 2: URL('user',args='profile')} > >step = int(request.args(0) or 0) >if not step in STEPS: redirect(URL(args=0)) >fields = STEPS[step] >if step==0: > session.register = {} >if isinstance(fields,tuple): > mytables = ['auth_user','user_info'] > form_fields = [] > [form_fields.extend([db[t][f] for f in db[t].fields if f in > fields]) for t in mytables] > form = SQLFORM.factory(*form_fields) > if form.accepts(request,session): > session.register.update(form.vars) > redirect(URL(args=step+1)) >else : > for k in mytables : > db[k].insert(**session.register) > session.flash = T('Signup completed') > redirect(fields) >return dict(form=form,step=step) > > Why the data entered by the user are not making it to the tables ?? why no ticket or errors ? .. why no redirect is taking place ?? thank you Don --
Re: [web2py] formwizard with 2 tables : - not working ! .. please help !
Actually, when the tables are used by themselves ! with a simple controller The first one ( auth_user ) works perfectly ... datas are recorded but the second one ( user_info ) gives me a clear error on 2.0.9 stable version Unable to handle upload but with the codes of the controller shown above, It does not even give me a ticket to tell me there is an error, it stops on the second step, no errors,even after the submit button is pressed it does not redirect and does not notify me of any errors ... and no data gets recorded either ( on web2py 2.0.9 nightly build ) what is going on ??? ... please help ... Can someone help me with this ... I don't know how to trace this or debug this ??? ... I have tried different things ... I also tried to take out the following lines of the controller in order to get something .. somekind of notice if db.user_info.user_image == defaultuserpics[1] : db.user_info.user_picture.default = lambda: open(os.path.join( request.folder, 'static',defaultfoto[1]), 'rb') if db.user_info.user_image == defaultuserpics[2] : db.user_info.user_picture.default = lambda: open(os.path.join( request.folder, 'static',defaultfoto[2]), 'rb') But nothing ! no ticket .. still .. anyone ??? --
Re: [web2py] Re: extra_field in auth_user problem !
Thank you Niphlod 2012/9/30 Niphlod > go easy on the exclamation marks :P > you can set whatever attribute of the field you want before defining a > form in any of the controllers > > def test(): > myfield = db.auth_user.user_story > myfield.readable = myfield.writable = True > form = SQLFORM(db.auth_user) > ... > > > -- William James nous dit : '' La plus grande découverte de ma génération est que l'être humain peut transformer sa vie simplement en modifiant sa maniére de penser.'' -- Le Don X --
Re: [web2py] Re: I cannot make ".../[app]/default/user/register " to behave differently !!!
Ouppsss ... Anthony, Thank you for the eye opener ! I was so focused on user/ and other things ... I did not even realized that I have not made my own navbar !!! Oh my god ! ... sorry this issue has been resolved in less than 2 minutes ! instead of creating my own navbar and reducing the number of access to the db I just modified the following line : {{='auth' in globals() and auth.navbar(separators=(' ',' | ',' '))}} with my own ! and it was solved ! ... thank you Anthony ! by the way ... on another note : Do you happen to ave any slice or JS pointers for thumbnail viewing before committing to a table upload field for images ... without refreshing or reloading the form page ??? ... I have played with the following script methods with no luck !! : http://www.zurb.com/playground/ajax_upload and http://blueimp.github.com/jQuery-File-Upload/ on this last link ( the blueimp one ) ... there is a version that they say it has been optimized for python / web2py ... you can find it here : https://github.com/hellais/jQuery-File-Upload but ... I tried to contact the author sometime ago but no response ! -- William James nous dit : '' La plus grande découverte de ma génération est que l'être humain peut transformer sa vie simplement en modifiant sa maniére de penser.'' -- Le Don X --
Re: [web2py] Re: Problems with a validation procedure ? - a Canadian postal code !
don't be sorry for jumping in it is appreciated ! .. and refreshing to noticed that there are canadian folks like me on here ! to resume ... from all the responses received - the best canadian postal code validation is actually the one submitted by Adnan : this one : ^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$ thank you ! ... with just one addition : the postal code entered will need to be capitalised before validation to avoid any issues ! This thread could help others with the same concern ! --
Re: [web2py] Re: Problems with a validation procedure ? - a Canadian postal code !
thank you guys ... so the set of characters only ( exclusively ) need to be referred to as : [A-Za-z] perfect ... thank you again. --
Re: [web2py] Question about the necessity to have 2 auth_user tables in a web2py app.... ?
Richard ... Villas ... thank you both for your insights ... for now .. I will go on ... and will try to figure it out as I go along ... I will probably end up trying both approach and see / compare etc .. I foresee issues of various bottlenecks in an app like this .. so .. ... lately .. I am in the process of transforming what I already have done and adopt it to the modelless approach ... when I am almost where there will be a need for access to the socceradmin functions in the app ( depending on who or which group ) .. I will look both of you up for further insights ... thanks again Don --
Re: [web2py] Modelless app no longer works with web2py 2.0.x ???
thank you Bruno for the update ! .. I will look it up shortly. --
Re: [web2py] Re: Checking for upgrades isn't working as I expected (1.99.7 installed)
Indeed ! ... Bruno is tha Man ! --
Re: [web2py] Is 2.0.2 or 2.0.3 really a stable version?
Well .. so far all the mini apps I have done on web2py 1.99.7 are working fine with 2.02+ ... I have not found any issues yet ! ... except for that upgrade button on 1.99.7 that is not working on any platform or browser !! ( well .. maybe with a mac platform ! - I did not test it on a mac ) ... ... so a new install has to be made in parallel for the time being ! ... or another option is to follow the directives on the web2py app dev cookbook on chapter 11 page 304 ! ( please note that I don't recommend an upgrade ... a new install or parallel install is better and safer ! ) .. it depends also on how far you are in your main app dev ! GOOD JOB WEB2PY DEVELOPERS ... & THANK YOU MASSIMO ... ANTHONY ... BRUNO ... and all the others .. who have always been there, somehow, for me with my learning curve of web2py & python ... --
Re: [web2py] Short way to update or insert data from SQLFORM.factory into the main db.my_table ??? ...
Amazing ! .. Viva python .. viva web2py ! This is pretty cool stuff ! thanks Anthony .. 2012/6/26 Anthony > > > On Tuesday, June 26, 2012 6:17:58 PM UTC-4, Don_X wrote: >> >> Hello Anthony, ... >> >> I have tried the suggested line of code ... >> the following way, based on my function index(): in the controller the >> filter field is 'email_check' >> >> so I have entered : >> db.auth_user.insert(**db.auth_**user.email_check(form.vars)) >> but I get an error msg ! .. should I put it in brakets ? in parenthesis >> ?? .. ... > > > No, you should literally use the exact code I included: > > db.auth_user.insert(**db.auth_user._filter_fields(form.vars)) > > The _filter_fields() method takes dictionary-like object and filters out > any items that are not fields in the table. So, if you pass form.vars to > it, it will remove any items that don't belong to the db.auth_user table > (in this case, the email_check variable). > > Anthony > > > -- > > > > -- William James nous dit : '' La plus grande découverte de ma génération est que l'être humain peut transformer sa vie simplement en modifiant sa maniére de penser.'' -- Le Don X --
Re: [web2py] Re: Question about a complex model & the associated form ( from controller to view )
ble=F**alse), >>> Field('modified_on','datetime'**,default=request.now, >>> label=T('Modified On'),writable=False,readable=F**alse, >>> update=request.now), >>> Field('registration_key',defau**lt='', >>> writable=False,readable=False)**, >>> Field('reset_password_key',def**ault='', >>> writable=False,readable=False)**, >>> migrate=settings.migrate) >>> >>> >>> I am using mysql on my local server, it all works ! the problem or issue >>> I am having is this : >>> In the usertype field, I have 6 predefined user types ... >>> 1) I wanted to user numbers ( like 1, 2, ... 6) internally to shorten >>> the various codes I'll be writting when it comes to compare or to decide on >>> the actions of that specific usertype ! >>> (PS. I am thinking that it is somekind of a list so I can refer >>> to that field as auth_user.usertype[0 to 5] to identify the specific >>> usertype of a subscriber !!! ... am I on the right track ??? ) >>> >>> 2) *** THIS IS MY MOST IMPORTANT QUESTION *** >>> Depending on that user type, the associated profile and form to fill out >>> that follow will not be the same upon registration !! ... in other words, >>> depending on the usertype chosen by the user, as I am using the form wizard >>> recipe, >>> the next steps ( and certain fields ) to be shown will not be the same >>> ... so .. I definitely need to create separate table for each user type >>> ... what if a specific user type ( such as a club and a league) >>> actually needs its own database instead of a table in my main database ! >>> ??? how do I approach this in the model and consequently in the controller >>> to the view ??? >>> To put it in context : a player or ref or coach is a user, ( simple ) >>> ... and most club owners and persons will be the same basic auth_user ! but >>> on the other hand ... >>> a team is a list of registered users >>> a club is a list of teams and users ( that >>> are not teams ) >>> a league is a list of clubs and users ( >>> that are not clubs, like volunteers, workers, etc.. ) >>> >>> Am i approaching this the right way ??? ... >>> >>> please advise >>> >>> thank you >> >> -- William James nous dit : '' La plus grande découverte de ma génération est que l'être humain peut transformer sa vie simplement en modifiant sa maniére de penser.'' -- Le Don X --