Thanks for posting this, Jay. This is a great idea.
In terms of implementation details, what if macros were simply Python
scripts using the Boots API? This would simplify and formalize the
arguments/scope issues, allow them to be called easily by other
macros, and could make them usable standalone outside of the standard
console (sole).
Here's what your example might look like:
<example>
sales_report_with_email.py:
---
import datetime
import smtplib
# The macro decorator could add the function to a list so that the
Sole knows it's a macro function instead of a helper.
@macro
def sales_report_with_email(to_email, connections):
today = datetime.datetime.now().isoformat()
filename = python("%s-%s-%s" % ("sales", to_email, today));
connections.execute("SELECT * FROM sales WHERE manager =
@to_email", to_email).write(output.csv(filename))
report_txt = open(filename, "r+b").read()
mailserver = smtplib.SMTP("localhost")
mailserver.sendmail("[email protected]", to_email, report_txt)
mailserver.quit()
print "Mail sent to %s\n" % to_email"
---
Then:
drizzle> load sales_report_with_email
Loaded 1 macro: "sales_report_with_email"
drizzle> mode python;
drizzle> sales_report_with_email("[email protected]")
Mail sent to [email protected]
</example>
How important is interactive recording to you? Would it be sufficient
to just make them scripts that are callable from the Sole?
Regards,
--Max
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp