473,378 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how to access module level variable in class

Expand|Select|Wrap|Line Numbers
  1. import smtplib
  2. import mimetypes;
  3. from optparse import OptionParser;
  4. from email import Encoders;
  5. from email.Message import Message;
  6. from email.MIMEBase import MIMEBase;
  7. from email.MIMEMultipart import MIMEMultipart;
  8. from email.MIMEText import MIMEText;
  9.  
  10. from StringIO  import StringIO
  11.  
  12. mail_server_not_specify_form='''<?xml version="1.0"?>
  13. <form string="SMTP Mail Server Error!">
  14.     <separator string="Required Mail-Server!!!" colspan="4"/>
  15.     <label string="Mail-Server Configuration Required" colspan="4"/>
  16. </form>''';
  17.  
  18. error_form = '''<?xml version="1.0"?>
  19. <form string="SMTP Mail Server Error!">
  20.     <separator string="Required Mail-Server!!!" colspan="4"/>
  21.     <label string="%s" colspan="4"/>
  22. </form>'''
  23.  
  24. class wiz_latepayment(wizard.interface):
  25.     def __init__(self,name):
  26.         self.error_message = '';
  27.         super(wiz_latepayment,self).__init__(name)
  28.  
  29.     def _send_reminder(self, cr, uid, data, context):
  30. #        print "In send reminder ::",
  31.         this_obj = pooler.get_pool(cr.dbname).get('position.reminder').read(cr,uid,data['ids'])[0];
  32.         send_currier_ids = pooler.get_pool(cr.dbname).get('position.reminder.line').search(cr,uid,[('reminder_id','=',this_obj['id']),('states','=','gen')])
  33.         reminder_lines = pooler.get_pool(cr.dbname).get('position.reminder.line').browse(cr,uid,send_currier_ids);
  34.  
  35.         canal = False
  36. #        print "Reminder Linses ::",reminder_lines
  37.         for reminder_line in reminder_lines:
  38.             try:
  39.                 if reminder_line.send_by_email == 'yes' and not this_obj['smtp_id']:
  40.                     return 'mailservernotgivan';
  41.                 #end if reminder_line.send_by_email == 'yes' and not this_obj['smtp_id']:
  42.  
  43.                 ret_create_report = self._create_report(cr, uid, reminder_line)
  44. #                print "After create report ::",ret_create_report
  45.                 if not ret_create_report[0]:
  46.                     raise ret_create_report[1]
  47.                 #end if not ret_create_report[0]:
  48.  
  49.                 if reminder_line.send_by_email == 'yes':
  50.                     ret_get_email = self._get_email(cr, uid, reminder_line)
  51. #                    print "After get email ::",ret_get_email
  52.                     if ret_get_email[0]:
  53.                         body_message = self._get_body_message(reminder_line)
  54.                         ret_send_mail = self._send_mail(cr, uid, this_obj['smtp_id'][0], ret_get_email[1], ret_create_report[1], body_message)
  55.                         if not ret_send_mail[0]:
  56.                             raise ret_send_mail[1]
  57.                         else:
  58.                             canal = 'E-mail'
  59.                         #end if not ret_send_mail[0]:
  60.                     #end if ret_get_email[0]:
  61.                 #end if reminder_line.send_by_email == 'yes':
  62.                 if reminder_line.send_by_currier == 'yes':
  63.                     if canal:
  64.                         canal = 'Currier&E-mail'
  65.                     else:
  66.                         canal = 'Currier'
  67.                 #end if reminder_line.send_by_currier == 'yes':
  68.  
  69.                 if canal:
  70.                     self._create_crm_case(cr, uid, canal, 'Normal Reminder', reminder_line,ret_create_report[1])
  71.                     reminder_line.write(cr,uid,[reminder_line.id],{'states':'sent'})
  72.                 #end if canal:
  73.                 #DELETE FILE AFTER USE
  74.                 if os.path.exists(ret_create_report[1]):
  75.                     os.remove(ret_create_report[1]);
  76.                 #End if os.path.exists(file_name):
  77.             except Exception,e:
  78.                 print "Exception e :",e
  79.                 if not self.error_message:
  80.                     self.error_message = e.__str__() + '\n'
  81.                 else:
  82.                     self.error_message = self.error_message + e.__str__() + '\n'
  83.                 pass
  84.         if self.error_message:
  85.             error_form = error_form % self.error_message
  86.             return 'errorform'
  87.  
  88.         return 'printflag';
  89.     #end def _send_reminder(self, cr, uid, data, context):
  90.  

and i want to set the value of the %s by value of error_message and show it in the last as
Expand|Select|Wrap|Line Numbers
  1.  states = {
  2.  
  3.             'init': {
  4.                          'actions': [],
  5.                         'result': {'type':'choice', 'next_state': _send_reminder},
  6.                      },
  7.              'printflag':{
  8.                            'actions': [],
  9.                         'result': {'type':'print', 'report':'position.reminder.report', 'state':'end'}
  10.                           },
  11.              'errorform':{
  12.                            'actions': [],
  13.                             'result': {'type':'form', 'arch': str(error_form.buf), 'fields':{},'state':[('printflag','OK')]}
  14.                           },
  15.               'mailservernotgivan': {
  16.                             'actions': [],
  17.                             'result': {'type':'form', 'arch':mail_server_not_specify_form, 'fields':{}, 'state':[('end','OK')]}
  18.                             },
  19.              }
  20.  
  21.  
and states is class level variable so how can i set the value
May 1 '07 #1
1 2022
bartonc
6,596 Expert 4TB
I wish that I got credit for every time I add [code] tags.
May 2 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Fly Girl | last post by:
Gurus needed! I'm trying to use a Word class object in order to capture events in Word. Here's what I have, but the event code appWord_BeforeDocumentSave... doesn't ever fire. In a Class Module...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
49
by: Yannick Turgeon | last post by:
Hello, We are in the process of examining our current main application. We have to do some major changes and, in the process, are questionning/validating the use of MS Access as front-end. The...
9
by: MLH | last post by:
I need a fundamental explanation of Class Modules - something suitable for newbies. Access 2.0 didn't seem to focus on them very much. Now that I'm using Access 97, it seems they're everywhere. thx...
9
by: Clint | last post by:
Hey all - Excuse the cross-post ... I'm not sure what the appropriate newsgroup would be for this question. I have a question that I'm not quite sure how to ask. For all I know, I have the...
8
by: Floris van Haaster | last post by:
Hi All! I have a question, i have a web application and I store some member information in a variable i declared in a module like: Public some_info_variable as string in module1.vb But...
16
by: A_PK | last post by:
Hi, I am a VB.net beginner, I do not know what are the major difference between Module vs Class. Could someone guide me when is the best situation to use Module or Class. I have no idea...
17
by: GinTon | last post by:
How to access to a variable (that value is not returned) from a module imported? And the variable is set at the module-level. That module is external to my program, it's from another project so...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
4
by: RgeeK | last post by:
I have a main module doStuff.py and another module utility.py. At the start of doStuff.py I call import utility.py Then I also proceed to initiallize some global variables sName = "" ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.