We have some pretty heavy sites on Pantheon, with big tables to manage our circulation, etc, with sizes over 1Gb and close to 2 million records. When we clone the environment for CI or dev purposes, it can take a while (15-30 minutes). So we have created a reference environment called master-lite, which mimics the content, but the huge tables are truncated. This exponentially reduces the backup size and time to clone.
We've set up some CI to test new branches we push up (hattip to Steve Persch, who helped us better understand CI and DevOps) and it will create a CI environment based on the master-lite, which doesn't take as long. Then one of the things it will do is perform a visual regression test between the CI environment (based on my dev branch) and the master-lite environment (which is based on the master branch).
All that sounds great, but unless I keep master-lite up-to-date, it can get stale pretty quickly, so I have created this Bash script to run several terminus commands to build the master-lite environment from our production environment:
Along with this script, I have separate .sql files named after the sites which have site-specific SQL commands to trim away the fat, so to speak. This script also has an if branch to exclude "site3" since that site hasn't grown to the point that I need to do any trimming.
Then I set this up as a cronjob to run every day at 3am from a separate server and now my master-lite environment is kept up-to-date automatically and it's much faster/easier to clone for CI/Dev purposes.
Thursday, April 18, 2019
Thursday, September 6, 2018
Moving from Lambda+DynamoDB to SQS
This is a follow-up to my previous post, where I was trying to offload the email tracking capabilities from our web server. Even with the more bulletproof Lambda function, I was losing some events because evidently, SNS tries 4 times and then gives up. Lambda was automatically scaling, but my writes to a DynamoDB table were not. So back to the drawing board!
I next moved from Lambda + DynamoDB to SQS, which seems to handle anything thrown at it, so that's awesome! Then I wrote a cronjob script to pull SQS messages, process them, and then delete them from the queue.
So now I can send a batch of emails through SES (using SendBulkTemplatedEmail), 50 at a time, which are set to use a configuration set to send email events (delivery, bounce, complaint, click, open, etc) to a SNS topic that is set to add it to a SQS queue. Once that's done, all events go to the queue and then every hour, I poll the queue to gather all messages and process/delete the relevant ones. I was able to send 7k emails in a few minutes and the load on my server was unnoticeable!
I next moved from Lambda + DynamoDB to SQS, which seems to handle anything thrown at it, so that's awesome! Then I wrote a cronjob script to pull SQS messages, process them, and then delete them from the queue.
So now I can send a batch of emails through SES (using SendBulkTemplatedEmail), 50 at a time, which are set to use a configuration set to send email events (delivery, bounce, complaint, click, open, etc) to a SNS topic that is set to add it to a SQS queue. Once that's done, all events go to the queue and then every hour, I poll the queue to gather all messages and process/delete the relevant ones. I was able to send 7k emails in a few minutes and the load on my server was unnoticeable!
Thursday, August 16, 2018
Tracking email performance with AWS
Background
For our two main websites (QSR & FNF), we send out a monthly e-letter to about 20k+ each and we have it setup such that it goes through Amazon SES and all email notifications (deliveries, bounces, unsubs, complaints, etc.) get posted back to the site. Our custom Drupal module receives each notification and updates several places so that we can track bounce rates, delivery rates, and opt out people who complain or unsubscribe. So our site bogs down (at least for authenticated traffic) when we send the 40k e-letters because these notifications bypass all of the layers of caching in order to make those database updates.Inspiration
Decoupled Drupal is a major mind-shift for me. QSR was our first Drupal (6) site back in 2010 and over the last 8 years, we have written over 40 custom modules to do things big (lead generation, circulation, etc.) and small (user surveys, etc.).The advantage is that it's one place for your users to go for all the tools they need. The disadvantage, though, is that your server resources are shared and is probably taking away from the higher priority of serving your users.
There's also something to be said about splitting a feature off into an environment where you're free to choose the best tech for the job, which might not necessarily be Drupal.
Setup
First, this article was a big help in getting things setup. I ended up using a different table schema, just having 4 fields, event_id (the SNS event messageid, which is also my primary key), the source (so I can gather items based on the site), a processed boolean flag, and the message itself, stringified JSON.One thing to keep in mind is that SNS posts its event differently to HTTP(S) than it does for Lambda, so you cannot rely on your HTTP(S) examples as test cases. I have a (sanitized) captured example here.
Finally, the easy/cool bit is changing the SNS subscription from your HTTP(S) endpoint to your Lambda function. You don't even have to program a subscription confirmation for that - it just works.
Next Steps
So I went live with this without testing an actual load scenario. Big mistake! Once the SNS messages came flying in, Lambda reported a ton of errors and DynamoDB's default write capacity caused a lot of throttling. So while Lambda can scale from input dynamically, what it does with the output can wreak havoc. I would highly recommend you do some load testing based on your situation. You can set up a test run to send 40k emails to a random assortment of AWS SES' test addresses. I ended up having to scramble my Lambda and DynamoDB configurations to bump up the timeout max and enable auto-scaling for writes. I ended up losing a lot of tracking data because my Lambda function didn't fail properly and SNS thought everything was OK and didn't try again. :(After I get that fixed and more bulletproof, my next step is to write a cron job to gather any unprocessed messages that belong to the site and process them. I'll write a follow-up post when I'm done with that.
And once I'm proud of my Lambda function, I'll post that, too. Update: Here it is.
Conclusion
So the tradeoff is that my reporting is not real-time and there are some AWS costs, but this frees up our web server to do what it should be doing best: serving content to our readers.
Labels:
aws,
cloudwatch,
decoupling,
drupal,
dynamodb,
email,
lambda,
ses,
sns
Thursday, August 2, 2018
DrupalCon changes = less value
Have you seen the latest changes for DrupalCon? They have replaced a day of sessions with an additional workshop/summit day (for an additional expense) and have increased the early-bird basic ticket price from $450 to $800. I went to DrupalCon Nashville and it was a good conference, but it felt more commercial and like a trade show with sponsors everywhere you look. I've also been to DrupalCamp Asheville (didn't get to go this year because of a scheduling conflict) and for me, I believe camps are a better bang for the buck and where I'll be focusing for continuing education.
Tuesday, July 24, 2018
Setting #default_value for date field in a D8 form
I had a hard time getting the #default_value to work for the date form field because the examples module and the documentation uses this approach:
$form['send_date'] = [
'#type' => 'date',
'#title' => $this->t("Send Date"),
'#default_value' => [
'month' => 2,
'day' => 15,
'year' => 2020,
],
];
After playing around with it for a while, I was able to get it to work by passing in a YYYY-MM-DD value, using date.formatter (the new way to format_date()).
$date_formatter = \Drupal::service('date.formatter');
$form['send_date'] = [
'#type' => 'date',
'#title' => $this->t("Send Date"),
'#default_value' => $date_formatter->format(REQUEST_TIME, 'html_date'),
];
Looks like this is a known issue that has also caused others lost time. :( Hopefully this will get rolled out soon.
$form['send_date'] = [
'#type' => 'date',
'#title' => $this->t("Send Date"),
'#default_value' => [
'month' => 2,
'day' => 15,
'year' => 2020,
],
];
After playing around with it for a while, I was able to get it to work by passing in a YYYY-MM-DD value, using date.formatter (the new way to format_date()).
$date_formatter = \Drupal::service('date.formatter');
$form['send_date'] = [
'#type' => 'date',
'#title' => $this->t("Send Date"),
'#default_value' => $date_formatter->format(REQUEST_TIME, 'html_date'),
];
Looks like this is a known issue that has also caused others lost time. :( Hopefully this will get rolled out soon.
Friday, June 8, 2018
Upgrading Drupal from 8.3 to 8.5
Background
I am the sysadmin and developer for Art & Object, a Drupal 8 website built with the Drupal Composer project. The version pin in composer for Drupal was 8, which in hindsight was too broad for our usage. Meaning Drupal point releases (8.3 to 8.4) require study to ensure you understand all the implications, which wasn't something I did. I just blindly did a composer update, thinking everything would be handled automatically.This really bit me when 8.4 came out because my server was running Debian Jessie, which runs PHP 5.6 and my composer didn't have a platform PHP configuration, so a lot of the underlying Symfony code updated to PHP 7. So I ended up doing a backgrade until I figured it out.
Then there were the critical security Drupal updates (SA-CORE-2018-002 and SA-CORE-2018-004) earlier this year that would not be released for 8.3, so I had to upgrade (or at least, at the time, I felt I had to, though I see now they have a patch for older 8.x releases). By that time, 8.5 was released, so I updated the composer to 8.5 and ran update and after some basic testing, moved on.
Then a few months later, I noticed the status error messages about running the contrib media module alongside the core and I knew I missed something and there was a problem.
I then started down a wicked rabbit hole of getting a local copy running and following the upgrade instructions, running into problem and going back to getting a local copy running fresh again and trying again. Lots of trail and error (mostly errors) and head-banging-on-the-desk. I looked for help on the #media IRC channel, but the best advice came from posting on Stack Overflow, where @sonfd pointed out that the media module needs to be uninstalled first. I thought I had tried that and ran into an error message that mentioned you can't uninstall the media module with media items already created.
The Fix
So after lots and lots (and lots) of local refreshes and trials and errors, here's the list I finally followed when it came time to upgrade production:- First, put the site in maintenance mode. Then take a database backup and make a tarball of your project directory. Don't skip over this.
- drush pmu media crop_media_entity: pmu = pm-uninstall. Remove the media module (and crop_media_entity, if you have that, too). This was the tip from @sonfd that opened the rest of this process for me.
- composer remove drupal/media: Remove the contrib media module from the filesystem. I should add that I prefixed all my composer commands with /usr/bin/php -d memory_limit=-1 /usr/local/bin/ because I often ran into memory limits when running composer.
- composer require drupal/inline_entity_form drupal/crop:1.x-dev drupal/media_entity_instagram:2.x-dev drupal/media_entity:2.x-dev drupal/media_entity_slideshow:2.x-dev drupal/media_entity_twitter:2.x-dev drupal/slick_media:2.x-dev drupal/media_entity_actions: These modules are temporary to help upgrade the database records.
- composer remove drupal/video_embed_field: For some reason, I couldn't require video_embed_field:2.x-dev, so I removed it and then...
- composer update: When I ran this, it updated video_embed_field to 2.x-dev.
- composer require drupal/media_entity_image drupal/media_entity_document drupal/image_widget_crop: More temporary modules to help the upgrade process.
- drush cr: Clear cache to make sure Drupal picks up new modules and paths.
- drush updb: Run the database updates.
- drush pmu entity media_entity: Uninstall these modules (these were the old contrib modules)
- composer remove drupal/media_entity drupal/media_entity_image drupal/media_entity_document drupal/crop drupal/image_widget_crop
/usr/bin/php -d memory_limit=-1 /usr/local/bin/composer require drupal/crop:2.x-dev drupal/image_widget_crop drupal/empty_page:2: Clean out the temporary modules from the filesystem. - drush cr: Clear caches
- drush updb: Run database updates
- drush cex: Export the configuration (so you can commit it later).
- The blazy module had an error with the core media and hasn't been updated (as of this writing), but there is a patch to fix that. So I learned how to add patches to a composer file - turned out pretty simple. Add this to composer.json in the extra section:
"patches": {
"drupal/blazy": {
"Gets Blazy to work with Drupal Core Media": "https://www.drupal.org/files/issues/2881849-8.patch"
}
} - composer update: This was odd, but I had to do an update, which picked up the patch, but didn't really install it. I can't remember exactly now, but I believe this actually deleted the blazy folder.
- composer remove drupal/blazy: So removing this actually installed it. Who knew? Whatever ... it's still in my composer.json and now the filesystem has the module and the patch.
- drush cr: Clear caches!
- For some reason, this upgrade created a new field called field_media_image_1 and assigned that as the source for the image media type, which broke some of the images on the site. So I edited media.type.image.yml file to revert source_field back to my original field_image.
- drush cim: Import my hack to get my media image type to work.
- I had a custom field formatter that I had to edit to change the namespace from media_entity to media.
- drush cr: Final cache clear!
- Test and make sure all is well. If so, take the site out of maintenance mode and commit your repo changes.
Advice / Conclusion
A lot of this pain could be negated by studying the release notes better. I own that and this counts as one of my many scars of lessons learned. I hope others can learn from my lesson, too. Someone may end up writing a meta post about this post to point out the high cost of maintaining a Drupal site and I don't think they'd be wrong about that, but that's the price you pay for running servers that are publicly accessible.Tuesday, October 24, 2017
Apex November 2017 Municipal Elections
It's that time of year again for municipal elections and we have two items coming up on the ballot, a parks bond and three seats on the town council.
First, let's talk about the Parks Bond. If you're unfamiliar with it, the town has put together a great FAQ that should address a lot of your questions. I asked John Brown, the Parks director, why the growth itself isn't enough to fund the initiatives and he pointed out that as we grow, those additional tax revenues are typically needed to offset the cost of providing services to meet the demands of the larger community (public safety, streets, infrastructure, etc). He also pointed out that if the funds are there, the council can opt to not issue some of the debt or increase taxes to repay it. If passed, the bond will add additional greenways (connecting 17 more neighborhoods!), provide for a senior center, and build out Pleasant Park (which could be useful for tournaments, meaning soccer parents, etc may not have to travel as much). In my opinion, this will have a great impact on our quality of life and we should all vote Yes for this.
Second, there are three spots opening up for the town council, Nicole Dozier, Gene Schulze, and Denise Wilkie's seats. Ms. Dozier is the only one running for re-election. There are five candidates running for these three seats:
I went to the candidate forum last night to hear from the candidates. If you were unable to make it, they will be posting a video on the Chamber website within a few days. Overall, the candidates seemed very similar to each other with very little disagreements.
So who has my votes? Well, I will be voting NDG (play on the NBA signs around town, encouraging people to vote for the block of Nicole, Brett, and Audra). Ms. Dozier impressed me with her experience, advocacy, and her drive to get a senior center in place. Mr. Hooks impressed me with his town experience (being on the planning board and a lifelong resident of Apex), poise, and volunteering with kids. Mr. Wilson impressed me with an emphasis on economic development.
Finally, if you want to see what the ballot will actually look like so you're prepared, you can see it here. Short and sweet!
Voting is November 7th! You can find election information here, including how to get an absentee ballot, your polling location, and more.
First, let's talk about the Parks Bond. If you're unfamiliar with it, the town has put together a great FAQ that should address a lot of your questions. I asked John Brown, the Parks director, why the growth itself isn't enough to fund the initiatives and he pointed out that as we grow, those additional tax revenues are typically needed to offset the cost of providing services to meet the demands of the larger community (public safety, streets, infrastructure, etc). He also pointed out that if the funds are there, the council can opt to not issue some of the debt or increase taxes to repay it. If passed, the bond will add additional greenways (connecting 17 more neighborhoods!), provide for a senior center, and build out Pleasant Park (which could be useful for tournaments, meaning soccer parents, etc may not have to travel as much). In my opinion, this will have a great impact on our quality of life and we should all vote Yes for this.
Second, there are three spots opening up for the town council, Nicole Dozier, Gene Schulze, and Denise Wilkie's seats. Ms. Dozier is the only one running for re-election. There are five candidates running for these three seats:
I went to the candidate forum last night to hear from the candidates. If you were unable to make it, they will be posting a video on the Chamber website within a few days. Overall, the candidates seemed very similar to each other with very little disagreements.
So who has my votes? Well, I will be voting NDG (play on the NBA signs around town, encouraging people to vote for the block of Nicole, Brett, and Audra). Ms. Dozier impressed me with her experience, advocacy, and her drive to get a senior center in place. Mr. Hooks impressed me with his town experience (being on the planning board and a lifelong resident of Apex), poise, and volunteering with kids. Mr. Wilson impressed me with an emphasis on economic development.
Finally, if you want to see what the ballot will actually look like so you're prepared, you can see it here. Short and sweet!
Voting is November 7th! You can find election information here, including how to get an absentee ballot, your polling location, and more.
Wednesday, October 11, 2017
Watch out for Drupal 8.4!
I was using a Drupal composer template and a few days ago, it upgraded from 8.3 to 8.4 automatically. I noticed and didn't really think much of it, so I applied the database updates and went on my way. Today, two days afterwards, I ran across this article which pointed out that PHP 7 is required for the underlying Symfony framework. Our site is running on Debian 8, which has PHP 5.6 and powers other PHP applications, so I wasn't looking to update the underlying OS and possibly break my other PHP things.
So I downloaded a db snap from 8.3 and then re-applied the 8.4 update and took another database snapshot. Then I diff'd the database snapshots. The biggest changes seemed to be in the cache tables and removing and adding some revision columns. So I reverse-engineered a backgrade SQL script. With that, I updated the composer.json file from this:
"drupal/core": "~8.0",
to this:
"drupal/core": "8.3.*",
Then I took a precautionary database backup and then did a composer update, which took care of the code backgrade. Then I ran my script (drush sqlc < backgrade.sql) and then I did a drush entity-updates to actually update the database schemas to match the backgraded code.
Now I just need to ignore Drupal telling me about 8.4 until I'm ready to fully embrace PHP 7. I feel like something bigger needed to get my attention to the update in system requirements when I ran the initial composer update.
So I downloaded a db snap from 8.3 and then re-applied the 8.4 update and took another database snapshot. Then I diff'd the database snapshots. The biggest changes seemed to be in the cache tables and removing and adding some revision columns. So I reverse-engineered a backgrade SQL script. With that, I updated the composer.json file from this:
"drupal/core": "~8.0",
"drupal/core": "8.3.*",
Now I just need to ignore Drupal telling me about 8.4 until I'm ready to fully embrace PHP 7. I feel like something bigger needed to get my attention to the update in system requirements when I ran the initial composer update.
Thursday, September 14, 2017
Ode to Sendgrid
I recently have been playing around with Sendgrid and it is pretty amazing. I have had some experience with sending email programmatically with AWS' SES product and it's nice, especially with its SNS integration, but Sendgrid's killer feature is its speed. I had about 6,000 emails to send, each one personalized with an individual URL and the person's first name. With AWS and a multi-threaded PHP program, I can send about 15 emails per second, which would have taken almost 7 minutes to process. With Sendgrid, I create a template in their system with template tags and then I create a massive data structure with up to 1,000 entries and then post it to the Sendgrid API. Rinse/repeat. I was able to send my 6,000 emails in 6 seconds! Sendgrid took care of the personalization on their end and I was seeing emails being delivered very soon after. Wow. Here's my script code:
I've only scratched the surface - there's lots more Sendgrid offers. One of the nice things is that you can get an activity feed and some nice stats after you send an email to see how people respond:
If you're a Google Cloud customer, they offer a free trial with up to 12,000 transactional emails per month. Definitely worth a checking out!
I've only scratched the surface - there's lots more Sendgrid offers. One of the nice things is that you can get an activity feed and some nice stats after you send an email to see how people respond:
![]() |
| Activity Log, showing opens, clicks, delivered, etc. |
![]() |
| Stat report, showing email performance. |
If you're a Google Cloud customer, they offer a free trial with up to 12,000 transactional emails per month. Definitely worth a checking out!
Monday, June 5, 2017
Global Climate
Climate change has been an ongoing issue for about 20 years (maybe more). I was influenced early on by Michael Crichton's book, State of Fear, which posits that there's no real scientific evidence of global warming. Plus, it was just another thing for humanity to focus on, that we need something to stay fearful of. It's an interesting theory, especially if you consider that the current growing fear of terrorism has probably reduced the fear of global warming, mitigating any resistance to progress. A few years ago, Casey shared this punnet-like square video of all the various perspectives of are we going to do anything about it and if global warming is caused by humans or not. So regardless of what you believe and if anything can be done, the risk of doing nothing seems a lot worse than the risk of doing something and it ending up not being a thing.
So with that out of the way, the current news of Trump and the Paris Climate Agreement has me more aware of local efforts. If the US government isn't going to lead the way, then we need to do what we can on a local level. As a North Carolina citizen, we have an opportunity to keep our state moving forward towards more renewable energy sources. There's a bill that was just filed with the NC House that rolls back some of the goals (the minimum stays at 6% vs. growing to 12.5% by 2021). I'm not a lawyer, but it also looks like nuclear energy will be considered renewable, which probably means that Duke Energy could just buy energy from its own nuclear plants vs. other renewable energy sources.
So, if you're a NC resident and you want to do something, you can find your representative and express your opinion. You can also look at what your town is up to.
Thursday, January 12, 2017
Drupal 8 project killed
I realize I haven't updated my blog in awhile, because I've been in the thick of developing and rolling out our new site (check it out!). This was taking our existing Drupal 7 site for FSR Magazine and migrating it to this new site, which is responsive and better catered to deal with all food service news. Unfortunately, we ended up killing the Drupal 8 upgrade because it was just too complex, given our custom module codebase. D8 has a mindset change, where everything is an Entity and it takes a lot of OOP and YAML files to get things done.
I figure it would cost us hundreds of hours to upgrade to D8 and it was tempting to upgrade to D8 for the configuration management, Big Pipe, and better caching features. But that's time and money we didn't want to spend on the upgrade.
I've talked with some folks at my local Drupal User Group (shoutout TriDUG!) and several others are in the same boat, where existing sites aren't upgrading, but rather, they're doing new sites in D8.
At some point, we'll need to do something, but we're able to do what we need with D7. If pressed, it may be easier to port to Backdrop vs. upgrade to D8.
I figure it would cost us hundreds of hours to upgrade to D8 and it was tempting to upgrade to D8 for the configuration management, Big Pipe, and better caching features. But that's time and money we didn't want to spend on the upgrade.
I've talked with some folks at my local Drupal User Group (shoutout TriDUG!) and several others are in the same boat, where existing sites aren't upgrading, but rather, they're doing new sites in D8.
At some point, we'll need to do something, but we're able to do what we need with D7. If pressed, it may be easier to port to Backdrop vs. upgrade to D8.
Monday, June 20, 2016
Entities (Porting Drupal 7 modules to Drupal 8)
Preface
Wow. Entities. What a mess. I really struggled with this. There's an example of a database-based module not using them and one that does use them. I think it boiled down to me that what I was representing were reports, which seemed very similar to nodes (in hindsight, perhaps this should have been a content type all along), so I should use entities.
Entities
As I look through examples, trying to figure out how to get my menu routing to work with my database entries, it appears that I need to set them up as entities. I say that, looking at the xmlsitemap and dbtng_example and content_entity_example from the examples module. So, let me back up and learn about D8 Entities. It looks like entities were introduced in Drupal 7 and there is a guide for that, but it's based on D7, so the concepts stuff is ok, but the implementation guidance is outdated. There's a link at the top to take you to a D8-specific guide. The guide says it's just a holder, but I'm going to give it a go. If nothing else, perhaps this post will help others.
First, entity types. Either you're setting up a configuration entity or a content entity. I think content entity fits for me. Next, looking at requirements section of the content type doc, I need to setup src/Entity/GatedContentEntity.php file with docblock stuff that will give the loader the information it needs. Hey, checkout this helpful hint about double quotes in the annotations doc (post #1 reference)! That annotations doc doesn't provide what all you need, but I'll take those 3 lines to start off with. I think this doc may list all of the properties you can use with ContentEntityType, but not sure which ones I really need and how to use them. This is when the examples/content_entity_example/src/Entity/Contact.php file helped. I first just used the core form & access handlers for now.
Random Aside: Sublime Text 3
I use Sublime Text 3 as my IDE and there is a PHPDoc plugin that makes life editing these annotations easier. Package Manager makes it easy to install plugins: just follow the installation instructions (and restart ST), then follow the usage instructions to pull up the Install Package option and then type phpdoc and select it to install. Then restart ST again and you'll be much happier. I think the same applies for Sublime Text 2, too. This Drupal doc has some other helpful Sublime Text tips.
Back to it...
So I found this great doc on how to create your own content entity. And whoa ... this comment pointed me to the Drupal Console project, which can jumpstart this a LOT. So I tucked my handcrafted code away and ran this command:
drupal --target="fnmd8.local" gect --module="gated_content" --entity-class="GatedContent" --entity-name="gated_content" --label="Gated Content"
The end result is about 10 files with lots of boilerplate fields that don't match up with what I'm using. Maybe I'm going about this all wrong. Maybe I don't need Entities? Time to take a break...
After the weekend
So I went back and added the preface above and I feel I need to stick the course with Entities. Perhaps this post will be totally rewritten after I totally understand them and and write a better guide that flows better. I need to just release this post because I'm about to flip back to some D7 work and will be taking another break. I'll pick this post thread back up again shortly.
Thursday, June 16, 2016
Porting custom module from Drupal 7 to Drupal 8 (databases, block view, URLs, and some menu work)
This is the next steps in getting my module working in Drupal 8. In the previous post, I got the block setup working, but it's just a generic "Hello World!" output. The block gets the most recent entries from a database table, so my next step is getting the database setup.
Once I had the database tables in place, I dumped my database tables from D7 and imported them into D8. NOTE: I probably need to either codify this (perhaps there's a way to hook into the migration system?) or keep notes about what tables to dump/import once everything's in place.
Now I needed to update my block to query the most recent entries in the table. db_query() is still supported in D8, however it looks like it's going away for D9, so if I wanted to future-proof my module even more, I could convert it to the new injection technique. So I created a storage class in my src folder. I downloaded the examples module and looked at the dbtng_example submodule and its DbtngExampleStorage class. I also found this answer on StackOverflow and the example posted in the select doc helpful. I ended up with a hybrid approach:
So a few things there. First, my post_date field was a legacy datetime field, so I had to convert the current time from a timestamp to the date format that mysql expected. format_date() is deprecated, so they recommend using Drupal::service('date.formatter'). Also, I make my __construct() method a little dynamic so that I don't have to pass in a connection, but it can support it if it is passed in.
Then my block build() method uses my storage class and calls the get_reports() method, passing in the block's configuration array. First, I add use Drupal\gated_content\GCStorage; to the top of my block plugin. Then my build() looks like this:
and foreach report, a
and l(); call to link to the report. Kind of reminds me of item_list a bit, so I think I'll start there.
Ok, it looks like item_list looks about the same. My render array just needs to '#theme' => 'item_list'. But l() is gone. This comment pointed me in the right direction. So now it looks like this:
Of course, these all link to just the homepage, which isn't very helpful.
Also, I had this module all setup with pathauto to get a nice SEO-friendly public URL. Ok, so I need to setup the menu routing so the user can get to /gated_content and /gated_content/[ID#] and /gated_content/[ID#]/download. And I need to setup pathauto again.
First, all of those URL's were setup in D7 with type of MENU_CALLBACK, so according to this doc, I need to set them up in a .routing.yml file. This wasn't something DMU setup for me, so I did this from scratch. This was a great doc that showed some examples going from D7 to D8.
My first question is that I was familiar with named placeholders and how the name would be used to call a NAME_load() function to put together the argument that gets passed into the callback. But these examples are using book, which uses node and entity, so I need something that will use my own data type.
Stuff for the next post!
Databases
This doesn't seem to have changed from Drupal 7 to 8. You basically copy over the .install file. The hook_schema() takes care of it. BTW, one thing that is different is if you need to uninstall/reinstall the modules, you just need to drush pm-uninstall MODULE vs. drush dis MODULE ; drush pm-uninstall MODULE.Once I had the database tables in place, I dumped my database tables from D7 and imported them into D8. NOTE: I probably need to either codify this (perhaps there's a way to hook into the migration system?) or keep notes about what tables to dump/import once everything's in place.
Now I needed to update my block to query the most recent entries in the table. db_query() is still supported in D8, however it looks like it's going away for D9, so if I wanted to future-proof my module even more, I could convert it to the new injection technique. So I created a storage class in my src folder. I downloaded the examples module and looked at the dbtng_example submodule and its DbtngExampleStorage class. I also found this answer on StackOverflow and the example posted in the select doc helpful. I ended up with a hybrid approach:
Then my block build() method uses my storage class and calls the get_reports() method, passing in the block's configuration array. First, I add use Drupal\gated_content\GCStorage; to the top of my block plugin. Then my build() looks like this:
public function build() {
$storage = new GCStorage;
$reports = $storage->get_reports($this->configuration);
$build = array();
kint($reports, $build);
return $build;
}
Block View
So now that my block has the right set of reports to show, I need to show them. This takes me to the whole theming and templates stuff. The D7 version called theme() directly and there was a hook_theme and I had a template. The end result was a simpleOk, it looks like item_list looks about the same. My render array just needs to '#theme' => 'item_list'. But l() is gone. This comment pointed me in the right direction. So now it looks like this:
$items = array();Success!
foreach ($reports as $report) {
$url = Url::fromRoute('');
$items[] = \Drupal::l(t($report['title']), $url);
}
$build = array(
'report_list' => array(
'#theme' => 'item_list',
'#items' => $items,
'#attributes' => array(
'class' => 'report-block',
),
),
);
Of course, these all link to just the homepage, which isn't very helpful.
Menu
So now I'm looking down another rabbit hole. The URL to my report is reports/[ID#]. But I use this module on separate domains, so the reports part is configurable. So I need to get that configuration setting to get the first bit of the URL. Actually, I think I can skip that since we'll be doing something different in our migration plans, so I can skip that part of the module. [postnote: if I do end up needing this, it looks like this shows how]Also, I had this module all setup with pathauto to get a nice SEO-friendly public URL. Ok, so I need to setup the menu routing so the user can get to /gated_content and /gated_content/[ID#] and /gated_content/[ID#]/download. And I need to setup pathauto again.
First, all of those URL's were setup in D7 with type of MENU_CALLBACK, so according to this doc, I need to set them up in a .routing.yml file. This wasn't something DMU setup for me, so I did this from scratch. This was a great doc that showed some examples going from D7 to D8.
My first question is that I was familiar with named placeholders and how the name would be used to call a NAME_load() function to put together the argument that gets passed into the callback. But these examples are using book, which uses node and entity, so I need something that will use my own data type.
Stuff for the next post!
Wednesday, June 15, 2016
Porting Drupal Blocks from Drupal 7 to Drupal 8
We are looking into porting our site to Drupal 8 and we have over 30 custom modules, so it's a pretty big undertaking. I thought I'd blog about the adventures in the hopes of helping others tackle porting to D8 as well as notes for myself.
Back in April, I took one of our sites and used Drupal Upgrade module to get it moved into D8, following these instructions. I really haven't touched it since then, so I can't really remember how that went. So I just blew the dust off and upgraded from 8.0 to 8.1 in the process. One of the first things I noticed is that comments were turned off, so I had to navigate into the various content types and edit them and edit the comments field to change it from Closed to Open.
Then I was looking through our custom modules and trying to figure out where to start first. Some of our stuff builds on top of each other, so I need to look at the hierarchy to determine what is something that isn't dependent on other things.
One of my first steps was to create a custom modules folder and copy my D7 custom module into that. I then copied the folder as a backup. Then I used the Drupal Module Upgrader (DMU) to generate an upgrade info report as well as attempt the upgrade process. Then I renamed that folder to append -auto and then I created a new folder where I will start work in earnest.
The module also has a block that shows the most recent gated content entries, which we include in our sidebar.
So I just wanted to start with the block and the block's settings.
I couldn't get dpm() (or dsm()) calls to show anything, so I stumbled across the kint submodule, which looks even better. You basically enable it and then use kint() vs. dpm(). One bonus is that kint() allows for multiple variables in the same call. It outputted the variable in a narrow region, but there's right arrow you can click on to open it in a new tab. And there's a useful stack trace beneath the output. One other thing I read is that dpm() doesn't have access to protected data, but kint() does.
Also, if you're not seeing output from either dpm() or kint() calls, try doing a cache-rebuild (drush cr). If that fixes it, you may want to setup local development configuration overrides so you don't have to rebuild manually every time.
Back in April, I took one of our sites and used Drupal Upgrade module to get it moved into D8, following these instructions. I really haven't touched it since then, so I can't really remember how that went. So I just blew the dust off and upgraded from 8.0 to 8.1 in the process. One of the first things I noticed is that comments were turned off, so I had to navigate into the various content types and edit them and edit the comments field to change it from Closed to Open.
Then I was looking through our custom modules and trying to figure out where to start first. Some of our stuff builds on top of each other, so I need to look at the hierarchy to determine what is something that isn't dependent on other things.
One of my first steps was to create a custom modules folder and copy my D7 custom module into that. I then copied the folder as a backup. Then I used the Drupal Module Upgrader (DMU) to generate an upgrade info report as well as attempt the upgrade process. Then I renamed that folder to append -auto and then I created a new folder where I will start work in earnest.
cd /path/to/drupal8 ;So my first custom module handles what we call "gated content," which is a collection of PDF files that our website users can request to download, which takes them to a request form and after they fill it out, it emails them a link to the PDF.
mkdir -p modules/custom/gated_content ;
cp -r /path/to/drupal7/sites/all/modules/custom/gated_content modules/custom/gated_content ;
cp -r /path/to/drupal7/sites/all/modules/custom/gated_content modules/custom/gated_content-orig ;
drush dmu-analyze gated_content --path=modules/custom/gated_content ;
drush dmu-upgrade gated_content --path=modules/custom/gated_content ;
mv modules/custom/gated_content modules/custom/gated_content-auto ;
mkdir modules/custom/gated_content ;
The module also has a block that shows the most recent gated content entries, which we include in our sidebar.
So I just wanted to start with the block and the block's settings.
The Block
One of the reasons I wanted to start from scratch is that this module is pretty big with lots of code that needs addressing to work in D8 and I'd like to incrementally get stuff working without having all the old stuff in there. So I copied the module's .info.yml and .permissions.yml files into my blank folder to start. No .module file. At least for now.
Blocks have a different way of doing things. You create a plugin. You don't need to point to your plugin through some .yml file. You create a src/Plugin/Block folder in your module and then create a php file for your plugin class. The filename needs to match PSR-4 specifications, which is the magic that autoloads all of this. So I called mine GCListBlock.php. One of my first lessons is that my namespace has to match the module name. My module name is gated_content and I initially used gatedcontent, which resulted in the block showing up in the list, but once you tried to place it in a region, it would result in an error.
Another odd thing is that the phpdoc is very specific with double quotes vs. single quotes. Use double quotes.
Using single quotes resulted in this error:
Doctrine\Common\Annotations\AnnotationException: [Syntax Error] Expected PlainValue, got ''' at position 18 in class Drupal\gated_content\Plugin\Block\GCListBlock. in Doctrine\Common\Annotations\AnnotationException::syntaxError() (line 42 of /Users/jason/Sites/devdesktop/fnmd8-dev/docroot/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php).
Another hiccup I ran across is I had t() calls through my block code that I had to change to $this->t().
I think there was some sort of 8.1 update, which wasn't reflected in the Blocks doc I was pointed to from the DMU report (I added a comment), that says $form_state is now a FormStateInterface. This also means you need to update accessing the form_state values to use $form_state->getValue('FORMFIELDNAME').
Finally, blocks don't just show up in the list of blocks on the blocks page like you might expect from Drupal 6/7 days. You have to click the Place Block button to pull up a list of available blocks and you should see it there. This is pretty neat because you can add a block more than once to a region or across multiple regions. I'm sure there's some way to differentiate the build based on its own order and region, but I don't have to worry about that for now.
Finally, blocks don't just show up in the list of blocks on the blocks page like you might expect from Drupal 6/7 days. You have to click the Place Block button to pull up a list of available blocks and you should see it there. This is pretty neat because you can add a block more than once to a region or across multiple regions. I'm sure there's some way to differentiate the build based on its own order and region, but I don't have to worry about that for now.
The Settings
I initially thought I needed to create a settings yml file, but actually, since the settings aren't used outside of the block code, they can be all specified and used in the block's class. You can provide the defaultConfiguration() method to specify the default values (return an array of keys to values).Bonus: Devel Module
One of the hiccups I faced was how to get the devel and dpm() calls working like I was used to in D7. One of the cool things I undercovered while getting devel setup is the webprofiler submodule, which adds a nifty toolbar at the bottom of the page with lots of development information and options.I couldn't get dpm() (or dsm()) calls to show anything, so I stumbled across the kint submodule, which looks even better. You basically enable it and then use kint() vs. dpm(). One bonus is that kint() allows for multiple variables in the same call. It outputted the variable in a narrow region, but there's right arrow you can click on to open it in a new tab. And there's a useful stack trace beneath the output. One other thing I read is that dpm() doesn't have access to protected data, but kint() does.
Also, if you're not seeing output from either dpm() or kint() calls, try doing a cache-rebuild (drush cr). If that fixes it, you may want to setup local development configuration overrides so you don't have to rebuild manually every time.
Tuesday, October 13, 2015
Apex Candidate Forum for Nov. 2015 Elections
Totally different topic than technology, but this is another topic I care about - my government. I'm raising two young daughters and am interested in providing them with an environment where they can be safe and thrive. Our town has gotten a little bit of attention; it has definitely grown since we moved here in 2002. Tonight was a candidate forum for the local elections, which I assert means more in my day-to-day life than any other little election going on. With the growth going on here, there's definitely an increased interest in the races. When I originally registered for the event, it was going to be held at the town hall, but they soon changed it to a new high school auditorium when it was apparent there was going to be a large crowd. I would estimate there were about 300 people in attendance.
There's a mayor race with 2 candidates and a town council race with 2 spots and 5 candidates.
The candidates talked about smart growth, using our #1 ranking and attraction to be more selective with the homes & businesses that want to come here. They saw a need for better roads and more water/sewer. There's an upcoming bond on the ballot that most (all?) candidates supported. It also seems like the Land Use plan needs to be updated.
Here are my notes from the question session:
There's a mayor race with 2 candidates and a town council race with 2 spots and 5 candidates.
Town Council Forum
The town council was first up. There were five candidates and they were given 90 seconds to make opening remarks and then the moderator (WRAL's Ken Smith!) would ask five questions (pre-selected, no audience interaction), giving each candidate 90 seconds to answer the question. After the five questions, each candidate would be given 90 seconds for closing remarks. Candidates were not able to challenge or address each other. This was a forum just to give the voting public an insight into their approaches.The candidates talked about smart growth, using our #1 ranking and attraction to be more selective with the homes & businesses that want to come here. They saw a need for better roads and more water/sewer. There's an upcoming bond on the ballot that most (all?) candidates supported. It also seems like the Land Use plan needs to be updated.
Here are my notes from the question session:
- What steps would you take to manage the influx of new residents?
- Helton: Invite more businesses. Don't say no to all opportunities.
- Jensen: Manage subdivisions with infrastructure. Incentivize businesses. Parks (called out Pleasant Park w/ 93 acres)
- Lassiter: Sustainable growth. Use land use plan. Strict standards/high fees for builders.
- Moyer: Set standards. Don't have to say Yes to all. Bring business to 540/64. Non-residential growth.
- Xavier: Managed growth. Keep eye on density.
- What are your top two infrastructure challenges and how would you address them?
- Jensen: Roads. Called out Kelly Rd/Olive Chapel Rd as a problem. $50M bond coming up to provide bridge over Salem St. for Peakway. Sewer/water.
- Lassiter: Roads. Approve transportation bond. Says it won't raise taxes. He sponsored the bill of getting out of the power business and says it saves the consumers money.
- Moyer: Traffic. Bond to help Peakway. Partner more with the DOT.
- Xavier: Roads. Annexation needs to include sewer/water. Avoid being in the business of provider power and implement it quicker.
- Helton: Bond. Sewer/Water is lifeblood. Looking at history, the $2M bond for sewer/water helped support the whole Beaver Creek Common shopping area.
- Would you support bond for Pleasant Park, even if it increases taxes?
- Lassiter: Would need concrete plan.
- Moyer: Agree. Would like to see plan tap into private funding. Let the public decide on the bond.
- Xavier: Fiscal conservative. No Bond. Wants senior center before a park.
- Helton: Needs to see a plan.
- Jensen: Need a plan. Voters will decide.
- What specific role should the council play when recruiting business?
- Moyer: Land Use Plan. Incubator.
- Xavier: Work proactively. In unison w/ builders and residents. Facilitate/manage process.
- Helton: Untie the hands of the economic development department. Allow them to offer incentives, such as free water/sewer for a year.
- Jensen: Revise land use plan. Add more business to the plan. Preplan infrastructure (water/sewer), so they can have it ready when a business shows up and ready to move in.
- Lassiter: He seemed more resistant, thinking we're fine w/ the residential percentages.
- Would you support a grant to match new investments for existing, expanding businesses?
- Xavier: Works elsewhere, even w/ Dell. Yes
- Helton: Yes. It's the right thing.
- Jensen: 80% of our growth comes from existing businesses, so yes, we need to support that.
- Lassiter: Skeptical, but if it's proven and ironclad, he would support it. Also if it didn't mean raising taxes. We already have a pretty good incentive with our workforce, open spaces, etc.
- Moyer: Invest in infrastructure.
In closing, Moyer seemed to get a dig into Lassiter by saying he's not using the council race as a stepping stone (Lassiter is rumored to run for higher office next). Lassiter was thankful to everyone and wanted to remind folks he's a fiscal conservative. Jensen stressed that we need more employers and a senior citizen center. Helton wrapped it up by saying we need to take some risks and that his mother-in-law is a great chef, so he's not going anywhere.
Mayor Forum
There are two candidates. Same format as the town council, but with six questions. Even with an additional question, they were done in less than half the time it took to field five questions to five candidates.
Olive opened that he's been here for 45 years and back then, the population was 1500. He's seen the downtown whither and then revitalize. Wilkie moved here in 1990 and wants to maintain our strong sense of community.
- How will you support the council when there's conflict?
- Olive: Unify council. Stop bickering and personal attacks. Work to find common ground. Meet with each member and find out what are their top five things they want to accomplish.
- Wilkie: The mayor is the CEO of the town. Represents the residents. Bring consensus.
- What do you want to accomplish?
- Wilkie: Economic development. Help small businesses grow.
- Olive: Hold public meetings to gather feedback. Election districts to make sure all areas of Apex are equally represented. Unique shops in downtown. No chains.
- How would you represent Apex in state or national venues?
- Olive: Work with Capital Area Metro to make sure Apex traffic is represented in overall plan.
- Wilkie: Work with DOT on roads.
- Businesses can't find space in Apex - how would you handle this?
- Wilkie: We should target 30% commercial tax base. Let them know we'll step up to help with infrastructure. Business-friendly.
- Olive: We're currently 82% residential. We need to review the plan, which should be derived from vision.
- Explain vision of economic development.
- Olive: It's going to come because of the #1 ranking. Need to work with existing businesses.
- Wilkie: Show businesses that we have the talent pool already, such as the academies in the high schools.
- Strategies for keeping up with being the best place to live?
- Wilkie: Being selective about businesses/subdivisions. Temper growth and selecting quality businesses and houses.
- Olive: Need to cast a vision for 20 years out. Insist on quality.
In closing, Wilkie said that Apex has a great staff and wants to support and use them. She's unaffiliated and so she doesn't have any party agenda. She wants to keep taxes low and businesses strong. Olive talked about breaking down his candidacy into three sections: Vision (history of working across party lines), Leadership (Cisco leadership, business school as an adult, and no party agenda, just an Apex agenda), and Experience (6 years on the planning board and 4 years on the council).
There's a local Apex Voter's Guide website that's pretty good, where you can get some more information. Don't forget to vote on November 3rd!
Monday, May 19, 2014
Talks submitted to IPC/WTC
I just submitted two talks for the +International PHP Conference.
Take your PHP app to the Cloud with Google AppEngineI was thinking I can use the experience I gained from the Google Cloud Developer Challenge to build upon for this talk.
Do you worry about not having the right amount of servers and configurations to handle your PHP app's success? Or do you worry about paying too much money for an over-architected solution? Google’s AppEngine only charges you for what’s used and can automatically scale up & down to meet your app’s demands. It’s a great way to deploy your PHP application into the cloud with managed scalability, performance and reliability. This session will guide you through a typical implementation as well as show you how to migrate your existing applications over.
I also submitted a workshop idea for +Drupal. I figure I'm still recently engaged enough with Drupal to tap into an outsider's perspective and at the same time, have the years of experience to share.
Building Your Web Presence with Drupal
If you’ve been considering using Drupal for your website, but find the documentation and vastness of the platform overwhelming, this workshop will give you a guided introduction that will give you the confidence you’re looking for. We’ll start with an overview and then go through the steps of building a site or migrating an existing site. Then we’ll highlight contributed modules & themes that can take your site to the next level. We’ll also cover how to extend Drupal by writing your own custom modules to extend Drupal farther. Finally, we’ll talk about some typical server configurations to ensure your website can handle its traffic.
And for good measure, I also submitted a talk I've given before on +Google Analytics to +WebTech Conference:
Making Cents from Google Analytics
Google Analytics is a free and powerful tool that should be utilized by every website. At first glance, you can easily retrieve common metrics, such as pageviews, visitors, etc, but if you don't dig deeper, you're missing out on some really powerful ways to monetize your website even further. This session will guide you through these deeper layers, helping you monetize your traffic.
What do you think? Sound like something you're interested in?
Monday, April 14, 2014
How to work with confirm_form in Drupal 7
Either my google-fu is losing its kung-fu grip or no one has really good documentation on confirm_form. This post hopes to change that (on both respects, since I hope to be able to find my own post later ;)). I have someone who's writing some custom Drupal module code to delete an object, but we want to confirm it with the user before actually deleting the object and she's running into a wall trying to understand how to accomplish that.
The trick is to use $form_state['rebuild'] = TRUE in your submit function. This kicks it back to your form method. So the form method should have two branches, one if it's the initial request and one if it's the confirmation request. Then your submit method should also have two branches, one for the initial submission and one for the confirmation submission. You should also use $form_state['storage'] to store the underlying states and data required for state discernment and form completion. Here's a simplified gist of what I'm getting at:
The healthy dose of dpm()'s are useful to help figure out what's going on, too. If you don't know, dpm() is a great function that's provided by the devel module.
I also uploaded the example module on GitHub for your perusal, download and adoption. :)
The trick is to use $form_state['rebuild'] = TRUE in your submit function. This kicks it back to your form method. So the form method should have two branches, one if it's the initial request and one if it's the confirmation request. Then your submit method should also have two branches, one for the initial submission and one for the confirmation submission. You should also use $form_state['storage'] to store the underlying states and data required for state discernment and form completion. Here's a simplified gist of what I'm getting at:
The healthy dose of dpm()'s are useful to help figure out what's going on, too. If you don't know, dpm() is a great function that's provided by the devel module.
I also uploaded the example module on GitHub for your perusal, download and adoption. :)
Tuesday, December 31, 2013
My Favorite 2013 Videos
I submit my favorite 15 videos from 2013. Not necessarily that they were created in 2013, but that I became aware of them in 2013. Why 15? Why not? Let's go!
I created a playlist of the 13 videos available on YouTube for your viewing pleasure.
#15: Flying Eagle POV
It's one thing to imagine this or to see a CGI rendering from the LOTR movies, but it's another thing altogether to see it for real.#14: Dream of the 90's - Portlandia on IFC
Ok, so this is not safe for work or safe for kids, but as a teenager of the 90's, I can relate to a lot of this. I just wish I watched this before going to DrupalCon in Portland back in May ... it would have explained a lot.#13: Zachary Quinto vs. Leonard Nimoy
Battle of the Spocks. A commercial, but to hear Nimoy sing the Ballad of Bilbo Baggins again is priceless.#12: Most Expensive Starbucks Drink
This should probably be stricken from the list for its hedonistic and consumer values, but if you were wondering how much you could spend on a Starbucks drink, look no further.#11: Two Monkeys Demand Equal Pay
Good to see that humans aren't the only selfish species.#10: Feynman on trains
My wife is ahead of me on appreciating Feynman and how he can make previously unapproachable subjects not only approachable, but understandable to the point where you could teach it. I enjoyed this talk on trains and had no idea they worked like this. Never really thought about it before, but now I get it.#9: Chompy the Shark
Yeah, I couldn't paddle fast enough and never (ever) go into that body of water again.#8: Billy Joel singing with a student accompanist
It took some stones to request this, but the guy has chops and the end result is pure magic.#7: Speed Painter on Anderson Cooper
I had to watch this multiple times.#6: Volvo Trucks Stunt with Jean-Claude Van Damme
Crazy stunt. Of course, Chuck Norris had to top that.#5: Latte for SharShar
SNL has really stepped up their game this year with some great comedy, including this great parody skit on the new Starbucks Verismo system. This video is no longer available on Hulu, but it looks like you can watch it on Vimeo.
#4: Almost Pizza
Another SNL gem. This is available on YouTube ... for now. I miss Bill Hader & Kristin Wiig.#3: What Does the Fox Say?
I'm sure I lose some hipster points for this, but it is so great and bonus points for being something I can play (& dance) with my kids.#2: New Hotspurs Manager
When NBC got the rights to the Premier League, they made a promo video with Jason Sudeikis.#1: Jaws recut
I will never look at Jaws the same way again and if anyone ever brings up the Jaws movie around me, I will start laughing (at least on the inside). Sooo good.I created a playlist of the 13 videos available on YouTube for your viewing pleasure.
Thursday, November 14, 2013
Well, that was fun
So I completed work on my Google Cloud Developer Challenge project and it's live and submitted for consideration. I even put together a quick video walkthrough. Now it's time to sit back, cross my fingers and hope for the best.
The last few days have been a mad scramble, as I was done earlier, but when it came to deploying the project on the real live AppEngine, I ran into a series of production issues. The big one I posted about on StackOverflow, but after not getting any help there, I stumbled across this brilliant AppEngine/CodeIgniter boilerplate on GitHub, so I restarted the project from that and copied my controllers, models and views over there. That worked, so then it was small polish things.
+Ian Barber wrote a great post about improving the credential flow, so that inspired me to come up with a logo, which I did with the Drawing app in Google Drive. I also took out the Drive scope since I wasn't yet using Drive, although I think I will at some point, so the users can pull in files from Drive as well as save their results there.
Then when it time to submit the app, I realized the domain had to be in the format gcdc2013-X.appspot.com. D'oh! Since you cannot rename the instance name, I then had to go and create a new application, configure it, setup billing, etc for the new (& proper) name.
So now we wait & see.
The last few days have been a mad scramble, as I was done earlier, but when it came to deploying the project on the real live AppEngine, I ran into a series of production issues. The big one I posted about on StackOverflow, but after not getting any help there, I stumbled across this brilliant AppEngine/CodeIgniter boilerplate on GitHub, so I restarted the project from that and copied my controllers, models and views over there. That worked, so then it was small polish things.
+Ian Barber wrote a great post about improving the credential flow, so that inspired me to come up with a logo, which I did with the Drawing app in Google Drive. I also took out the Drive scope since I wasn't yet using Drive, although I think I will at some point, so the users can pull in files from Drive as well as save their results there.
Then when it time to submit the app, I realized the domain had to be in the format gcdc2013-X.appspot.com. D'oh! Since you cannot rename the instance name, I then had to go and create a new application, configure it, setup billing, etc for the new (& proper) name.
So now we wait & see.
Saturday, November 9, 2013
Great news, even! [appengine project]
Not sure why I didn't stumble upon this until now, but I'm glad that I waited to develop the user aspect to my project. The PHP AppEngine folks have an unofficial blog with some neat tips & tricks, including this dandy to get the Google PHP API client library working inside of your AppEngine app. This is huge because with the library, you can take advantage of some of Google's modern systems.
So now instead of using AppEngine's native User class, I can now use my OAuth login approach. The old (2007!) User class was ok, but you aren't able to do much with the resulting user, beyond getting their nickname and ID #. With OAuth, you can get their profile picture to slap into your header, ask them to integrate with their other services (which you can use the library for, too).
My guess is that Google's working towards getting the library integrated into the runtime, but there's probably some dust that needs to settle somewhere.
So now instead of using AppEngine's native User class, I can now use my OAuth login approach. The old (2007!) User class was ok, but you aren't able to do much with the resulting user, beyond getting their nickname and ID #. With OAuth, you can get their profile picture to slap into your header, ask them to integrate with their other services (which you can use the library for, too).
My guess is that Google's working towards getting the library integrated into the runtime, but there's probably some dust that needs to settle somewhere.
Subscribe to:
Posts (Atom)







