hello,
I wasn't able to run your example because of tabbing issues, but from
examining it I see you added the user_role field. But the login and
register forms still seem to require an email - is that right?
How do you intend to deal with updates to t2.py? Stay with your edited
version, or remake these edits after each update?
Richard
On Nov 17, 4:16 am, tommy <[EMAIL PROTECTED]> wrote:
> I had same issue, I changed the t2.py and it worked out. Here is my
> code. I added one field in the personal table.
>
> """
> This file was developed by Massimo Di Pierro as a web2py extension.
> This file is released under the BSD license (you can include it in
> bytecode compiled web2py apps as long as you acknowledge the author).
> web2py (required to run this file) is released under the GPLv2
> license.
> TODO:
> - ok, works on GAE but need to fix ID in search
> - ok, delete files and dowload on GAE
> - add media_player?
> - add slideshow?
> - add layout customization?
> """
>
> from gluon.storage import Storage
> from gluon.html import *
> from gluon.http import *
> from gluon.validators import *
> from gluon.sqlhtml import *
> from gluon.contrib.markdown import WIKI
>
> class T2:
> IMAGE_EXT=['.jpg','.gif','.png']
>
> def __init__
> (self,request,response,session,cache,T,db,all_in_db=False):
> """
> Creates a T2 object and all necessary tables:
>
> t2_person: name, email, password, user_role,
> registration_key
> t2_group: name
> t2_membership: person_id, group_id, membership_type, status
> t2_access: person_id, table_name, record_id, access_type
> t2_attachment: ...
> t2_comment: ...
> t2_review: ...
>
> request.args[-1] is stored in self.id
> if self.logged_in:
> self.person_id, self.person_name, self.person_email,
> self.user_role
> """
> import datetime
> self.error_action='error'
> self.now=now=datetime.datetime.now()
> self.request=request
> self.response=response
> self.session=session
> self.cache=cache
> self.T=T
> self.db=db
> self.all_in_db=all_in_db
> if self.db._dbname=='gql':
> self.is_gae=True
> self.all_in_db=True
> else: self.is_gae=False
> if all_in_db: session.connect(request,response,db=db)
> if not session.t2: session.t2=Storage()
> self.id=request.args[-1] if request.args else 0
> self.person_name=session.t2.person_name
> self.person_id=session.t2.person_id
> self.person_email=session.t2.person_email
> self.user_role=session.t2.user_role
> """
> This file was developed by Massimo Di Pierro as a web2py extension.
> This file is released under the BSD license (you can include it in
> bytecode compiled web2py apps as long as you acknowledge the author).
> web2py (required to run this file) is released under the GPLv2
> license.
> TODO:
> - ok, works on GAE but need to fix ID in search
> - ok, delete files and dowload on GAE
> - add media_player?
> - add slideshow?
> - add layout customization?
> """
>
> from gluon.storage import Storage
> from gluon.html import *
> from gluon.http import *
> from gluon.validators import *
> from gluon.sqlhtml import *
> from gluon.contrib.markdown import WIKI
>
> class T2:
> IMAGE_EXT=['.jpg','.gif','.png']
>
> def __init__
> (self,request,response,session,cache,T,db,all_in_db=False):
> """
> Creates a T2 object and all necessary tables:
>
> t2_person: name, email, password, user_role,
> registration_key
> t2_group: name
> t2_membership: person_id, group_id, membership_type, status
> t2_access: person_id, table_name, record_id, access_type
> t2_attachment: ...
> t2_comment: ...
> t2_review: ...
>
> request.args[-1] is stored in self.id
> if self.logged_in:
> self.person_id, self.person_name, self.person_email,
> self.user_role
> """
> import datetime
> self.error_action='error'
> self.now=now=datetime.datetime.now()
> self.request=request
> self.response=response
> self.session=session
> self.cache=cache
> self.T=T
> self.db=db
> self.all_in_db=all_in_db
> if self.db._dbname=='gql':
> self.is_gae=True
> self.all_in_db=True
> else: self.is_gae=False
> if all_in_db: session.connect(request,response,db=db)
> if not session.t2: session.t2=Storage()
> self.id=request.args[-1] if request.args else 0
> self.person_name=session.t2.person_name
> self.person_id=session.t2.person_id
> self.person_email=session.t2.person_email
> self.user_role=session.t2.user_role
> self.logged_in=True if self.person_id else False
> self._define_messages()
> self._create_tables()
> if session.t2.my_groups_id:
> self.my_groups_id=session.t2.my_groups_id
> else:
> self.memberships=self.my_memberships()
> self.my_groups_id=[g.group_id for g in self.memberships]
> session.t2.my_groups_id=self.my_groups_id
> response.files=[
> '/plugin_t2/static/t2/scripts/jquery.js',
> '/plugin_t2/static/t2/styles/calendar.css',
> '/plugin_t2/static/t2/scripts/calendar.js',
> '/plugin_t2/static/t2/styles/sfmenu.css',
> '/plugin_t2/static/t2/scripts/sfmenu.js',
> '/plugin_t2/static/t2/scripts/fancyzoom.min.js',
> '/plugin_t2/static/t2/styles/rating.css',
> '/plugin_t2/static/t2/scripts/rating.js',
> '/plugin_t2/static/t2/scripts/web2py.js',
> ]
>
> def onerror(self): ### FIX - PASS MORE PARAMETERS
> """
> To be used as a decorator. On error it calles self._error()
> """
> def g(f):
> def h(*a,**b):
> try: return f(*a,**b)
> except HTTP, e: raise e
> except Exception: self._error()
> return h
> return g
>
> def _globals(self):
> """
> Returns (request,response,session,cache,T,db)
> """
> return self.request, self.response, self.session, \
> self.cache, self.T, self.db
>
> def _error(self):
> """
> Redirects to the self.error_action (='error'?) page.
> """
> self.redirect(self.error_action)
>
> def action(self,f=None,args=[],vars={}):
> """
> self.action('name',[],{}) is a shortcut for
>
> URL(r=request,f='name',args=[],vars={})
> """
> if not f: f=self.request.function
> if not isinstance(args,(list,tuple)): args=[args]
> return URL(r=self.request,f=f,args=args,vars=vars)
>
> def redirect(self,f=None,args=[],vars={},flash=None):
> """
> self.redirect('name',[],{},'message') is a shortcut for
>
> session.flash='message'
> redirect(URL(r=request,f='name',args=[],vars={})
> """
> if flash: self.session.flash=flash
> redirect(self.action(f,args,vars))
>
> def include(self):
> """
> In the layout.html <head>{{=t2.include()}}</head> includes all
> necessary CSS and JS files for this plugin to work.
> """
> s=''
> for file in self.response.files:
> if file[-4:]=='.css':
> s+=LINK(_href=file,
> _rel="stylesheet",
> _type="text/css",
> _charset="utf-8").xml()
> elif file[-3:]=='.js':
> s+=SCRIPT(_src=file).xml()
> return XML(s)
>
> def menu(self,menu,style='h'):
> """
> In the layout {{=t2.menu(style='h')}} inserts a menu from
> response.menu
>
> It assumes response.menu=[item1, items2, ...] where
> item1=['name',active True/False,URL(...),[item11,item12,...]]
> item11 is a submenu item, etc.
>
> style can be 'h' for horizontal, 'v' for vertical, 'n' for
> navigation
> """
> request,response,session,cache,T,db=self._globals()
> def rec_menu(menu,_class=None):
> items=[LI(A(i[0],_class='current' if i[1] else None,
> _href=i[2]),rec_menu(i[3]) if len(i)>3 else '')
> \
> for i in menu]
> return UL(_class=_class if _class else None,*items)
> if not menu: return ''
> _class='sf-menu'
> if style=='n': _class+=' sf-navbar'
> if style=='v': _class+=' sf-vertical'
> return rec_menu(menu,_class=_class)
>
> @staticmethod
> def _capitalize(text):
> return ' '.join([c.capitalize() for c in text.split('_')])
>
> @staticmethod
> def _get_labels(table):
> labels={}
> for field in table.fields:
> if hasattr(table[field],'label'):
> labels[field]=table[field].label
> return labels
>
> @staticmethod
> def _get_col3(table):
> col3={}
> for field in table.fields:
> if hasattr(table[field],'comment'):
> col3[field]=table[field].comment
> return col3
>
> def _define_messages(self):
> self.messages=Storage()
> self.messages.record_created="Record Created"
> self.messages.record_modified="Record Modified"
> self.messages.record_deleted="Record(s) Deleted"
> self.messages.record_was_altered="Record Could Not Be Saved
> Because It Has Changed"
> self.messages.invalid_value="Invalid Enrty"
> self.messages.attachment_posted="Attchment Posted"
> self.messages.no_comments="No Comments"
> self.messages.no_visible_comments="No Visible Comments"
> self.messages.review_posted="Review Posted"
> self.messages.register_email_body="Click here %
> (registration_key)s to complete registration"
> self.messages.register_email_subject="Verify Registration"
> self.messages.logged_in="Logged In"
> self.messages.invalid_login="Invalid Login"
> self.messages.logged_out="Logged Out"
>
> def _create_tables(self):
> """
> Defines all tables needed by the plugin to work
> (if they do not exist) called by contructor.
> """
> import uuid
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---